[all-commits] [llvm/llvm-project] b5ed37: [BOLT] Skip _init; avoiding GOT breakage for stati...

Peter Waller via All-commits all-commits at lists.llvm.org
Thu Nov 28 06:59:28 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b5ed375f9d63c1f37bb490f32898e6dc711c8a15
      https://github.com/llvm/llvm-project/commit/b5ed375f9d63c1f37bb490f32898e6dc711c8a15
  Author: Peter Waller <peter.waller at arm.com>
  Date:   2024-11-28 (Thu, 28 Nov 2024)

  Changed paths:
    M bolt/lib/Rewrite/RewriteInstance.cpp
    A bolt/test/AArch64/check-init-not-moved.s

  Log Message:
  -----------
  [BOLT] Skip _init; avoiding GOT breakage for static binaries (#117751)

_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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list