[PATCH] D95730: [MC] Support SHF_GNU_RETAIN as section flag 'R'
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 22:52:24 PST 2021
MaskRay created this revision.
MaskRay added reviewers: arichardson, grimar, jhenderson, jrtc27.
Herald added subscribers: hiraditya, krytarowski.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
GNU as sets EI_OSABI to ELFOSABI_GNU when SHF_GNU_RETAIN is used, even on
FreeBSD.
GNU ld respects SHF_GNU_RETAIN only for ELFOSABI_FREEBSD/ELFOSABI_GNU.
https://sourceware.org/bugzilla/show_bug.cgi?id=27282
MC doesn't set ELFOSABI_GNU for SHF_GNU_RETAIN/STB_GNU_UNIQUE/STT_GNU_IFUNC.
MC assembled object files do not have special semantics in GNU ld.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95730
Files:
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/lib/MC/MCSectionELF.cpp
llvm/test/MC/ELF/section-gnu.s
Index: llvm/test/MC/ELF/section-gnu.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/section-gnu.s
@@ -0,0 +1,16 @@
+# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s | llvm-readobj -hS - | FileCheck %s --check-prefix=OBJ
+
+# ASM: .section retain,"aR", at progbits
+
+## Note: GNU as sets OSABI to GNU.
+# OBJ: OS/ABI: SystemV (0x0)
+
+# OBJ: Name: retain
+# OBJ-NEXT: Type: SHT_PROGBITS
+# OBJ-NEXT: Flags [
+# OBJ-NEXT: SHF_ALLOC
+# OBJ-NEXT: SHF_GNU_RETAIN
+# OBJ-NEXT: ]
+
+.section retain,"aR", at progbits
Index: llvm/lib/MC/MCSectionELF.cpp
===================================================================
--- llvm/lib/MC/MCSectionELF.cpp
+++ llvm/lib/MC/MCSectionELF.cpp
@@ -102,6 +102,8 @@
OS << 'T';
if (Flags & ELF::SHF_LINK_ORDER)
OS << 'o';
+ if (Flags & ELF::SHF_GNU_RETAIN)
+ OS << 'R';
// If there are target-specific flags, print them.
Triple::ArchType Arch = T.getArch();
Index: llvm/lib/MC/MCParser/ELFAsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -326,6 +326,9 @@
case 'G':
flags |= ELF::SHF_GROUP;
break;
+ case 'R':
+ flags |= ELF::SHF_GNU_RETAIN;
+ break;
case '?':
*UseLastGroup = true;
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95730.320282.patch
Type: text/x-patch
Size: 1450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210130/1f502fda/attachment.bin>
More information about the llvm-commits
mailing list