[all-commits] [llvm/llvm-project] ed399d: [ELF] Make SHF_GNU_RETAIN sections GC roots
Fangrui Song via All-commits
all-commits at lists.llvm.org
Thu Feb 4 09:23:23 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ed399d508ff6e0df657e251afe936fac713ff417
https://github.com/llvm/llvm-project/commit/ed399d508ff6e0df657e251afe936fac713ff417
Author: Fangrui Song <i at maskray.me>
Date: 2021-02-04 (Thu, 04 Feb 2021)
Changed paths:
M lld/ELF/MarkLive.cpp
A lld/test/ELF/gc-sections-retain.s
Log Message:
-----------
[ELF] Make SHF_GNU_RETAIN sections GC roots
binutils 2.36 introduced the new section flag SHF_GNU_RETAIN (for ELFOSABI_GNU &
ELFOSABI_FREEBSD) to mark a sections as a GC root. Several LLVM side toolchain
folks (including me) were involved in the design process of SHF_GNU_RETAIN and
were happy with this proposal.
Currently GNU ld only respects SHF_GNU_RETAIN semantics for ELFOSABI_GNU &
ELFOSABI_FREEBSD object files
(https://sourceware.org/bugzilla/show_bug.cgi?id=27282). GNU ld sets EI_OSABI
to ELFOSABI_GNU for relocatable output
(https://sourceware.org/bugzilla/show_bug.cgi?id=27091). In practice the single
value EI_OSABI is neither a good indicator for object file compatibility, nor a
useful mechanism marking used ELF extensions.
For input, we respect SHF_GNU_RETAIN semantics even for ELFOSABI_NONE object
files. This is compatible with how LLD and GNU ld handle (mildly useful) STT_GNU_IFUNC
/ (emitted by GCC, considered misfeature by some folks) STB_GNU_UNIQUE input.
(As of LLVM 12.0.0, the integrated assembler does not set ELFOSABI_GNU for
STT_GNU_IFUNC/STB_GNU_UNIQUE).
Arguably STT_GNU_IFUNC/STB_GNU_UNIQUE probably need indicators in object files
but SHF_GNU_RETAIN is more likely accepted by more OSABI platforms.
For output, we take a step further than GNU ld: we don't promote ELFOSABI_NONE
to ELFOSABI_GNU for all output.
Differential Revision: https://reviews.llvm.org/D95749
More information about the All-commits
mailing list