[PATCH] D25927: [cfi] Implement cfi-icall using inline assembly.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 15:30:53 PDT 2016


eugenis created this revision.
eugenis added reviewers: pcc, echristo.
eugenis added a subscriber: llvm-commits.
eugenis set the repository for this revision to rL LLVM.
Herald added subscribers: mehdi_amini, aemerson.

The current implementation is emitting a global constant that happens
to evaluate to the same bytes + relocation as a jump instruction on
X86. This does not work for PIE executables and shared libraries
though, because we end up with a wrong relocation type. And it has no
chance of working on ARM/AArch64 which use different relocation types
for jump instructions (R_ARM_JUMP24) that is never generated for
data.

This change replaces the constant with module-level inline assembly
followed by a hidden declaration of the jump table. Works fine for
ARM/AArch64, but has some drawbacks.

- Extra symbols are added to the static symbol table, which inflate

the size of the unstripped binary a little. Stripped binaries are not
affected. This happens because jump table declarations must be
external (because their body is in the inline asm).

- Original functions that were anonymous are now named

<original name>.cfi, and it affects symbolization sometimes. This is
necessary because the only user of these functions is the (inline
asm) jump table, so they had to be added to @llvm.used, which does
not allow unnamed functions.


Repository:
  rL LLVM

https://reviews.llvm.org/D25927

Files:
  lib/Transforms/IPO/LowerTypeTests.cpp
  test/Transforms/LowerTypeTests/function-disjoint.ll
  test/Transforms/LowerTypeTests/function-ext.ll
  test/Transforms/LowerTypeTests/function.ll
  test/Transforms/LowerTypeTests/section.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25927.75654.patch
Type: text/x-patch
Size: 21555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161024/25f7e08e/attachment.bin>


More information about the llvm-commits mailing list