import ( "go/cmd/internal/obj" "os" ) func main() { f, err := os.Open("main.o") if err != nil { panic(err) } defer f.Close() prog, err := obj.ReadProg(f) if err != nil { panic(err) } // Now you can access the fields of prog struct }
import ( "go/cmd/internal/obj" "os" ) func main() { f, err := os.Open("main.o") if err != nil { panic(err) } defer f.Close() prog, err := obj.ReadProg(f) if err != nil { panic(err) } for _, symbol := range prog.Syms { if symbol.Type == obj.SDATA && symbol.Name == "gohostline" { var lno obj.Lineno lno.PC = symbol.Value obj.GetLinenos(prog, &lno) // Now you can access the fields of lno struct } } }In this example we are using the `GetLinenos` function to extract line number information for a particular symbol in the object file.