summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-readobj/ELFDumper.cpp24
1 files changed, 22 insertions, 2 deletions
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<ELFT>::printDynamicSymbols() {
template <class ELFT>
void ELFDumper<ELFT>::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;