Index: third_party/android_platform/bionic/tools/relocation_packer/src/elf_traits.h |
diff --git a/tools/relocation_packer/src/elf_traits.h b/third_party/android_platform/bionic/tools/relocation_packer/src/elf_traits.h |
similarity index 50% |
copy from tools/relocation_packer/src/elf_traits.h |
copy to third_party/android_platform/bionic/tools/relocation_packer/src/elf_traits.h |
index 1004767542b16db7392f35e3e577e1cdd2e76e56..41b06c8576d689cb672c6feebf5e233c5354546a 100644 |
--- a/tools/relocation_packer/src/elf_traits.h |
+++ b/third_party/android_platform/bionic/tools/relocation_packer/src/elf_traits.h |
@@ -10,31 +10,10 @@ |
#include "elf.h" |
#include "libelf.h" |
-// The TARGET_ macro controls which Elf types we expect and handle. |
-// Either TARGET_ARM or TARGET_ARM64 must be defined, but not both. |
- |
-#if !defined(TARGET_ARM) && !defined(TARGET_ARM64) |
-# error "Unsupported target, define one of TARGET_ARM or TARGET_ARM64" |
-#elif defined(TARGET_ARM) && defined(TARGET_ARM64) |
-# error "Define one of TARGET_ARM or TARGET_ARM64, but not both" |
-#endif |
- |
-// TODO(simonb): Eliminate these once AARCH64 appears reliably in elf.h. |
-#ifndef EM_AARCH64 |
-#define EM_AARCH64 183 |
-#endif |
-#ifndef R_AARCH64_RELATIVE |
-#define R_AARCH64_RELATIVE 1027 |
-#endif |
-#ifndef R_AARCH64_NONE |
-#define R_AARCH64_NONE 0 |
-#endif |
- |
// ELF is a traits structure used to provide convenient aliases for |
-// 32/64 bit Elf types and functions, depending on the target specified. |
+// 32/64 bit Elf types and functions, depending on the target file. |
-#if defined(TARGET_ARM) |
-struct ELF { |
+struct ELF32_traits { |
typedef Elf32_Addr Addr; |
typedef Elf32_Dyn Dyn; |
typedef Elf32_Ehdr Ehdr; |
@@ -48,26 +27,17 @@ struct ELF { |
typedef Elf32_Sym Sym; |
typedef Elf32_Word Word; |
typedef Elf32_Xword Xword; |
+ typedef Elf32_Half Half; |
static inline Ehdr* getehdr(Elf* elf) { return elf32_getehdr(elf); } |
static inline Phdr* getphdr(Elf* elf) { return elf32_getphdr(elf); } |
static inline Shdr* getshdr(Elf_Scn* scn) { return elf32_getshdr(scn); } |
- |
- enum { kMachine = EM_ARM }; |
- enum { kFileClass = ELFCLASS32 }; |
- enum { kRelativeRelocationCode = R_ARM_RELATIVE }; |
- enum { kNoRelocationCode = R_ARM_NONE }; |
- |
- static inline const char* Machine() { return "ARM"; } |
- |
-# define ELF_R_SYM(val) ELF32_R_SYM(val) |
-# define ELF_R_TYPE(val) ELF32_R_TYPE(val) |
-# define ELF_R_INFO(sym, type) ELF32_R_INFO(sym, type) |
-# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) |
+ static inline Word elf_r_type(Word info) { return ELF32_R_TYPE(info); } |
+ static inline int elf_st_type(uint8_t info) { return ELF32_ST_TYPE(info); } |
+ static inline Word elf_r_sym(Word info) { return ELF32_R_SYM(info); } |
}; |
-#elif defined(TARGET_ARM64) |
-struct ELF { |
+struct ELF64_traits { |
typedef Elf64_Addr Addr; |
typedef Elf64_Dyn Dyn; |
typedef Elf64_Ehdr Ehdr; |
@@ -81,23 +51,14 @@ struct ELF { |
typedef Elf64_Sym Sym; |
typedef Elf64_Word Word; |
typedef Elf64_Xword Xword; |
+ typedef Elf64_Half Half; |
static inline Ehdr* getehdr(Elf* elf) { return elf64_getehdr(elf); } |
static inline Phdr* getphdr(Elf* elf) { return elf64_getphdr(elf); } |
static inline Shdr* getshdr(Elf_Scn* scn) { return elf64_getshdr(scn); } |
- |
- enum { kMachine = EM_AARCH64 }; |
- enum { kFileClass = ELFCLASS64 }; |
- enum { kRelativeRelocationCode = R_AARCH64_RELATIVE }; |
- enum { kNoRelocationCode = R_AARCH64_NONE }; |
- |
- static inline const char* Machine() { return "ARM64"; } |
- |
-# define ELF_R_SYM(val) ELF64_R_SYM(val) |
-# define ELF_R_TYPE(val) ELF64_R_TYPE(val) |
-# define ELF_R_INFO(sym, type) ELF64_R_INFO(sym, type) |
-# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) |
+ static inline Xword elf_r_type(Xword info) { return ELF64_R_TYPE(info); } |
+ static inline int elf_st_type(uint8_t info) { return ELF64_ST_TYPE(info); } |
+ static inline Word elf_r_sym(Xword info) { return ELF64_R_SYM(info); } |
}; |
-#endif |
#endif // TOOLS_RELOCATION_PACKER_SRC_ELF_TRAITS_H_ |