[llvm-objdump] --syms: print 'u' for STB_GNU_UNIQUE

GCC when configured with --enable-gnu-unique (default on glibc>=2.11)
emits STB_GNU_UNIQUE for certain objects which are otherwise emitted as
STT_OBJECT, such as an inline function's static local variable or its
guard variable, and a static data member of a template.

Clang does not implement -fgnu-unique.

Implementing it as a binding is strange and the feature itself is
considered by some as a misfeature.

Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D75797
This commit is contained in:
Fangrui Song 2020-03-06 21:00:15 -08:00
parent e799405e53
commit 7b74b0d4e5
2 changed files with 3 additions and 1 deletions

View File

@ -25,7 +25,7 @@
# CHECK-NEXT:0000000000000000 *UND* 0000000000000000 reserve
# CHECK-NEXT:0000000000000000 g *ABS* 0000000000000000 abs
# CHECK-NEXT:0000000000000000 *COM* 0000000000000000 common2
# CHECK-NEXT:0000000000000000 g O .data 0000000000000000 gnu_unique
# CHECK-NEXT:0000000000000000 u O .data 0000000000000000 gnu_unique
# CHECK-NEXT:0000000000000000 g .data 0000000000000000 invalid_binding
# CHECK-NEXT:0000000000000000 g .data 0000000000000000 STB_HIOS
# CHECK-NEXT:0000000000000000 g .data 0000000000000000 STB_LOPROC

View File

@ -1903,6 +1903,8 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
if (auto *ELF = dyn_cast<ELFObjectFileBase>(O)) {
if (ELFSymbolRef(*I).getELFType() == ELF::STT_GNU_IFUNC)
IFunc = 'i';
if (ELFSymbolRef(*I).getBinding() == ELF::STB_GNU_UNIQUE)
GlobLoc = 'u';
}
char Debug = (Type == SymbolRef::ST_Debug || Type == SymbolRef::ST_File)
? 'd' : ' ';