[llvm] r239231 - [Object/ELF] Provide helpers for symbol types.
Davide Italiano
davide at freebsd.org
Sat Jun 6 15:54:09 PDT 2015
Author: davide
Date: Sat Jun 6 17:54:09 2015
New Revision: 239231
URL: http://llvm.org/viewvc/llvm-project?rev=239231&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/Object/ELFTypes.h
Modified: llvm/trunk/include/llvm/Object/ELFTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFTypes.h?rev=239231&r1=239230&r2=239231&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFTypes.h (original)
+++ llvm/trunk/include/llvm/Object/ELFTypes.h Sat Jun 6 17:54:09 2015
@@ -154,6 +154,7 @@ struct Elf_Sym_Base<ELFType<TargetEndian
template <class ELFT>
struct Elf_Sym_Impl : Elf_Sym_Base<ELFT> {
using Elf_Sym_Base<ELFT>::st_info;
+ using Elf_Sym_Base<ELFT>::st_shndx;
using Elf_Sym_Base<ELFT>::st_other;
// These accessors and mutators correspond to the ELF32_ST_BIND,
@@ -176,6 +177,28 @@ struct Elf_Sym_Impl : Elf_Sym_Base<ELFT>
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
More information about the llvm-commits
mailing list