[llvm] r354849 - Revert "Improve "llvm-nm -f sysv" output for Elf files"
Vlad Tsyrklevich via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 25 23:04:56 PST 2019
Author: vlad.tsyrklevich
Date: Mon Feb 25 23:04:56 2019
New Revision: 354849
URL: http://llvm.org/viewvc/llvm-project?rev=354849&view=rev
Log:
Revert "Improve "llvm-nm -f sysv" output for Elf files"
This reverts commit r354833, it was causing ASan test failures on
sanitizer-x86_64-linux-fast.
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/Object/ELFObjectFile.cpp
llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test
llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Mon Feb 25 23:04:56 2019
@@ -41,8 +41,6 @@
namespace llvm {
namespace object {
-extern const llvm::EnumEntry<unsigned> ElfSymbolTypes[8];
-
class elf_symbol_iterator;
class ELFObjectFileBase : public ObjectFile {
@@ -150,17 +148,6 @@ public:
uint8_t getELFType() const {
return getObject()->getSymbolELFType(getRawDataRefImpl());
}
-
- void getELFTypeName(StringRef &TN) const {
- uint8_t et = getELFType();
- TN = "";
- for (auto &ee : ElfSymbolTypes) {
- if (ee.Value == et) {
- TN = ee.AltName;
- break;
- }
- }
- }
};
class elf_symbol_iterator : public symbol_iterator {
@@ -257,7 +244,6 @@ protected:
Expected<section_iterator> getSymbolSection(const Elf_Sym *Symb,
const Elf_Shdr *SymTab) const;
Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
- int getSymbolSectionIndex(DataRefImpl Symb) const override;
void moveSectionNext(DataRefImpl &Sec) const override;
std::error_code getSectionName(DataRefImpl Sec,
@@ -670,13 +656,6 @@ ELFObjectFile<ELFT>::getSymbolSection(Da
}
template <class ELFT>
-int
-ELFObjectFile<ELFT>::getSymbolSectionIndex(DataRefImpl Symb) const {
- const Elf_Sym *Sym = getSymbol(Symb);
- return Sym->st_shndx;
-}
-
-template <class ELFT>
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {
const Elf_Shdr *ESec = getSection(Sec);
Sec = toDRI(++ESec);
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Feb 25 23:04:56 2019
@@ -174,9 +174,6 @@ public:
/// end_sections() if it is undefined or is an absolute symbol.
Expected<section_iterator> getSection() const;
- // Get the section index of the section of this symbol
- int getSectionIndex() const;
-
const ObjectFile *getObject() const;
};
@@ -231,7 +228,6 @@ protected:
virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
virtual Expected<section_iterator>
getSymbolSection(DataRefImpl Symb) const = 0;
- virtual int getSymbolSectionIndex(DataRefImpl Symb) const { return -1; }
// Same as above for SectionRef.
friend class SectionRef;
@@ -379,10 +375,6 @@ inline uint64_t SymbolRef::getCommonSize
return getObject()->getCommonSymbolSize(getRawDataRefImpl());
}
-inline int SymbolRef::getSectionIndex() const {
- return getObject()->getSymbolSectionIndex(getRawDataRefImpl());
-}
-
inline Expected<section_iterator> SymbolRef::getSection() const {
return getObject()->getSymbolSection(getRawDataRefImpl());
}
Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Mon Feb 25 23:04:56 2019
@@ -35,16 +35,6 @@
using namespace llvm;
using namespace object;
-const EnumEntry<unsigned> llvm::object::ElfSymbolTypes[8] = {
- {"None", "NOTYPE", ELF::STT_NOTYPE},
- {"Object", "OBJECT", ELF::STT_OBJECT},
- {"Function", "FUNC", ELF::STT_FUNC},
- {"Section", "SECTION", ELF::STT_SECTION},
- {"File", "FILE", ELF::STT_FILE},
- {"Common", "COMMON", ELF::STT_COMMON},
- {"TLS", "TLS", ELF::STT_TLS},
- {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC}};
-
ELFObjectFileBase::ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source)
: ObjectFile(Type, Source) {}
Modified: llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test (original)
+++ llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test Mon Feb 25 23:04:56 2019
@@ -1,6 +1,6 @@
RUN: llvm-nm -f sysv %p/Inputs/hello.obj.elf-i386 | FileCheck %s --strict-whitespace
CHECK: Name Value Class Type Size Line Section
-CHECK: .L.str |00000000| r | OBJECT|0000000f| |.rodata.str1.1
-CHECK: main |00000000| T | FUNC|00000015| |.text
-CHECK: puts | | U | NOTYPE| | |*UND*
+CHECK: .L.str |00000000| r | |0000000f| |
+CHECK: main |00000000| T | |00000015| |
+CHECK: puts | | U | | | |
Modified: llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test (original)
+++ llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test Mon Feb 25 23:04:56 2019
@@ -2,8 +2,8 @@ RUN: llvm-nm -f sysv %p/Inputs/hello.obj
RUN: llvm-nm -f sysv %p/Inputs/hello.obj.macho-x86_64 2>&1 | FileCheck %s --check-prefix=MACHO --strict-whitespace
ELF: Name Value Class Type Size Line Section
-ELF: main |0000000000000000| T | FUNC|0000000000000015| |.text
-ELF: puts | | U | NOTYPE| | |*UND*
+ELF: main |0000000000000000| T | |0000000000000015| |
+ELF: puts | | U | | | |
MACHO: Name Value Class Type Size Line Section
MACHO: EH_frame0 |0000000000000068| s | |0000000000000000| |
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Feb 25 23:04:56 2019
@@ -262,8 +262,6 @@ struct NMSymbol {
uint64_t Size;
char TypeChar;
StringRef Name;
- StringRef SectionName;
- StringRef TypeName;
BasicSymbolRef Sym;
// The Sym field above points to the native symbol in the object file,
// for Mach-O when we are creating symbols from the dyld info the above
@@ -884,13 +882,8 @@ static void sortAndPrintSymbolList(Symbo
std::string PaddedName(Name);
while (PaddedName.length() < 20)
PaddedName += " ";
- std::string TNPad = "";
- int TNL = I->TypeName.size();
- while ((TNPad.length() + TNL) < 18)
- TNPad += " ";
outs() << PaddedName << "|" << SymbolAddrStr << "| " << I->TypeChar
- << " |" << TNPad << I->TypeName << "|" << SymbolSizeStr
- << "| |" << I->SectionName << "\n";
+ << " | |" << SymbolSizeStr << "| |\n";
}
}
@@ -1085,37 +1078,7 @@ static bool isObject(SymbolicFile &Obj,
: elf_symbol_iterator(I)->getELFType() == ELF::STT_OBJECT;
}
-// For ELF object files, Set TypeName to the symbol typename, to be printed
-// in the 'Type' column of the SYSV format output.
-static void getNMTypeName(SymbolicFile &Obj, basic_symbol_iterator I,
- StringRef &TypeName) {
- if (isa<ELFObjectFileBase>(&Obj)) {
- elf_symbol_iterator SymI(I);
- SymI->getELFTypeName(TypeName);
- }
-}
-
-// Return Posix nm class type tag (single letter), but also set SecName and
-// section and name, to be used in format=sysv output.
-static char getNMClassTagAndSectionName(SymbolicFile &Obj,
- basic_symbol_iterator I,
- StringRef &SecName) {
- if (isa<ELFObjectFileBase>(&Obj)) {
- elf_symbol_iterator SymI(I);
-
- Expected<elf_section_iterator> SecIOrErr = SymI->getSection();
- if (!SecIOrErr) {
- consumeError(SecIOrErr.takeError());
- return '?';
- }
- int SI = SymI->getSectionIndex();
- if (SI == 0) {
- SecName = "*UND*";
- } else {
- elf_section_iterator secT = *SecIOrErr;
- secT->getName(SecName);
- }
- }
+static char getNMTypeChar(SymbolicFile &Obj, basic_symbol_iterator I) {
uint32_t Symflags = I->getFlags();
if ((Symflags & object::SymbolRef::SF_Weak) && !isa<MachOObjectFile>(Obj)) {
char Ret = isObject(Obj, I) ? 'v' : 'w';
@@ -1125,10 +1088,8 @@ static char getNMClassTagAndSectionName(
if (Symflags & object::SymbolRef::SF_Undefined)
return 'U';
- if (Symflags & object::SymbolRef::SF_Common) {
- SecName = "*COM*";
+ if (Symflags & object::SymbolRef::SF_Common)
return 'C';
- }
char Ret = '?';
if (Symflags & object::SymbolRef::SF_Absolute)
@@ -1240,8 +1201,7 @@ dumpSymbolNamesFromObject(SymbolicFile &
}
S.Address = *AddressOrErr;
}
- getNMTypeName(Obj, Sym, S.TypeName);
- S.TypeChar = getNMClassTagAndSectionName(Obj, Sym, S.SectionName);
+ S.TypeChar = getNMTypeChar(Obj, Sym);
std::error_code EC = Sym.printName(OS);
if (EC && MachO)
OS << "bad string index";
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=354849&r1=354848&r2=354849&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Mon Feb 25 23:04:56 2019
@@ -1104,6 +1104,16 @@ static const EnumEntry<unsigned> ElfSymb
{"HIDDEN", "HIDDEN", ELF::STV_HIDDEN},
{"PROTECTED", "PROTECTED", ELF::STV_PROTECTED}};
+static const EnumEntry<unsigned> ElfSymbolTypes[] = {
+ {"None", "NOTYPE", ELF::STT_NOTYPE},
+ {"Object", "OBJECT", ELF::STT_OBJECT},
+ {"Function", "FUNC", ELF::STT_FUNC},
+ {"Section", "SECTION", ELF::STT_SECTION},
+ {"File", "FILE", ELF::STT_FILE},
+ {"Common", "COMMON", ELF::STT_COMMON},
+ {"TLS", "TLS", ELF::STT_TLS},
+ {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC}};
+
static const EnumEntry<unsigned> AMDGPUSymbolTypes[] = {
{ "AMDGPU_HSA_KERNEL", ELF::STT_AMDGPU_HSA_KERNEL }
};
More information about the llvm-commits
mailing list