cmd/link: go version fails on internally linked PIE #37173
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?tip (1c241d2)
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
Related to issue #31861,
go version
still fails on internally linked PIE.It seems the problem is that for building PIE, we generate dynamic relocations for address references. This includes the address references for the build info, specifically in symbols
.go.buildinfo
,runtime.buildVersion
, andruntime.modinfo
. When we generate dynamic relocations, we just leave the bytes in the binary unset (as zero), as the dynamic linker will overwrite it at run time anyway. Butgo version
examines the file, so it won't be able to follow the address references.I see the following ways for fixing this:
only apply the static relocations to specific symbols (namely,.go.buildinfo
,runtime.buildVersion
, andruntime.modinfo
). We need to keep the list of special symbols in sync with the runtime and the go command, though.go version
about resolving dynamic relocations. Seems overkill.@ianlancetaylor @rsc @bcmills for thoughts. I can do the implementation once we decide which way to go.
The text was updated successfully, but these errors were encountered: