cmd/link: support relocations typical with -mcmodel=medium with internal linking #67475
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
TLDR: it would useful if the Go linker could be changed to add support for relocations typically emitted by C compilers for code built with -mcmodel=medium.
More detail:
Consider this program (using txtar format):
This code currently will not build due to "-mcmodel" etc not being on the allowlist for CGO cflags, but if you hack the go command to allow these options, then build:
Note the "unknown relocation type 26". This is R_X86_64_GOTPC32; this reloc and R_X86_64_GOTOFF64 are frequently generated when building with the medium code model.
It would be useful to ungrade the linker to handle these relocations; this is not a critical problem by any means since we can always fall back on external linking, but given the increased prevalence of "-mcmodel=medium" out in the wild for building very large programs, it might well be a good thing for us to add support for this.
NB: patch required to get to this to build with go command is below.
Related google-internal bug: b/341263385.
For some background on just exactly what
-mcmodel=medium
implies, see Eli's blog post.The text was updated successfully, but these errors were encountered: