Lines Matching full:elf

14  * The input of this program is the relocatable ELF object containing
27 #include <elf.h>
132 /* Global state of the processed ELF. */
140 } elf; variable
167 elf.path, ## __VA_ARGS__); \
175 elf.path, strerror(errno)); \
199 * the beginning of the ELF file.
201 #define elf_ptr(type, off) ((type *)(elf.begin + (off)))
203 /* Iterate over all sections in the ELF. */
205 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var)
221 return elf.sh_string + elf32toh(shdr->sh_name); in section_name()
241 return &elf.sh_table[idx]; in section_by_idx()
245 * Memory-map the given ELF file, perform sanity checks, and
254 elf.path = path; in init_elf()
256 /* Open the ELF file. */ in init_elf()
259 fatal_perror("Could not open ELF file"); in init_elf()
261 /* Get status of ELF file to obtain its size. */ in init_elf()
265 fatal_perror("Could not get status of ELF file"); in init_elf()
268 /* mmap() the entire ELF file read-only at an arbitrary address. */ in init_elf()
269 elf.begin = mmap(0, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0); in init_elf()
270 if (elf.begin == MAP_FAILED) { in init_elf()
272 fatal_perror("Could not mmap ELF file"); in init_elf()
278 /* Get pointer to the ELF header. */ in init_elf()
279 assert_ge(stat.st_size, sizeof(*elf.ehdr), "%lu"); in init_elf()
280 elf.ehdr = elf_ptr(Elf64_Ehdr, 0); in init_elf()
282 /* Check the ELF magic. */ in init_elf()
283 assert_eq(elf.ehdr->e_ident[EI_MAG0], ELFMAG0, "0x%x"); in init_elf()
284 assert_eq(elf.ehdr->e_ident[EI_MAG1], ELFMAG1, "0x%x"); in init_elf()
285 assert_eq(elf.ehdr->e_ident[EI_MAG2], ELFMAG2, "0x%x"); in init_elf()
286 assert_eq(elf.ehdr->e_ident[EI_MAG3], ELFMAG3, "0x%x"); in init_elf()
289 assert_eq(elf.ehdr->e_ident[EI_CLASS], ELFCLASS64, "%u"); in init_elf()
290 assert_eq(elf.ehdr->e_ident[EI_DATA], ELFENDIAN, "%u"); in init_elf()
291 assert_eq(elf16toh(elf.ehdr->e_type), ET_REL, "%u"); in init_elf()
292 assert_eq(elf16toh(elf.ehdr->e_machine), EM_AARCH64, "%u"); in init_elf()
295 elf.sh_table = section_by_off(elf64toh(elf.ehdr->e_shoff)); in init_elf()
296 elf.sh_string = section_begin(section_by_idx(elf16toh(elf.ehdr->e_shstrndx))); in init_elf()
365 Elf64_Shdr *sh_orig = &elf.sh_table[elf32toh(sh_rela->sh_info)]; in emit_rela_section()