1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 // NOTE: <stdint.h> is required here before <elf.h>. This is a NDK header bug.
12 // ELF is a traits structure used to provide convenient aliases for
13 // 32/64 bit Elf types, depending on the target CPU bitness.
14 #if __SIZEOF_POINTER__ == 4
16 typedef Elf32_Ehdr Ehdr;
17 typedef Elf32_Phdr Phdr;
18 typedef Elf32_Word Word;
19 typedef Elf32_Sword Sword;
20 typedef Elf32_Addr Addr;
21 typedef Elf32_Dyn Dyn;
22 typedef Elf32_Sym Sym;
23 typedef Elf32_Rel Rel;
24 typedef Elf32_Rela Rela;
25 typedef Elf32_auxv_t auxv_t;
27 enum { kElfClass = ELFCLASS32 };
28 enum { kElfBits = 32 };
31 #define ELF_R_TYPE ELF32_R_TYPE
35 #define ELF_R_SYM ELF32_R_SYM
38 #elif __SIZEOF_POINTER__ == 8
40 typedef Elf64_Ehdr Ehdr;
41 typedef Elf64_Phdr Phdr;
42 typedef Elf64_Word Word;
43 typedef Elf64_Sword Sword;
44 typedef Elf64_Addr Addr;
45 typedef Elf64_Dyn Dyn;
46 typedef Elf64_Sym Sym;
47 typedef Elf64_Rel Rel;
48 typedef Elf64_Rela Rela;
49 typedef Elf64_auxv_t auxv_t;
51 enum { kElfClass = ELFCLASS64 };
52 enum { kElfBits = 64 };
55 #define ELF_R_TYPE ELF64_R_TYPE
59 #define ELF_R_SYM ELF64_R_SYM
63 #error "Unsupported target CPU bitness"
67 #define ELF_MACHINE EM_ARM
68 #elif defined(__i386__)
69 #define ELF_MACHINE EM_386
70 #elif defined(__x86_64__)
71 #define ELF_MACHINE EM_X86_64
72 #elif defined(__mips__) && !defined(__LP64__) // mips64el defines __mips__ too
73 #define ELF_MACHINE EM_MIPS
74 #elif defined(__aarch64__)
75 #define ELF_MACHINE EM_AARCH64
77 #error "Unsupported target CPU architecture"
80 #endif // _ELF_TRAITS_H_