[PATCH] D107861: [MC] Change ELFOSABI_NONE to ELFOSABI_GNU for STB_GNU_UNIQUE

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 10 12:36:46 PDT 2021


MaskRay created this revision.
MaskRay added reviewers: joerg, ro.
Herald added subscribers: hiraditya, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Similar to D97976 <https://reviews.llvm.org/D97976>.
On Linux, most GCC installations are configured with
`--enable-gnu-unique-object` and such GCC emits `@gnu_unique_object` assembly.

The feature is highly controversial and disliked by many folks.
(On glibc DF_1_NODELETE is implicitly enabled and makes dlclose a no-op).

In llvm-project STB_GNU_UNIQUE is assembly only. Clang does not use STB_GNU_UNIQUE.

Use ELFOSABI_GNU to match GNU as behavior and avoid collision with other
OSABI binding values.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107861

Files:
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/test/MC/ELF/gnu-type.s
  llvm/test/MC/ELF/gnu-unique.s


Index: llvm/test/MC/ELF/gnu-unique.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/gnu-unique.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s | llvm-readelf -h -s - | FileCheck %s --check-prefix=OBJ
+
+# ASM: .type unique, at gnu_unique_object
+
+# OBJ: OS/ABI: UNIX - GNU
+# OBJ: Type   Bind   Vis     Ndx Name
+# OBJ: OBJECT UNIQUE DEFAULT [[#]] unique
+
+.data
+.globl unique
+.type unique, @gnu_unique_object
+unique:
Index: llvm/test/MC/ELF/gnu-type.s
===================================================================
--- llvm/test/MC/ELF/gnu-type.s
+++ llvm/test/MC/ELF/gnu-type.s
@@ -29,10 +29,3 @@
 
 	.type string_type, "function"
 // CHECK: .type string_type, at function
-
-	.type special gnu_unique_object
-// CHECK: .type special, at gnu_unique_object
-
-	.type comma_special, gnu_unique_object
-// CHECK: .type comma_special, at gnu_unique_object
-
Index: llvm/lib/MC/MCELFStreamer.cpp
===================================================================
--- llvm/lib/MC/MCELFStreamer.cpp
+++ llvm/lib/MC/MCELFStreamer.cpp
@@ -224,6 +224,7 @@
   case MCSA_ELF_TypeGnuUniqueObject:
     Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
     Symbol->setBinding(ELF::STB_GNU_UNIQUE);
+    getAssembler().getWriter().markGnuAbi();
     break;
 
   case MCSA_Global:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107861.365587.patch
Type: text/x-patch
Size: 1433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210810/3c82aaa9/attachment.bin>


More information about the llvm-commits mailing list