golang/go · error

could not parse .ARM.attributes

Error message

could not parse .ARM.attributes

What it means

Inside the `aeabi` subsection, `.ARM.attributes` carries a list of (tag,value) attributes parsed by `elfAttributeList.armAttr()`. If that parser records an internal error (`attrList.err != nil`) — e.g. a ULEB128 tag that overruns the buffer, an attribute value of the wrong type, or a subsection size that does not match its contents — the linker reports a generic parse failure, because it cannot reliably determine attributes like `Tag_VFP_args` (the hard-float ABI marker).

Source

Thrown at src/cmd/link/internal/loadelf/ldelf.go:229

		for len(sectiondata) != 0 {
			subsectiontag, sz := binary.Uvarint(sectiondata)
			subsectionsize := e.Uint32(sectiondata[sz:])
			subsectiondata := sectiondata[sz+4 : subsectionsize]
			sectiondata = sectiondata[subsectionsize:]

			if subsectiontag != TagFile {
				continue
			}
			attrList := elfAttributeList{data: subsectiondata}
			for !attrList.done() {
				attr := attrList.armAttr()
				if attr.tag == TagABIVFPArgs && attr.ival == 1 {
					found = true
					ehdrFlags = 0x5000402 // has entry point, Version5 EABI, hard-float ABI
				}
			}
			if attrList.err != nil {
				return false, 0, fmt.Errorf("could not parse .ARM.attributes\n")
			}
		}
	}
	return found, ehdrFlags, nil
}

// Load loads the ELF file pn from f.
// Symbols are installed into the loader, and a slice of the text symbols is returned.
//
// On ARM systems, Load will attempt to determine what ELF header flags to
// emit by scanning the attributes in the ELF file being loaded. The
// parameter initEhdrFlags contains the current header flags for the output
// object, and the returned ehdrFlags contains what this Load function computes.
// TODO: find a better place for this logic.
func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, f *bio.Reader, pkg string, length int64, pn string, initEhdrFlags uint32) (textp []loader.Sym, ehdrFlags uint32, err error) {
	errorf := func(str string, args ...any) ([]loader.Sym, uint32, error) {
		return nil, 0, fmt.Errorf("loadelf: %s: %v", pn, fmt.Sprintf(str, args...))
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Rebuild the ARM object with a mainstream, stable GCC/Clang release.
  2. `go clean -cache && go build -a` to flush any corrupt objects.
  3. Inspect with `readelf -A <obj>`; if it reports errors, the object is the problem.
  4. Upgrade Go — attribute parsing has been hardened across releases.
Defensive patterns

Strategy: validation

Validate before calling

for obj in $(find build -name '*.o'); do
  readelf -A "$obj" >/dev/null 2>&1 || echo "unparseable ARM attributes in $obj"
done

Try / catch

set +e
go build ./...
rc=$?
set -e
if [ $rc -ne 0 ]; then
  go clean -cache && go build -a ./...
fi

Prevention

When it happens

Trigger: An ARM object with a malformed attribute value (truncated ULEB128, integer where a string is expected); a subsection whose declared size disagrees with its bytes; an object from a toolchain emitting attributes the parser does not understand.

Common situations: Cross-compiling with an unusual or experimental ARM toolchain; corrupted cache; object generated by a custom assembler emitting non-standard tags.

Related errors


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