mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 03:06:06 +00:00

_init is used during startup of binaires. Unfortunately, its address can be shared (at least on AArch64 glibc static binaries) with a data reference that lives in the GOT. The GOT rewriting is currently unable to distinguish between data addresses and function addresses. This leads to the data address being incorrectly rewritten, causing a crash on startup of the binary: Unexpected reloc type in static binary. To avoid this, don't consider _init for being moved, by skipping it. ~We could add further conditions to narrow the skipped case for known crashes, but as a straw man I thought it'd be best to keep the condition as simple as possible and see if there any objections to this.~ (Edit: this broke the test bolt/test/runtime/X86/retpoline-synthetic.test, because _init was skipped from the retpoline pass and it has an indirect call in it, so I include a check for static binaries now, which avoids the test failure, but perhaps this could/should be narrowed further?) For now, skip _init for static binaries on any architecture; we could add further conditions to narrow the skipped case for known crashes, but as a straw man I thought it'd be best to keep the condition as simple as possible and see if there any objections to this. Updates #100096.