{"record":{"id":"85d075f51188a44c","repo":"golang/go","slug":"symbol-s-invalid-section-number-d-85d075","errorCode":null,"errorMessage":"symbol %s: invalid section number %d","messagePattern":"symbol (.+?): invalid section number (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/objfile/xcoff.go","lineNumber":116,"sourceCode":"}\n\nfunc (f *xcoffFile) text() (textStart uint64, text []byte, err error) {\n\tsect := f.xcoff.Section(\".text\")\n\tif sect == nil {\n\t\treturn 0, nil, fmt.Errorf(\"text section not found\")\n\t}\n\ttextStart = sect.VirtualAddress\n\ttext, err = sect.Data()\n\treturn\n}\n\nfunc findXCOFFSymbol(f *xcoff.File, name string) (*xcoff.Symbol, error) {\n\tfor _, s := range f.Symbols {\n\t\tif s.Name != name {\n\t\t\tcontinue\n\t\t}\n\t\tif s.SectionNumber <= 0 {\n\t\t\treturn nil, fmt.Errorf(\"symbol %s: invalid section number %d\", name, s.SectionNumber)\n\t\t}\n\t\tif len(f.Sections) < s.SectionNumber {\n\t\t\treturn nil, fmt.Errorf(\"symbol %s: section number %d is larger than max %d\", name, s.SectionNumber, len(f.Sections))\n\t\t}\n\t\treturn s, nil\n\t}\n\treturn nil, fmt.Errorf(\"no %s symbol found\", name)\n}\n\nfunc loadXCOFFTable(f *xcoff.File, sname, ename string) ([]byte, error) {\n\tssym, err := findXCOFFSymbol(f, sname)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tesym, err := findXCOFFSymbol(f, ename)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/objfile/xcoff.go#L98-L134","documentation":"findXCOFFSymbol locates a named symbol and then validates its SectionNumber. A SectionNumber <= 0 corresponds to special (undefined/absolute/debug) symbols that have no real section, which is unusable for the table-extraction caller that needs section-relative addressing. The lookup therefore fails for that symbol even though it exists by name.","triggerScenarios":"Looking up a symbol that exists in the XCOFF symbol table but whose SectionNumber is <= 0 (e.g. an undefined external reference or an absolute symbol).","commonSituations":"A binary where the requested symbol (e.g. runtime.pclntab) is still undefined because the object was not fully linked, or a symbol defined as absolute/debug.","solutions":["Use a fully-linked XCOFF executable so the symbol resolves to a real section.","Pick a symbol that is defined in a concrete section rather than an external reference."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-filter candidates: only symbols with SectionNumber > 0 are usable.\n// for _, s := range f.Symbols {\n//     if s.Name == name && s.SectionNumber > 0 && int(s.SectionNumber) <= len(f.Sections) {\n//         return s, nil\n//     }\n// }","typeGuard":null,"tryCatchPattern":"// s, err := findXCOFFSymbol(f, name)\n// if err != nil {\n//     // 'invalid section number' -> symbol is undefined/absolute; use a linked binary\n//     return nil, err\n// }","preventionTips":["Use fully-linked XCOFF executables so symbols resolve to real sections.","Avoid looking up symbols that may remain undefined externals.","Rebuild if the requested symbol is unexpectedly undefined."],"tags":["xcoff","aix","symbol","objfile"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}