golang/go · error

invalid section number in symbol table

Error message

invalid section number in symbol table

What it means

While mapping XCOFF (AIX) symbols into the objfile Sym form, the code resolves each symbol's section by 1-based index. After handling the special N_UNDEF/N_ABS/N_DEBUG cases, any SectionNumber that is negative or larger than the number of sections in the file is rejected as corrupt, since indexing f.xcoff.Sections would be out of range.

Source

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

	var syms []Sym
	for _, s := range f.xcoff.Symbols {
		const (
			N_UNDEF = 0  // An undefined (extern) symbol
			N_ABS   = -1 // An absolute symbol (e_value is a constant, not an address)
			N_DEBUG = -2 // A debugging symbol
		)
		sym := Sym{Name: s.Name, Addr: s.Value, Code: '?'}

		switch s.SectionNumber {
		case N_UNDEF:
			sym.Code = 'U'
		case N_ABS:
			sym.Code = 'C'
		case N_DEBUG:
			sym.Code = '?'
		default:
			if s.SectionNumber < 0 || len(f.xcoff.Sections) < s.SectionNumber {
				return nil, fmt.Errorf("invalid section number in symbol table")
			}
			sect := f.xcoff.Sections[s.SectionNumber-1]

			// debug/xcoff returns an offset in the section not the actual address
			sym.Addr += sect.VirtualAddress

			if s.AuxCSect.SymbolType&0x3 == xcoff.XTY_LD {
				// The size of a function is contained in the
				// AUX_FCN entry
				sym.Size = s.AuxFcn.Size
			} else {
				sym.Size = s.AuxCSect.Length
			}

			sym.Size = s.AuxCSect.Length

			switch sect.Type {
			case xcoff.STYP_TEXT:

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Rebuild the AIX (ppc/ppc64) binary cleanly.
  2. Verify the file with AIX tooling (e.g. 'dump') before inspection.
  3. Ensure you are using a Go toolchain version whose debug/xcoff matches the binary's producer.
Defensive patterns

Strategy: try-catch

Try / catch

// syms, err := xf.symbols()
// if err != nil {
//     if strings.Contains(err.Error(), "invalid section number") {
//         // XCOFF symbol table is internally inconsistent; rebuild
//     }
//     return nil, err
// }

Prevention

When it happens

Trigger: Iterating XCOFF symbols where a symbol's SectionNumber is not one of the special constants and falls outside [1, len(f.xcoff.Sections)].

Common situations: A corrupted or hand-edited XCOFF binary, a truncated file whose section table was cut off, or a mismatched/incompatible debug/xcoff parser version.

Related errors


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