golang/go · error
symbol %s: invalid section number %d
Error message
symbol %s: invalid section number %d
What it means
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.
Source
Thrown at src/cmd/internal/objfile/xcoff.go:116
}
func (f *xcoffFile) text() (textStart uint64, text []byte, err error) {
sect := f.xcoff.Section(".text")
if sect == nil {
return 0, nil, fmt.Errorf("text section not found")
}
textStart = sect.VirtualAddress
text, err = sect.Data()
return
}
func findXCOFFSymbol(f *xcoff.File, name string) (*xcoff.Symbol, error) {
for _, s := range f.Symbols {
if s.Name != name {
continue
}
if s.SectionNumber <= 0 {
return nil, fmt.Errorf("symbol %s: invalid section number %d", name, s.SectionNumber)
}
if len(f.Sections) < s.SectionNumber {
return nil, fmt.Errorf("symbol %s: section number %d is larger than max %d", name, s.SectionNumber, len(f.Sections))
}
return s, nil
}
return nil, fmt.Errorf("no %s symbol found", name)
}
func loadXCOFFTable(f *xcoff.File, sname, ename string) ([]byte, error) {
ssym, err := findXCOFFSymbol(f, sname)
if err != nil {
return nil, err
}
esym, err := findXCOFFSymbol(f, ename)
if err != nil {
return nil, err
}View on GitHub (pinned to b6b368adc5)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-filter candidates: only symbols with SectionNumber > 0 are usable.
// for _, s := range f.Symbols {
// if s.Name == name && s.SectionNumber > 0 && int(s.SectionNumber) <= len(f.Sections) {
// return s, nil
// }
// } Try / catch
// s, err := findXCOFFSymbol(f, name)
// if err != nil {
// // 'invalid section number' -> symbol is undefined/absolute; use a linked binary
// return nil, err
// } Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- no %s symbol found
- invalid section number in symbol table
- text section not found
- symbol %s: section number %d is larger than max %d
- %s and %s symbols must be in the same section
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/85d075f51188a44c.
Report an issue: GitHub.