1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef BERBERIS_TINY_LOADER_ELF_TYPES_H_ 18 #define BERBERIS_TINY_LOADER_ELF_TYPES_H_ 19 20 #include <elf.h> 21 22 // glibc has this defined in link.h - remove the definition to avoid conflicts 23 #if defined(ElfW) 24 #undef ElfW 25 #endif 26 27 #if defined(__LP64__) 28 #define ElfW(type) Elf64_##type 29 constexpr int kSupportedElfClass = ELFCLASS64; 30 #else 31 #define ElfW(type) Elf32_##type 32 constexpr int kSupportedElfClass = ELFCLASS32; 33 #endif 34 35 using ElfAddr = ElfW(Addr); 36 using ElfDyn = ElfW(Dyn); 37 using ElfEhdr = ElfW(Ehdr); 38 using ElfHalf = ElfW(Half); 39 using ElfPhdr = ElfW(Phdr); 40 using ElfShdr = ElfW(Shdr); 41 using ElfSym = ElfW(Sym); 42 using ElfWord = ElfW(Word); 43 44 #endif // BERBERIS_TINY_LOADER_ELF_TYPES_H_ 45