summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-03-14 22:58:21 +0000
committerRui Ueyama <ruiu@google.com>2016-03-14 22:58:21 +0000
commit113819bf8b52b852ca18114c8a946077609afa03 (patch)
treeaa0b88aa4ae0903d36819049f453c71f09a000ea
parentbdb261b4c01b0bdd3fa22b60ffbe1318ab906630 (diff)
downloadbcm5719-llvm-113819bf8b52b852ca18114c8a946077609afa03.tar.gz
bcm5719-llvm-113819bf8b52b852ca18114c8a946077609afa03.zip
Object: Add ELF types to ELFType.
These types are defined in ELFFile, so in order to use them, you have to write ELFFile<ELFT>::SomeType. But there seems to be no reason to have ELFFile have these types. This patch allows you to write ELFT::SomeType instead. This simplifies libObject users. This is an example: http://reviews.llvm.org/D18129 http://reviews.llvm.org/D18130 llvm-svn: 263504
-rw-r--r--llvm/include/llvm/Object/ELFTypes.h55
1 files changed, 49 insertions, 6 deletions
diff --git a/llvm/include/llvm/Object/ELFTypes.h b/llvm/include/llvm/Object/ELFTypes.h
index 3d7f0c1384a..d5a9c00598f 100644
--- a/llvm/include/llvm/Object/ELFTypes.h
+++ b/llvm/include/llvm/Object/ELFTypes.h
@@ -21,9 +21,55 @@ namespace object {
using support::endianness;
-template <endianness target_endianness, bool is64Bits> struct ELFType {
- static const endianness TargetEndianness = target_endianness;
- static const bool Is64Bits = is64Bits;
+template <class ELFT> struct Elf_Ehdr_Impl;
+template <class ELFT> struct Elf_Shdr_Impl;
+template <class ELFT> struct Elf_Sym_Impl;
+template <class ELFT> struct Elf_Dyn_Impl;
+template <class ELFT> struct Elf_Phdr_Impl;
+template <class ELFT, bool isRela> struct Elf_Rel_Impl;
+template <class ELFT> struct Elf_Verdef_Impl;
+template <class ELFT> struct Elf_Verdaux_Impl;
+template <class ELFT> struct Elf_Verneed_Impl;
+template <class ELFT> struct Elf_Vernaux_Impl;
+template <class ELFT> struct Elf_Versym_Impl;
+template <class ELFT> struct Elf_Hash_Impl;
+template <class ELFT> struct Elf_GnuHash_Impl;
+
+template <endianness E, bool Is64> struct ELFType {
+private:
+ template <typename Ty>
+ using packed = support::detail::packed_endian_specific_integral<Ty, E, 2>;
+
+public:
+ static const endianness TargetEndianness = E;
+ static const bool Is64Bits = Is64;
+
+ typedef typename std::conditional<Is64, uint64_t, uint32_t>::type uint;
+ typedef Elf_Ehdr_Impl<ELFType<E, Is64>> Ehdr;
+ typedef Elf_Shdr_Impl<ELFType<E, Is64>> Shdr;
+ typedef Elf_Sym_Impl<ELFType<E, Is64>> Sym;
+ typedef Elf_Dyn_Impl<ELFType<E, Is64>> Dyn;
+ typedef Elf_Phdr_Impl<ELFType<E, Is64>> Phdr;
+ typedef Elf_Rel_Impl<ELFType<E, Is64>, false> Rel;
+ typedef Elf_Rel_Impl<ELFType<E, Is64>, true> Rela;
+ typedef Elf_Verdef_Impl<ELFType<E, Is64>> Verdef;
+ typedef Elf_Verdaux_Impl<ELFType<E, Is64>> Verdaux;
+ typedef Elf_Verneed_Impl<ELFType<E, Is64>> Verneed;
+ typedef Elf_Vernaux_Impl<ELFType<E, Is64>> Vernaux;
+ typedef Elf_Versym_Impl<ELFType<E, Is64>> Versym;
+ typedef Elf_Hash_Impl<ELFType<E, Is64>> Hash;
+ typedef Elf_GnuHash_Impl<ELFType<E, Is64>> GnuHash;
+ typedef iterator_range<const Dyn *> DynRange;
+ typedef iterator_range<const Shdr *> ShdrRange;
+ typedef iterator_range<const Sym *> SymRange;
+
+ typedef packed<uint16_t> Half;
+ typedef packed<uint32_t> Word;
+ typedef packed<int32_t> Sword;
+ typedef packed<uint64_t> Xword;
+ typedef packed<int64_t> Sxword;
+ typedef packed<uint> Addr;
+ typedef packed<uint> Off;
};
typedef ELFType<support::little, false> ELF32LE;
@@ -320,9 +366,6 @@ struct Elf_Dyn_Impl : Elf_Dyn_Base<ELFT> {
uintX_t getPtr() const { return d_un.d_ptr; }
};
-// Elf_Rel: Elf Relocation
-template <class ELFT, bool isRela> struct Elf_Rel_Impl;
-
template <endianness TargetEndianness>
struct Elf_Rel_Impl<ELFType<TargetEndianness, false>, false> {
LLVM_ELF_IMPORT_TYPES(TargetEndianness, false)
OpenPOWER on IntegriCloud