golang/go · error

text section not found

Error message

text section not found

What it means

xcoffFile.text() looks up the '.text' section to extract executable code and its starting virtual address. If Section(".text") returns nil, the file has no text segment and code extraction cannot proceed.

Source

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

	}

	return syms, nil
}

func (f *xcoffFile) pcln() (textStart uint64, pclntab []byte, err error) {
	if sect := f.xcoff.Section(".text"); sect != nil {
		textStart = sect.VirtualAddress
	}
	if pclntab, err = loadXCOFFTable(f.xcoff, "runtime.pclntab", "runtime.epclntab"); err != nil {
		return 0, nil, err
	}
	return textStart, pclntab, nil
}

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

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Inspect the fully-linked XCOFF executable rather than an intermediate object.
  2. Rebuild the AIX binary.
  3. Verify the file with AIX 'dump -ov' or 'file'.
Defensive patterns

Strategy: try-catch

Try / catch

// textStart, text, err := xf.text()
// if err != nil {
//     if strings.Contains(err.Error(), "text section not found") {
//         // not a linked XCOFF executable
//     }
//     return err
// }

Prevention

When it happens

Trigger: Calling text() on an xcoffFile whose underlying xcoff.File has no '.text' section — e.g. a relocatable/object file before final linking, or a non-executable XCOFF.

Common situations: Pointing the tool at a .o relocatable object instead of the linked executable, or a corrupted AIX binary.

Related errors


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