tmp.symbols/main.go
Vincent Batts 19a8ea518a
Initial commit
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2024-05-26 21:00:18 -04:00

66 lines
1 KiB
Go

package main
import (
"debug/elf"
"fmt"
"os"
"github.com/go-delve/delve/pkg/dwarf/godwarf"
"github.com/sirupsen/logrus"
)
func main() {
fpath := "/home/vbatts/bin/cosign"
if len(os.Args) > 1 {
fpath = os.Args[1]
}
f, err := elf.Open(fpath)
if err != nil {
logrus.Fatal(err)
}
defer func() {
if err := f.Close(); err != nil {
logrus.Warn(err)
}
}()
buf, err := godwarf.GetDebugSectionElf(f, "abbrev")
if err != nil {
logrus.Fatal(err)
}
fmt.Println(buf)
libs, err := f.ImportedLibraries()
if err != nil {
logrus.Fatal(err)
}
fmt.Printf("Libraries:\n%#v\n", libs)
func() {
syms, err := f.ImportedSymbols()
if err != nil {
logrus.Warn(err)
} else {
fmt.Printf("ImportedSymbols:\n%#v\n", syms)
}
}()
syms, err := f.DynamicSymbols()
if err != nil {
logrus.Warn(err)
} else {
fmt.Printf("DynamicSymbols:\n%#v\n", syms)
}
syms, err = f.Symbols()
if err != nil {
logrus.Warn(err)
} else {
fmt.Printf("Symbols:\n%#v\n", syms)
}
d, err := f.DWARF()
if err != nil {
logrus.Fatal(err)
}
_ = d
}