aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-02-26 11:59:53 -0800
committerFangrui Song <i@maskray.me>2021-02-26 16:37:50 -0800
commit8afdacba9dcd36fc838eb86fca86f7f903040030 (patch)
treebba9167727ae7c03a880fa94619cbebdaf5339db /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent233ba2709bde54ea820cdaba0405d46b2c197e01 (diff)
downloadllvm-8afdacba9dcd36fc838eb86fca86f7f903040030.zip
llvm-8afdacba9dcd36fc838eb86fca86f7f903040030.tar.gz
llvm-8afdacba9dcd36fc838eb86fca86f7f903040030.tar.bz2
Add GNU attribute 'retain'
For ELF targets, GCC 11 will set SHF_GNU_RETAIN on the section of a `__attribute__((retain))` function/variable to prevent linker garbage collection. (See AttrDocs.td for the linker support). This patch adds `retain` functions/variables to the `llvm.used` list, which has the desired linker GC semantics. Note: `retain` does not imply `used`, so an unused function/variable can be dropped by Sema. Before 'retain' was introduced, previous ELF solutions require inline asm or linker tricks, e.g. `asm volatile(".reloc 0, R_X86_64_NONE, target");` (architecture dependent) or define a non-local symbol in the section and use `ld -u`. There was no elegant source-level solution. With D97448, `__attribute__((retain))` will set `SHF_GNU_RETAIN` on ELF targets. Differential Revision: https://reviews.llvm.org/D97447
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
0 files changed, 0 insertions, 0 deletions