golang/go · error

symbol %s: section number %d is larger than max %d

Error message

symbol %s: section number %d is larger than max %d

What it means

findXCOFFSymbol's second validation: after confirming SectionNumber > 0, it checks that SectionNumber <= len(f.Sections). If the symbol claims a section beyond what the file actually contains, the file is internally inconsistent and the lookup fails rather than index out of range.

Source

Thrown at src/cmd/internal/objfile/xcoff.go:119

	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
	}
	if ssym.SectionNumber != esym.SectionNumber {
		return nil, fmt.Errorf("%s and %s symbols must be in the same section", sname, ename)
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Rebuild the AIX binary.
  2. Verify file integrity with AIX tooling.
  3. Ensure the Go toolchain's debug/xcoff version matches the binary producer.
Defensive patterns

Strategy: try-catch

Try / catch

// s, err := findXCOFFSymbol(f, name)
// if err != nil {
//     if strings.Contains(err.Error(), "larger than max") {
//         // XCOFF is internally inconsistent; rebuild
//     }
//     return nil, err
// }

Prevention

When it happens

Trigger: An XCOFF symbol whose SectionNumber is positive but greater than the number of sections in f.Sections.

Common situations: Corrupted or truncated XCOFF file whose section header table is incomplete relative to its symbol table, or an incompatible parser.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/f3298c658a4730bb. Report an issue: GitHub.