// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef _ELF_TRAITS_H_ #define _ELF_TRAITS_H_ // NOTE: is required here before . This is a NDK header bug. #include #include // ELF is a traits structure used to provide convenient aliases for // 32/64 bit Elf types, depending on the target CPU bitness. #if __SIZEOF_POINTER__ == 4 struct ELF { typedef Elf32_Ehdr Ehdr; typedef Elf32_Phdr Phdr; typedef Elf32_Word Word; typedef Elf32_Sword Sword; typedef Elf32_Addr Addr; typedef Elf32_Dyn Dyn; typedef Elf32_Sym Sym; typedef Elf32_Rel Rel; typedef Elf32_Rela Rela; typedef Elf32_auxv_t auxv_t; enum { kElfClass = ELFCLASS32 }; enum { kElfBits = 32 }; #ifndef ELF_R_TYPE #define ELF_R_TYPE ELF32_R_TYPE #endif #ifndef ELF_R_SYM #define ELF_R_SYM ELF32_R_SYM #endif }; #elif __SIZEOF_POINTER__ == 8 struct ELF { typedef Elf64_Ehdr Ehdr; typedef Elf64_Phdr Phdr; typedef Elf64_Word Word; typedef Elf64_Sword Sword; typedef Elf64_Addr Addr; typedef Elf64_Dyn Dyn; typedef Elf64_Sym Sym; typedef Elf64_Rel Rel; typedef Elf64_Rela Rela; typedef Elf64_auxv_t auxv_t; enum { kElfClass = ELFCLASS64 }; enum { kElfBits = 64 }; #ifndef ELF_R_TYPE #define ELF_R_TYPE ELF64_R_TYPE #endif #ifndef ELF_R_SYM #define ELF_R_SYM ELF64_R_SYM #endif }; #else #error "Unsupported target CPU bitness" #endif #ifdef __arm__ #define ELF_MACHINE EM_ARM #elif defined(__i386__) #define ELF_MACHINE EM_386 #elif defined(__mips__) && !defined(__LP64__) // mips64el defines __mips__ too #define ELF_MACHINE EM_MIPS #elif defined(__aarch64__) #define ELF_MACHINE EM_AARCH64 #else #error "Unsupported target CPU architecture" #endif #endif // _ELF_TRAITS_H_