From 86a28d87b15ff62ece40a9889c39ea67b956902a Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sat, 6 Jun 2015 22:54:09 +0000 Subject: [PATCH] [Object/ELF] Provide helpers for symbol types. These were, originally, in a different form in lld. They can be reused for other tools, e.g. llvm-readobj. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239231 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFTypes.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/llvm/Object/ELFTypes.h b/include/llvm/Object/ELFTypes.h index 85e1e019f99..09a6fea53ef 100644 --- a/include/llvm/Object/ELFTypes.h +++ b/include/llvm/Object/ELFTypes.h @@ -154,6 +154,7 @@ struct Elf_Sym_Base> { template struct Elf_Sym_Impl : Elf_Sym_Base { using Elf_Sym_Base::st_info; + using Elf_Sym_Base::st_shndx; using Elf_Sym_Base::st_other; // These accessors and mutators correspond to the ELF32_ST_BIND, @@ -176,6 +177,28 @@ struct Elf_Sym_Impl : Elf_Sym_Base { assert(v < 4 && "Invalid value for visibility"); st_other = (st_other & ~0x3) | v; } + + bool isAbsolute() const { return st_shndx == ELF::SHN_ABS; } + bool isCommon() const { + return !isUndefined() && + !(st_shndx >= ELF::SHN_LORESERVE && st_shndx < ELF::SHN_ABS); + } + bool isDefined() const { + return !isUndefined() && + (!(st_shndx >= ELF::SHN_LORESERVE && + st_shndx <= ELF::SHN_HIRESERVE) || + st_shndx == ELF::SHN_XINDEX); + } + bool isProcessorSpecific() const { + return st_shndx >= ELF::SHN_LOPROC && st_shndx <= ELF::SHN_HIPROC; + } + bool isOSSpecific() const { + 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; + } + bool isUndefined() const { return st_shndx == ELF::SHN_UNDEF; } }; /// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section -- 2.34.1