diff --git a/include/llvm/Object/ELFTypes.h b/include/llvm/Object/ELFTypes.h index 15c792f682b..4b8ed883482 100644 --- a/include/llvm/Object/ELFTypes.h +++ b/include/llvm/Object/ELFTypes.h @@ -184,10 +184,7 @@ struct Elf_Sym_Impl : Elf_Sym_Base { bool isCommon() const { return getType() == ELF::STT_COMMON || st_shndx == ELF::SHN_COMMON; } - bool isDefined() const { - return !isUndefined() && - !(st_shndx >= ELF::SHN_LORESERVE && st_shndx < ELF::SHN_ABS); - } + bool isDefined() const { return !isUndefined(); } bool isProcessorSpecific() const { return st_shndx >= ELF::SHN_LOPROC && st_shndx <= ELF::SHN_HIPROC; } @@ -195,7 +192,7 @@ struct Elf_Sym_Impl : Elf_Sym_Base { return st_shndx >= ELF::SHN_LOOS && st_shndx <= ELF::SHN_HIOS; } bool isReserved() const { - return st_shndx > ELF::SHN_HIOS && st_shndx < ELF::SHN_ABS; + return st_shndx >= ELF::SHN_LORESERVE && st_shndx <= ELF::SHN_HIRESERVE; } bool isUndefined() const { return st_shndx == ELF::SHN_UNDEF; } }; diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 0931cb70f6d..85363f152bf 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -147,12 +147,12 @@ getSectionNameIndex(const ELFO &Obj, typename ELFO::Elf_Sym_Iter Symbol, SectionName = "Processor Specific"; else if (Symbol->isOSSpecific()) SectionName = "Operating System Specific"; - else if (Symbol->isReserved()) - SectionName = "Reserved"; else if (Symbol->isAbsolute()) SectionName = "Absolute"; else if (Symbol->isCommon()) SectionName = "Common"; + else if (Symbol->isReserved() && SectionIndex != SHN_XINDEX) + SectionName = "Reserved"; else { if (SectionIndex == SHN_XINDEX) SectionIndex = Obj.getSymbolTableIndex(&*Symbol);