{"record":{"id":"d02492c1ecdba194","repo":"golang/go","slug":"unknown-load-address","errorCode":null,"errorMessage":"unknown load address","messagePattern":"unknown load address","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/internal/objfile/elf.go","lineNumber":141,"sourceCode":"\t\t}\n\tcase elf.EM_S390:\n\t\treturn \"s390x\"\n\t}\n\treturn \"\"\n}\n\nfunc (f *elfFile) loadAddress() (uint64, error) {\n\tfor _, p := range f.elf.Progs {\n\t\tif p.Type == elf.PT_LOAD && p.Flags&elf.PF_X != 0 {\n\t\t\t// The memory mapping that contains the segment\n\t\t\t// starts at an aligned address. Apparently this\n\t\t\t// is what pprof expects, as it uses this and the\n\t\t\t// start address of the mapping to compute PC\n\t\t\t// delta.\n\t\t\treturn p.Vaddr - p.Vaddr%p.Align, nil\n\t\t}\n\t}\n\treturn 0, fmt.Errorf(\"unknown load address\")\n}\n\nfunc (f *elfFile) dwarf() (*dwarf.Data, error) {\n\treturn f.elf.DWARF()\n}\n\nfunc (f *elfFile) symbolData(start, end string) []byte {\n\telfSyms, err := f.elf.Symbols()\n\tif err != nil {\n\t\treturn nil\n\t}\n\tvar addr, eaddr uint64\n\tfor _, s := range elfSyms {\n\t\tif s.Name == start {\n\t\t\taddr = s.Value\n\t\t} else if s.Name == end {\n\t\t\teaddr = s.Value\n\t\t}","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/objfile/elf.go#L123-L159","documentation":"When analyzing an ELF binary, `elfFile.loadAddress()` scans all program headers (PT_LOAD segments) looking for one with the executable flag (PF_X) to determine the base virtual address. If no executable PT_LOAD segment is found, this error is returned. The load address is needed by tools like pprof to compute PC deltas from memory mappings.","triggerScenarios":"Calling `objfile.Open` followed by `File.LoadAddress()` on an ELF binary whose program headers contain no PT_LOAD segment with the PF_X (execute) flag. This happens with non-executable ELF files (shared libraries without exec segments, data-only ELFs, or kernel modules) or binaries produced by unusual linkers.","commonSituations":"Analyzing a shared library (`.so`) or a relocatable object that has no executable segment at the program-header level. Using pprof against a binary produced by a non-standard build process. Examining an ELF file that is not a normal Go executable.","solutions":["Verify the file is an ELF executable with at least one executable PT_LOAD segment: `readelf -l <file> | grep LOAD`.","Ensure the binary was linked normally (not `-nostdlib` or custom linker scripts that remove exec segments).","If analyzing a library or object, use the appropriate analysis path rather than expecting a load address.","Rebuild the binary with standard linking options."],"exampleFix":"// before — analyzing a .so with no exec PT_LOAD segment\nf, _ := objfile.Open(\"libfoo.so\")\naddr, err := f.LoadAddress()  // fails\n\n// after — analyze a linked executable\nf, _ := objfile.Open(\"main_executable\")\naddr, err := f.LoadAddress()  // succeeds","handlingStrategy":"fallback","validationCode":"// Check for executable PT_LOAD segment\nfunc hasExecutableLoadSegment(path string) bool {\n    f, err := elf.Open(path)\n    if err != nil { return false }\n    defer f.Close()\n    for _, p := range f.Progs {\n        if p.Type == elf.PT_LOAD && p.Flags&elf.PF_X != 0 {\n            return true\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"addr, err := f.LoadAddress()\nif err != nil && strings.Contains(err.Error(), \"unknown load address\") {\n    // Non-executable ELF; use 0 or infer from section addresses\n    addr = 0\n} else if err != nil {\n    return err\n}","preventionTips":["Ensure the ELF binary is a standard executable with executable PT_LOAD segments.","Do not use objfile on shared libraries or relocatable objects when a load address is needed.","Use 'readelf -l <file>' to verify program header layout before analysis."],"tags":["elf","binary-analysis","load-address","program-headers"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}