{"record":{"id":"3796c2016fcf55df","repo":"golang/go","slug":"unknown-load-address-3796c2","errorCode":null,"errorMessage":"unknown load address","messagePattern":"unknown load address","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/internal/objfile/goobj.go","lineNumber":337,"sourceCode":"\t\t}\n\t}\n\t*p = s\n\treturn v\n}\n\n// We treat the whole object file as the text section.\nfunc (f *goobjFile) text() (textStart uint64, text []byte, err error) {\n\ttext = make([]byte, f.goobj.Size)\n\t_, err = f.f.ReadAt(text, f.goobj.Offset)\n\treturn\n}\n\nfunc (f *goobjFile) goarch() string {\n\treturn f.goobj.Arch\n}\n\nfunc (f *goobjFile) loadAddress() (uint64, error) {\n\treturn 0, fmt.Errorf(\"unknown load address\")\n}\n\nfunc (f *goobjFile) dwarf() (*dwarf.Data, error) {\n\treturn nil, errors.New(\"no DWARF data in go object file\")\n}\n","sourceCodeStart":319,"sourceCodeEnd":343,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/objfile/goobj.go#L319-L343","documentation":"Go object files (`.o` compiler output) are relocatable — they have no fixed load address because they are meant to be linked into a final binary. `goobjFile.loadAddress()` is a stub that always returns this error. Any caller that requests a load address from a `.o` file will get it, because the concept does not apply.","triggerScenarios":"Calling `File.LoadAddress()` on a `.o` Go object file (as opposed to a linked executable). The `objfile` package tries all formats, and if the file is a Go object file, `loadAddress` will fail.","commonSituations":"Accidentally pointing a binary analysis tool (pprof, objdump) at a `.o` file instead of a linked executable. A build script passing intermediate object files to a tool that expects finished binaries.","solutions":["Link the `.o` file into an executable first, then analyze the executable.","Check that you are pointing the tool at a linked binary: `file <path>` should say 'executable', not 'relocatable'.","Use `go tool nm` for symbol inspection of `.o` files, which does not require a load address."],"exampleFix":"// before — analyzing a .o file\nf, err := objfile.Open(\"main.o\")\naddr, err := f.LoadAddress()  // fails: no load address for .o\n\n// after — link first, then analyze\n$ go build -o main main.go\nf, err := objfile.Open(\"main\")\naddr, err := f.LoadAddress()  // succeeds","handlingStrategy":"validation","validationCode":"// Check if file is a linked executable, not a relocatable .o\nfunc isExecutable(path string) bool {\n    f, err := os.Open(path)\n    if err != nil { return false }\n    defer f.Close()\n    buf := make([]byte, 18)\n    f.Read(buf)\n    // ELF executables have e_type=ET_EXEC (2) or ET_DYN (3)\n    if bytes.HasPrefix(buf, []byte{0x7f, 'E', 'L', 'F'}) {\n        return buf[16] == 2 || buf[16] == 3\n    }\n    // Mach-O, PE, etc. — use 'file' command as heuristic\n    return true\n}","typeGuard":null,"tryCatchPattern":"addr, err := f.LoadAddress()\nif err != nil && strings.Contains(err.Error(), \"unknown load address\") {\n    if isGoObjectFile(path) {\n        log.Printf(\"%s is a .o object file — link it first\", path)\n    }\n}","preventionTips":["Link .o files into executables before running objfile-based tools.","Use 'file <path>' to confirm the file type before analysis.","Use 'go tool nm' for symbol inspection of .o files — it does not need a load address."],"tags":["goobj","load-address","relocatable","objfile"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}