Skip to content

cmd/link: DWARF5 output causes ~60,000 readelf warnings - incorrect DW_FORM_addrx offset calculation #77246

Description

@kajaaz

Go version

go version go1.25.6 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/xxx/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/xxx/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3231229538=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/xxx/Documents/optrollups/go-ethereum/go.mod'
GOMODCACHE='/home/xxx/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/xxx/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/xxx/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.6'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Built a large Go project (go-ethereum) with Go 1.25.6 and analyzed the DWARF debug information with GNU readelf:

git clone https://github.com/ethereum/go-ethereum
cd go-ethereum
# remove the flags '--strip-all' and '-trimpath' from the /build/ci.go file, add the flag '-gcflags all=-N -l'
make geth
readelf --debug-dump=info ./build/bin/geth 2>&1 | grep -c "readelf: Warning"
# Output: 60877

What did you see happen?

Building with Go 1.25.6 (DWARF5 enabled by default) produces 60,877 readelf warnings:

readelf: Warning: Offset into section .debug_addr too big: 0x47002e00
readelf: Warning: Offset into section .debug_addr too big: 0x47002e08
readelf: Warning: Offset into section .debug_addr too big: 0x47002e10
...

Example of failing function DIE:

<57>   DW_AT_addr_base   : 0x8
 <1><5b>: Abbrev Number: 3 (DW_TAG_subprogram)
    <5c>   DW_AT_name        : crypto/internal/fips140/ecdh.ecdh[go.shape.*crypto/internal/fips140/nistec.P256Point]
    <b2>   DW_AT_low_pc      :readelf: Warning: Offset into section .debug_addr too big: 0x47002e00

The compilation unit has DW_AT_addr_base: 0x8, which is correct. However, readelf computes offset 0x47002e00 instead of the expected small offset.
If we reverse the calculation:

  • readelf uses: offset = addr_base + (index × 8)
  • 0x47002e00 = addr_base + (index × 8)
  • This implies readelf is using addr_base ≈ 0x47002e00 instead of 0x8

The value 0x47 is ASCII 'G', suggesting readelf may be misreading unrelated data (possibly from strings like "github.com/...") as the addr_base.

Tools versions:

$ readelf --version
GNU readelf (GNU Binutils for Ubuntu) 2.42
$ readelf --debug-dump=info ./build/bin/geth 2>/dev/null | grep "Version:" | head -3
   Version:       5
   Version:       5
   Version:       5

What did you expect to see?

I expected readelf to parse the DWARF5 debug information without warnings and resolve function addresses correctly using the DW_AT_addr_base attribute.
Expected:

  • DW_AT_low_pc should resolve to actual function addresses
  • No "Offset into section .debug_addr too big" warnings
  • DWARF consumers (debuggers, binary analysis tools) should work correctly

This breaks DWARF-based debugging and analysis tools including:

  • GDB debugger
  • Binary analysis frameworks (angr, Ghidra DWARF import)
  • Security research tools for vulnerability analysis
  • Any tool using libdwarf/libdw to parse Go binaries

Possible causes:

  • The DWARF5 .debug_addr section format may not match what binutils expects
  • The relationship between compilation unit boundaries and DW_AT_addr_base scope may be malformed
  • There may be an issue with how DW_FORM_addrx indices are encoded or how they relate to the addr_base

Investigation notes:

  • The .debug_addr section exists and has a valid DWARF5 header
  • DW_AT_addr_base values are present in compilation units and appear reasonable (0x8, 0x130, etc.)
  • The indices stored in DW_FORM_addrx attributes are small valid numbers
  • But readelf computes wildly incorrect offsets (0x47002e00, 0x47002e08, etc.)
  • This was tested with binutils 2.42 (Ubuntu current) - latest available is 2.45

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions