[PATCH] D97448: ELF: Create unique SHF_GNU_RETAIN sections for llvm.used global objects
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 23:41:25 PST 2021
MaskRay created this revision.
MaskRay added reviewers: compnerd, phosek, rnk.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, krytarowski, arichardson, nemanjai, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If a global object is listed in `@llvm.used`, place it in a unique section with
the `SHF_GNU_RETAIN` flag. The section is a GC root under `ld --gc-sections`
with LLD>=13 or GNU ld>=2.36.
For front ends which do not expect to see multiple sections of the same name,
consider emitting `@llvm.compiler.used` instead of `@llvm.used`.
We don't restrict the feature to ELFOSABI_GNU and ELFOSABI_FREEBSD for now.
See the rationale in D95749 <https://reviews.llvm.org/D95749>.
The integrated assembler has supported SHF_GNU_RETAIN since D95730 <https://reviews.llvm.org/D95730>.
GNU as>=2.36 supports section flag 'R'.
We don't need to worry about GNU ld support because older GNU ld just ignores
the unknown SHF_GNU_RETAIN.
With this change, `__attribute__((retain))` functions/variables emitted
by clang will get the SHF_GNU_RETAIN flag.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97448
Files:
llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp
llvm/test/CodeGen/PowerPC/func-addr-consts.ll
llvm/test/CodeGen/PowerPC/no-dead-strip.ll
llvm/test/CodeGen/X86/elf-retain.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97448.326301.patch
Type: text/x-patch
Size: 8742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210225/067bed16/attachment.bin>
More information about the llvm-commits
mailing list