Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"debug/dwarf"
"debug/elf"
"fmt"
"io"
"log"
"os"
)
func main() {
elfFile, err := elf.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
dwarfData, err := elfFile.DWARF()
if err != nil {
log.Fatal(err)
}
entryReader := dwarfData.Reader()
for {
// Read all entries in sequence
entry, err := entryReader.Next()
if err == io.EOF {
// We've reached the end of DWARF entries
break
}
// Check if this entry is a function
if entry.Tag == dwarf.TagSubprogram {
// Go through fields
for _, field := range entry.Field {
if field.Attr == dwarf.AttrName {
fmt.Println(field.Val.(string))
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment