[MC] Change ELFOSABI_NONE to ELFOSABI_GNU for STB_GNU_UNIQUE

Similar to 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.

Reviewed By: jrtc27

Differential Revision: https://reviews.llvm.org/D107861
This commit is contained in:
Fangrui Song
2021-08-27 08:53:55 -07:00
parent 77b6a4bde4
commit 83dfa0d098
3 changed files with 14 additions and 7 deletions

View File

@@ -224,6 +224,7 @@ bool MCELFStreamer::emitSymbolAttribute(MCSymbol *S, MCSymbolAttr Attribute) {
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:

View File

@@ -29,10 +29,3 @@
.type string_type, "function"
// CHECK: .type string_type,@function
.type special gnu_unique_object
// CHECK: .type special,@gnu_unique_object
.type comma_special, gnu_unique_object
// CHECK: .type comma_special,@gnu_unique_object

View File

@@ -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,@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: