// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_ZUCCHINI_TYPE_ELF_H_ #define COMPONENTS_ZUCCHINI_TYPE_ELF_H_ #include <stdint.h> namespace zucchini { // Structures and constants taken from linux/elf.h and following identical // layout. This is used for parsing of Executable and Linkable Format (ELF). namespace elf { // Supported by MSVC, g++, and clang++. Ensures no gaps in packing. #pragma pack(push, 1) // This header defines various types from the ELF file spec, but no code // related to using them. Elf32_Addr; // Unsigned program address. Elf32_Half; // Unsigned medium integer. Elf32_Off; // Unsigned file offset. Elf32_Sword; // Signed large integer. Elf32_Word; // Unsigned large integer. Elf64_Addr; // Unsigned program address. Elf64_Half; // Unsigned medium integer. Elf64_Off; // Unsigned file offset. Elf64_Sword; // Signed large integer. Elf64_Word; // Unsigned large integer. Elf64_Sxword; // Signed extra large integer. Elf64_Xword; // Unsigned extra large integer. // The header at the top of the file. struct Elf32_Ehdr { … }; struct Elf64_Ehdr { … }; // Identification Indexes in header->e_ident. enum IdentificationIndex { … }; // Values for header->e_ident[EI_CLASS]. enum FileClass { … }; // Values for header->e_type. enum FileType { … }; // Values for header->e_machine. enum MachineArchitecture { … }; // A section header in the section header table. struct Elf32_Shdr { … }; struct Elf64_Shdr { … }; // Values for the section type field in a section header. enum sh_type_values { … }; enum sh_flag_masks { … }; struct Elf32_Phdr { … }; struct Elf64_Phdr { … }; // Values for the segment type field in a program segment header. enum ph_type_values { … }; struct Elf32_Rel { … }; struct Elf64_Rel { … }; struct Elf32_Rela { … }; struct Elf64_Rela { … }; enum elf32_rel_386_type_values { … }; enum elf32_rel_x86_64_type_values { … }; enum elf32_rel_arm_type_values { … }; enum elf64_rel_aarch64_type_values { … }; #pragma pack(pop) } // namespace elf } // namespace zucchini #endif // COMPONENTS_ZUCCHINI_TYPE_ELF_H_