Skip to content

Instantly share code, notes, and snippets.

@qzaidi
Created March 9, 2017 23:54
Show Gist options
  • Save qzaidi/d4c1df63c85005913ebeb7a5c4b13b42 to your computer and use it in GitHub Desktop.
Save qzaidi/d4c1df63c85005913ebeb7a5c4b13b42 to your computer and use it in GitHub Desktop.
package main
import (
"os"
"fmt"
"log"
"debug/elf"
)
func main() {
bin, err := os.OpenFile(os.Args[0],os.O_RDONLY,0)
if err != nil {
log.Fatalln("can't open file",err)
}
f,err := elf.NewFile(bin)
if err != nil {
log.Fatalln("elf read error",err)
}
if sect := f.Section(".gosymtab"); sect != nil {
fmt.Println("found a .gosymtab")
}
if sect := f.Section(".note.go.buildid"); sect != nil {
fmt.Println("found note", sect.Name, sect.Type)
if d,err := sect.Data(); err == nil {
fmt.Println(string(d[:]))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment