golang/go · error

loadxcoff: %v: %v

Error message

loadxcoff: %v: %v

What it means

The Go linker's XCOFF object loader (used on AIX) encountered an error while loading an XCOFF format object file. This is a generic wrapper error from the `errorf` closure in the `Load` function; it prefixes the path of the file being loaded with the specific error message. XCOFF is IBM's object file format used on AIX, and this loader handles host object files (typically C code compiled via cgo) during linking on AIX.

Source

Thrown at src/cmd/link/internal/loadxcoff/ldxcoff.go:46

type xcoffBiobuf bio.Reader

func (f *xcoffBiobuf) ReadAt(p []byte, off int64) (int, error) {
	ret := ((*bio.Reader)(f)).MustSeek(off, 0)
	if ret < 0 {
		return 0, errors.New("fail to seek")
	}
	n, err := f.Read(p)
	if err != nil {
		return 0, err
	}
	return n, nil
}

// loads the Xcoff file pn from f.
// Symbols are written into loader, and a slice of the text symbols is returned.
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Reader, pkg string, length int64, pn string) (textp []loader.Sym, err error) {
	errorf := func(str string, args ...any) ([]loader.Sym, error) {
		return nil, fmt.Errorf("loadxcoff: %v: %v", pn, fmt.Sprintf(str, args...))
	}

	var ldSections []*ldSection

	f, err := xcoff.NewFile((*xcoffBiobuf)(input))
	if err != nil {
		return nil, err
	}
	defer f.Close()

	for _, sect := range f.Sections {
		//only text, data and bss section
		if sect.Type < xcoff.STYP_TEXT || sect.Type > xcoff.STYP_BSS {
			continue
		}
		lds := new(ldSection)
		lds.Section = *sect
		name := fmt.Sprintf("%s(%s)", pkg, lds.Name)

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Read the specific error message after the file path to understand what sub-operation failed (section type, symbol, relocation, etc.).
  2. Ensure you are using a compatible C compiler on AIX — check the Go release notes for the minimum required xlC/gcc version.
  3. Clean and rebuild: `go clean -cache && go build` to eliminate stale or corrupt object files.
  4. If possible, switch from xlC to gcc or vice versa on AIX to see if the alternate compiler produces compatible output.
  5. Update Go to the latest version — XCOFF loader support is actively maintained for AIX.

Example fix

# Clean and rebuild on AIX
go clean -cache
GOOS=aix go build ./...

# Verify C compiler compatibility
xlC --version  # or: gcc --version
Defensive patterns

Strategy: try-catch

Validate before calling

// The Load function is linker-internal; validate XCOFF files externally:
// Use AIX 'dump' command: dump -o file.o
// Or use 'file' command to verify XCOFF format: file file.o

Try / catch

// In Go linker integration code (if wrapping the linker):
//   textp, err := loadxcoff.Load(l, arch, ver, input, pkg, length, pn)
//   if err != nil {
//       // err contains "loadxcoff: <path>: <detail>"
//       log.Printf("XCOFF load failed for %s: %v", pn, err)
//       return fmt.Errorf("cannot link AIX object %s: %w", pn, err)
//   }

Prevention

When it happens

Trigger: Fires from the `errorf` closure at ldxcoff.go:45-47, which is called at various points within the `Load` function when parsing errors occur (e.g., unrecognized section type at line 70, symbol processing failures). The function is invoked by the Go linker when processing .o files on GOOS=aix. The `xcoff.NewFile` call at line 51 can also fail separately (returning its own error without the wrapper).

Common situations: Compiling Go with cgo on AIX (`GOOS=aix`) where the C compiler (xlc or gcc) produces object files the Go linker cannot parse. Using an incompatible or outdated version of xlC/gcc on AIX. Mixing object files from different AIX toolchains. Corrupt object files from interrupted builds. AIX-specific ABI changes in newer compiler versions not yet handled by Go's XCOFF loader.

Related errors


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