From 2236f9348ddccbc1fb71b8da6e84bc64aad24248 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 24 Mar 2014 05:00:34 +0000 Subject: Teach llvm-readobj to print human friendly description of reserved sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204584 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-readobj/ELFDumper.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index e4532a5476..94b76d00e7 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -625,8 +625,28 @@ void ELFDumper::printDynamicSymbols() { template void ELFDumper::printSymbol(typename ELFO::Elf_Sym_Iter Symbol) { StringRef SymbolName = errorOrDefault(Obj->getSymbolName(Symbol)); - const Elf_Shdr *Sec = Obj->getSection(&*Symbol); - StringRef SectionName = Sec ? errorOrDefault(Obj->getSectionName(Sec)) : ""; + + unsigned SectionIndex = Obj->getSymbolTableIndex(&*Symbol); + StringRef SectionName; + if (SectionIndex == SHN_UNDEF) { + SectionName = "Undefined"; + } else if (SectionIndex >= SHN_LOPROC && SectionIndex <= SHN_HIPROC) { + SectionName = "Processor Specific"; + } else if (SectionIndex >= SHN_LOOS && SectionIndex <= SHN_HIOS) { + SectionName = "Operating System Specific"; + } else if (SectionIndex > SHN_HIOS && SectionIndex < SHN_ABS) { + SectionName = "Reserved"; + } else if (SectionIndex == SHN_ABS) { + SectionName = "Absolute"; + } else if (SectionIndex == SHN_COMMON) { + SectionName = "Common"; + } else { + assert(SectionIndex != SHN_XINDEX && + "getSymbolTableIndex should handle this"); + const Elf_Shdr *Sec = Obj->getSection(SectionIndex); + SectionName = errorOrDefault(Obj->getSectionName(Sec)); + } + std::string FullSymbolName(SymbolName); if (Symbol.isDynamic()) { bool IsDefault; -- cgit v1.2.3