[PATCH] [Object/ELF] Provide symbol helpers

Rui Ueyama ruiu at google.com
Fri Jun 5 13:49:09 PDT 2015


On Fri, Jun 5, 2015 at 1:46 PM, Davide Italiano <dccitaliano at gmail.com>
wrote:

> Yes, you're both right. I should have done this before.
>
>
> http://reviews.llvm.org/D10264
>
> Files:
>   include/llvm/Object/ELFTypes.h
>
> Index: include/llvm/Object/ELFTypes.h
> ===================================================================
> --- include/llvm/Object/ELFTypes.h
> +++ include/llvm/Object/ELFTypes.h
> @@ -154,6 +154,7 @@
>  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,27 @@
>      assert(v < 4 && "Invalid value for visibility");
>      st_other = (st_other & ~0x3) | v;
>    }
> +
> +  bool isAbsoluteSymbol() const { return st_shndx == ELF::SHN_ABS; }
> +  bool isCommonSymbol() const {
> +    return getType() == ELF::STT_COMMON || st_shndx == ELF::SHN_COMMON;
> +  }
> +  bool isDefinedSymbol() const {
> +    return !isUndefinedSymbol() &&
> +           (!(st_shndx >= ELF::SHN_LORESERVE &&
> +              st_shndx <= ELF::SHN_HIRESERVE) ||
> +            st_shndx == ELF::SHN_XINDEX);
> +  }
> +  bool isProcessorSpecificSymbol() const {
> +    return st_shndx >= ELF::SHN_LOPROC && st_shndx <= ELF::SHN_HIPROC;
> +  }
> +  bool isOSSpecificSymbol() const {
> +    return st_shndx >= ELF::SHN_LOOS && st_shndx <= ELF::SHN_HIOS;
> +  }
> +  bool isReservedSymbol() const {
> +    return st_shndx > ELF::SHN_HIOS && st_shndx < ELF::SHN_ABS;
> +  }
> +  bool isUndefinedSymbol() const { return st_shndx == ELF::SHN_UNDEF; }
>  };
>

Because they are now members of Elf_Sym, I'd remove "Symbol" suffix from
function names.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150605/60817524/attachment.html>


More information about the llvm-commits mailing list