From c74ac023d83730307835b6c67bbfb326b64eaf62 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 12 Jun 2015 17:23:39 +0000 Subject: [PATCH] Have the ELF symbol predicates match more directly the spec. The underlaying issues is that this code can't really know if an OS specific or processor specific section number should return true or false. One option would be to assert or return an error, but that looks like over engineering since extensions are not that common. It seems better to have these be direct implementation of the ELF spec so that they are natural for someone familiar with ELF reading the code. Code that does have to handle OS/Architecture specific values can do it at a higher level. llvm-svn: 239618 --- llvm/include/llvm/Object/ELFTypes.h | 7 ++----- llvm/tools/llvm-readobj/ELFDumper.cpp | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h index 15c792f6..4b8ed883 100644 --- a/llvm/include/llvm/Object/ELFTypes.h +++ b/llvm/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/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 0931cb7..85363f1 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/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); -- 2.7.4