<div dir="ltr">I've reverted this change in r354849. It was causing <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29901">ASan failures</a> on sanitizer-x86_64-linux-fast like the following:<div><pre style="font-family:"Courier New",courier,monotype,monospace;font-size:medium"><span class="inbox-inbox-stdout">FAIL: LLVM :: Object/X86/nm-print-size.s (22871 of 29961)
******************** TEST 'LLVM :: Object/X86/nm-print-size.s' FAILED ********************
Script:
--
: 'RUN: at line 1'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llvm-mc /b/sanitizer-x86_64-linux-fast/build/llvm/test/Object/X86/nm-print-size.s -o /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/test/Object/X86/Output/nm-print-size.s.tmp -filetype=obj -triple=x86_64-pc-linux
: 'RUN: at line 2'; /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llvm-nm --print-size /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/test/Object/X86/Output/nm-print-size.s.tmp | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/FileCheck /b/sanitizer-x86_64-linux-fast/build/llvm/test/Object/X86/nm-print-size.s
--
Exit Code: 2
Command Output (stderr):
--
=================================================================
==61874==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x617000000323 at pc 0x000000fce265 bp 0x7ffedd5d10b0 sp 0x7ffedd5d10a8
READ of size 4 at 0x617000000323 thread T0
#0 0xfce264 in read<unsigned int, 1> /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Endian.h:68:3
#1 0xfce264 in read<unsigned int, llvm::support::little, 1> /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Endian.h:79
#2 0xfce264 in operator unsigned int /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Endian.h:215
#3 0xfce264 in llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*, llvm::StringRef) const /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELF.h:623
#4 0xfcd3d4 in llvm::object::ELFFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<(llvm::support::endianness)1, true> > const*) const /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELF.h:617:10
#5 0xfc30e8 in llvm::object::ELFObjectFile<llvm::object::ELFType<(llvm::support::endianness)1, true> >::getSectionName(llvm::object::DataRefImpl, llvm::StringRef&) const /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELFObjectFile.h:688:18
#6 0x5ed81f in getName /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ObjectFile.h:422:24
#7 0x5ed81f in getNMClassTagAndSectionName /b/sanitizer-x86_64-linux-fast/build/llvm/tools/llvm-nm/llvm-nm.cpp:1116
#8 0x5ed81f in dumpSymbolNamesFromObject(llvm::object::SymbolicFile&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /b/sanitizer-x86_64-linux-fast/build/llvm/tools/llvm-nm/llvm-nm.cpp:1244
#9 0x5e063c in dumpSymbolNamesFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) /b/sanitizer-x86_64-linux-fast/build/llvm/tools/llvm-nm/llvm-nm.cpp:2073:5
#10 0x5d3647 in for_each<std::__1::__wrap_iter<std::__1::basic_string<char> *>, void (*)(std::__1::basic_string<char> &)> /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/algorithm:858:9
#11 0x5d3647 in for_each<llvm::cl::list<std::__1::basic_string<char>, bool, llvm::cl::parser<std::string> > &, void (*)(std::__1::basic_string<char> &)> /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/STLExtras.h:1179
#12 0x5d3647 in main /b/sanitizer-x86_64-linux-fast/build/llvm/tools/llvm-nm/llvm-nm.cpp:2127
#13 0x7f4af51462e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
#14 0x4ca6a9 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan/bin/llvm-nm+0x4ca6a9)
0x617000000323 is located 2 bytes to the right of 673-byte region [0x617000000080,0x617000000321)
allocated by thread T0 here:
#0 0x5cbd00 in operator new(unsigned long, std::nothrow_t const&) /b/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:112
#1 0x1174b2d in llvm::WritableMemoryBuffer::getNewUninitMemBuffer(unsigned long, llvm::Twine const&) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/MemoryBuffer.cpp:283:34
#2 0x1175647 in llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > > getOpenFileImpl<llvm::MemoryBuffer>(int, llvm::Twine const&, unsigned long, unsigned long, long, bool, bool) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/MemoryBuffer.cpp:455:14
#3 0x1173fca in getFileAux<llvm::MemoryBuffer> /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/MemoryBuffer.cpp:251:14
#4 0x1173fca in getFile /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/MemoryBuffer.cpp:231
#5 0x1173fca in llvm::MemoryBuffer::getFileOrSTDIN(llvm::Twine const&, long, bool) /b/sanitizer-x86_64-linux-fast/build/llvm/lib/Support/MemoryBuffer.cpp:150
#6 0x5d456a in dumpSymbolNamesFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) /b/sanitizer-x86_64-linux-fast/build/llvm/tools/llvm-nm/llvm-nm.cpp:1775:7
#7 0x5d3647 in for_each<std::__1::__wrap_iter<std::__1::basic_string<char> *>, void (*)(std::__1::basic_string<char> &)> /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/algorithm:858:9
#8 0x5d3647 in for_each<llvm::cl::list<std::__1::basic_string<char>, bool, llvm::cl::parser<std::string> > &, void (*)(std::__1::basic_string<char> &)> /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/STLExtras.h:1179
#9 0x5d3647 in main /b/sanitizer-x86_64-linux-fast/build/llvm/tools/llvm-nm/llvm-nm.cpp:2127
#10 0x7f4af51462e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
SUMMARY: AddressSanitizer: heap-buffer-overflow /b/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Endian.h:68:3 in read<unsigned int, 1>
Shadow bytes around the buggy address:
0x0c2e7fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c2e7fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c2e7fff8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c2e7fff8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c2e7fff8050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c2e7fff8060: 00 00 00 00[01]fa fa fa fa fa fa fa fa fa fa fa
0x0c2e7fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c2e7fff8080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c2e7fff8090: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c2e7fff80a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c2e7fff80b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Shadow gap: cc
==61874==ABORTING
</span></pre><br class="inbox-inbox-Apple-interchange-newline"><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 25, 2019 at 4:18 PM Sunil Srivastava via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ssrivastava<br>
Date: Mon Feb 25 16:19:39 2019<br>
New Revision: 354833<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=354833&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=354833&view=rev</a><br>
Log:<br>
Improve "llvm-nm -f sysv" output for Elf files<br>
<br>
Specifically, compute and Print Type and Section columns.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D58263" rel="noreferrer" target="_blank">https://reviews.llvm.org/D58263</a><br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Object/ELFObjectFile.h<br>
llvm/trunk/include/llvm/Object/ObjectFile.h<br>
llvm/trunk/lib/Object/ELFObjectFile.cpp<br>
llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test<br>
llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test<br>
llvm/trunk/tools/llvm-nm/llvm-nm.cpp<br>
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)<br>
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Mon Feb 25 16:19:39 2019<br>
@@ -41,6 +41,8 @@<br>
namespace llvm {<br>
namespace object {<br>
<br>
+extern const llvm::EnumEntry<unsigned> ElfSymbolTypes[8];<br>
+<br>
class elf_symbol_iterator;<br>
<br>
class ELFObjectFileBase : public ObjectFile {<br>
@@ -148,6 +150,17 @@ public:<br>
uint8_t getELFType() const {<br>
return getObject()->getSymbolELFType(getRawDataRefImpl());<br>
}<br>
+<br>
+ void getELFTypeName(StringRef &TN) const {<br>
+ uint8_t et = getELFType();<br>
+ TN = "";<br>
+ for (auto &ee : ElfSymbolTypes) {<br>
+ if (ee.Value == et) {<br>
+ TN = ee.AltName;<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
};<br>
<br>
class elf_symbol_iterator : public symbol_iterator {<br>
@@ -244,6 +257,7 @@ protected:<br>
Expected<section_iterator> getSymbolSection(const Elf_Sym *Symb,<br>
const Elf_Shdr *SymTab) const;<br>
Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;<br>
+ int getSymbolSectionIndex(DataRefImpl Symb) const override;<br>
<br>
void moveSectionNext(DataRefImpl &Sec) const override;<br>
std::error_code getSectionName(DataRefImpl Sec,<br>
@@ -656,6 +670,13 @@ ELFObjectFile<ELFT>::getSymbolSection(Da<br>
}<br>
<br>
template <class ELFT><br>
+int<br>
+ELFObjectFile<ELFT>::getSymbolSectionIndex(DataRefImpl Symb) const {<br>
+ const Elf_Sym *Sym = getSymbol(Symb);<br>
+ return Sym->st_shndx;<br>
+}<br>
+<br>
+template <class ELFT><br>
void ELFObjectFile<ELFT>::moveSectionNext(DataRefImpl &Sec) const {<br>
const Elf_Shdr *ESec = getSection(Sec);<br>
Sec = toDRI(++ESec);<br>
<br>
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)<br>
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Mon Feb 25 16:19:39 2019<br>
@@ -174,6 +174,9 @@ public:<br>
/// end_sections() if it is undefined or is an absolute symbol.<br>
Expected<section_iterator> getSection() const;<br>
<br>
+ // Get the section index of the section of this symbol<br>
+ int getSectionIndex() const;<br>
+<br>
const ObjectFile *getObject() const;<br>
};<br>
<br>
@@ -228,6 +231,7 @@ protected:<br>
virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;<br>
virtual Expected<section_iterator><br>
getSymbolSection(DataRefImpl Symb) const = 0;<br>
+ virtual int getSymbolSectionIndex(DataRefImpl Symb) const { return -1; }<br>
<br>
// Same as above for SectionRef.<br>
friend class SectionRef;<br>
@@ -375,6 +379,10 @@ inline uint64_t SymbolRef::getCommonSize<br>
return getObject()->getCommonSymbolSize(getRawDataRefImpl());<br>
}<br>
<br>
+inline int SymbolRef::getSectionIndex() const {<br>
+ return getObject()->getSymbolSectionIndex(getRawDataRefImpl());<br>
+}<br>
+<br>
inline Expected<section_iterator> SymbolRef::getSection() const {<br>
return getObject()->getSymbolSection(getRawDataRefImpl());<br>
}<br>
<br>
Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)<br>
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Mon Feb 25 16:19:39 2019<br>
@@ -35,6 +35,16 @@<br>
using namespace llvm;<br>
using namespace object;<br>
<br>
+const EnumEntry<unsigned> llvm::object::ElfSymbolTypes[8] = {<br>
+ {"None", "NOTYPE", ELF::STT_NOTYPE},<br>
+ {"Object", "OBJECT", ELF::STT_OBJECT},<br>
+ {"Function", "FUNC", ELF::STT_FUNC},<br>
+ {"Section", "SECTION", ELF::STT_SECTION},<br>
+ {"File", "FILE", ELF::STT_FILE},<br>
+ {"Common", "COMMON", ELF::STT_COMMON},<br>
+ {"TLS", "TLS", ELF::STT_TLS},<br>
+ {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC}};<br>
+<br>
ELFObjectFileBase::ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source)<br>
: ObjectFile(Type, Source) {}<br>
<br>
<br>
Modified: llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test (original)<br>
+++ llvm/trunk/test/tools/llvm-nm/X86/sysv-i386.test Mon Feb 25 16:19:39 2019<br>
@@ -1,6 +1,6 @@<br>
RUN: llvm-nm -f sysv %p/Inputs/hello.obj.elf-i386 | FileCheck %s --strict-whitespace<br>
<br>
CHECK: Name Value Class Type Size Line Section<br>
-CHECK: .L.str |00000000| r | |0000000f| |<br>
-CHECK: main |00000000| T | |00000015| |<br>
-CHECK: puts | | U | | | |<br>
+CHECK: .L.str |00000000| r | OBJECT|0000000f| |.rodata.str1.1<br>
+CHECK: main |00000000| T | FUNC|00000015| |.text<br>
+CHECK: puts | | U | NOTYPE| | |*UND*<br>
<br>
Modified: llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test (original)<br>
+++ llvm/trunk/test/tools/llvm-nm/X86/sysv-x86_64.test Mon Feb 25 16:19:39 2019<br>
@@ -2,8 +2,8 @@ RUN: llvm-nm -f sysv %p/Inputs/hello.obj<br>
RUN: llvm-nm -f sysv %p/Inputs/hello.obj.macho-x86_64 2>&1 | FileCheck %s --check-prefix=MACHO --strict-whitespace<br>
<br>
ELF: Name Value Class Type Size Line Section<br>
-ELF: main |0000000000000000| T | |0000000000000015| |<br>
-ELF: puts | | U | | | |<br>
+ELF: main |0000000000000000| T | FUNC|0000000000000015| |.text<br>
+ELF: puts | | U | NOTYPE| | |*UND*<br>
<br>
MACHO: Name Value Class Type Size Line Section<br>
MACHO: EH_frame0 |0000000000000068| s | |0000000000000000| |<br>
<br>
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)<br>
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Feb 25 16:19:39 2019<br>
@@ -262,6 +262,8 @@ struct NMSymbol {<br>
uint64_t Size;<br>
char TypeChar;<br>
StringRef Name;<br>
+ StringRef SectionName;<br>
+ StringRef TypeName;<br>
BasicSymbolRef Sym;<br>
// The Sym field above points to the native symbol in the object file,<br>
// for Mach-O when we are creating symbols from the dyld info the above<br>
@@ -882,8 +884,13 @@ static void sortAndPrintSymbolList(Symbo<br>
std::string PaddedName(Name);<br>
while (PaddedName.length() < 20)<br>
PaddedName += " ";<br>
+ std::string TNPad = "";<br>
+ int TNL = I->TypeName.size();<br>
+ while ((TNPad.length() + TNL) < 18)<br>
+ TNPad += " ";<br>
outs() << PaddedName << "|" << SymbolAddrStr << "| " << I->TypeChar<br>
- << " | |" << SymbolSizeStr << "| |\n";<br>
+ << " |" << TNPad << I->TypeName << "|" << SymbolSizeStr<br>
+ << "| |" << I->SectionName << "\n";<br>
}<br>
}<br>
<br>
@@ -1078,7 +1085,37 @@ static bool isObject(SymbolicFile &Obj,<br>
: elf_symbol_iterator(I)->getELFType() == ELF::STT_OBJECT;<br>
}<br>
<br>
-static char getNMTypeChar(SymbolicFile &Obj, basic_symbol_iterator I) {<br>
+// For ELF object files, Set TypeName to the symbol typename, to be printed<br>
+// in the 'Type' column of the SYSV format output.<br>
+static void getNMTypeName(SymbolicFile &Obj, basic_symbol_iterator I,<br>
+ StringRef &TypeName) {<br>
+ if (isa<ELFObjectFileBase>(&Obj)) {<br>
+ elf_symbol_iterator SymI(I);<br>
+ SymI->getELFTypeName(TypeName);<br>
+ }<br>
+}<br>
+<br>
+// Return Posix nm class type tag (single letter), but also set SecName and<br>
+// section and name, to be used in format=sysv output.<br>
+static char getNMClassTagAndSectionName(SymbolicFile &Obj,<br>
+ basic_symbol_iterator I,<br>
+ StringRef &SecName) {<br>
+ if (isa<ELFObjectFileBase>(&Obj)) {<br>
+ elf_symbol_iterator SymI(I);<br>
+<br>
+ Expected<elf_section_iterator> SecIOrErr = SymI->getSection();<br>
+ if (!SecIOrErr) {<br>
+ consumeError(SecIOrErr.takeError());<br>
+ return '?';<br>
+ }<br>
+ int SI = SymI->getSectionIndex();<br>
+ if (SI == 0) {<br>
+ SecName = "*UND*";<br>
+ } else {<br>
+ elf_section_iterator secT = *SecIOrErr;<br>
+ secT->getName(SecName);<br>
+ }<br>
+ }<br>
uint32_t Symflags = I->getFlags();<br>
if ((Symflags & object::SymbolRef::SF_Weak) && !isa<MachOObjectFile>(Obj)) {<br>
char Ret = isObject(Obj, I) ? 'v' : 'w';<br>
@@ -1088,8 +1125,10 @@ static char getNMTypeChar(SymbolicFile &<br>
if (Symflags & object::SymbolRef::SF_Undefined)<br>
return 'U';<br>
<br>
- if (Symflags & object::SymbolRef::SF_Common)<br>
+ if (Symflags & object::SymbolRef::SF_Common) {<br>
+ SecName = "*COM*";<br>
return 'C';<br>
+ }<br>
<br>
char Ret = '?';<br>
if (Symflags & object::SymbolRef::SF_Absolute)<br>
@@ -1201,7 +1240,8 @@ dumpSymbolNamesFromObject(SymbolicFile &<br>
}<br>
S.Address = *AddressOrErr;<br>
}<br>
- S.TypeChar = getNMTypeChar(Obj, Sym);<br>
+ getNMTypeName(Obj, Sym, S.TypeName);<br>
+ S.TypeChar = getNMClassTagAndSectionName(Obj, Sym, S.SectionName);<br>
std::error_code EC = Sym.printName(OS);<br>
if (EC && MachO)<br>
OS << "bad string index";<br>
<br>
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=354833&r1=354832&r2=354833&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=354833&r1=354832&r2=354833&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)<br>
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Mon Feb 25 16:19:39 2019<br>
@@ -1104,16 +1104,6 @@ static const EnumEntry<unsigned> ElfSymb<br>
{"HIDDEN", "HIDDEN", ELF::STV_HIDDEN},<br>
{"PROTECTED", "PROTECTED", ELF::STV_PROTECTED}};<br>
<br>
-static const EnumEntry<unsigned> ElfSymbolTypes[] = {<br>
- {"None", "NOTYPE", ELF::STT_NOTYPE},<br>
- {"Object", "OBJECT", ELF::STT_OBJECT},<br>
- {"Function", "FUNC", ELF::STT_FUNC},<br>
- {"Section", "SECTION", ELF::STT_SECTION},<br>
- {"File", "FILE", ELF::STT_FILE},<br>
- {"Common", "COMMON", ELF::STT_COMMON},<br>
- {"TLS", "TLS", ELF::STT_TLS},<br>
- {"GNU_IFunc", "IFUNC", ELF::STT_GNU_IFUNC}};<br>
-<br>
static const EnumEntry<unsigned> AMDGPUSymbolTypes[] = {<br>
{ "AMDGPU_HSA_KERNEL", ELF::STT_AMDGPU_HSA_KERNEL }<br>
};<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div></div>