cmd/link: corrupted pclntab created by binutils strip for PIE binary #67261
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
release-blocker
Milestone
Go version:
This problem happens for Go 1.23 (tip), but is not applicable for previous versions.
It appears that a recent change to the linker to enable full RELRO triggers some unpleasant behavior when Go programs are processed with "strip" (the binutils tool) for ELF targets. It should be noted that the problem only crops up for
-buildmode=pie
binaries.The change in question is CL 473495, which moves the
.got
and.dynamic
sections from writable data into.data.rel.ro
when PIE buildmode is enabled (note that this change was initially rolled back and then rolled forward again in CL 571417). The resulting Go binaries execute properly, but something in the way they are constructed triggers a bug in the binutils version ofstrip
. Here is an example to demonstrate:The failure mode here ("invalid function symbol table") is due to the fact that the pclntab has been corrupted; when the Go runtime tries to read the pclntab section header it finds that the magic string is corrupted.
Unclear as to exactly what it is that is causing binutils
strip
to do the wrong thing. Regardless, it would be great if we could come up with some sort of workaround (e.g. tweak our ELF generation in some way that will bypass the bug). Even if we track down the problem in strip (assuming it is indeed a bug there), Go users who runstrip
are likely to run into this problem.Also worth noting that this is not an issue with external linking; if we can figure out what it is that the external linker is doing to make
strip
happy and do the same thing in the Go linker, that seems like it would be the best option.The text was updated successfully, but these errors were encountered: