OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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. |
| 4 |
| 5 #ifndef _ELF_TRAITS_H_ |
| 6 #define _ELF_TRAITS_H_ |
| 7 |
| 8 // NOTE: <stdint.h> is required here before <elf.h>. This is a NDK header bug. |
| 9 #include <stdint.h> |
| 10 #include <elf.h> |
| 11 |
| 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 |
| 15 struct ELF { |
| 16 typedef Elf32_Ehdr Ehdr; |
| 17 typedef Elf32_Phdr Phdr; |
| 18 typedef Elf32_Word Word; |
| 19 typedef Elf32_Addr Addr; |
| 20 typedef Elf32_Dyn Dyn; |
| 21 typedef Elf32_Sym Sym; |
| 22 typedef Elf32_Rel Rel; |
| 23 typedef Elf32_auxv_t auxv_t; |
| 24 |
| 25 enum { kElfClass = ELFCLASS32 }; |
| 26 enum { kElfBits = 32 }; |
| 27 }; |
| 28 #elif __SIZEOF_POINTER__ == 8 |
| 29 struct ELF { |
| 30 typedef Elf64_Ehdr Ehdr; |
| 31 typedef Elf64_Phdr Phdr; |
| 32 typedef Elf64_Word Word; |
| 33 typedef Elf64_Addr Addr; |
| 34 typedef Elf64_Dyn Dyn; |
| 35 typedef Elf64_Sym Sym; |
| 36 typedef Elf64_Rel Rel; |
| 37 typedef Elf64_auxv_t auxv_t; |
| 38 |
| 39 enum { kElfClass = ELFCLASS64 }; |
| 40 enum { kElfBits = 64 }; |
| 41 }; |
| 42 #else |
| 43 #error "Unsupported target CPU bitness" |
| 44 #endif |
| 45 |
| 46 #ifdef __arm__ |
| 47 #define ELF_MACHINE EM_ARM |
| 48 #elif defined(__i386__) |
| 49 #define ELF_MACHINE EM_386 |
| 50 #elif defined(__mips__) |
| 51 #define ELF_MACHINE EM_MIPS |
| 52 #else |
| 53 #error "Unsupported target CPU architecture" |
| 54 #endif |
| 55 |
| 56 #endif // _ELF_TRAITS_H_ |
OLD | NEW |