Lines Matching defs:elf
27 #include <elf.h>
137 } elf;
164 elf.path, ## __VA_ARGS__); \
172 elf.path, strerror(errno)); \
198 #define elf_ptr(type, off) ((type *)(elf.begin + (off)))
202 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var)
218 return elf.sh_string + elf32toh(shdr->sh_name);
238 return &elf.sh_table[idx];
251 elf.path = path;
266 elf.begin = mmap(0, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
267 if (elf.begin == MAP_FAILED) {
276 assert_ge(stat.st_size, sizeof(*elf.ehdr), "%lu");
277 elf.ehdr = elf_ptr(Elf64_Ehdr, 0);
280 assert_eq(elf.ehdr->e_ident[EI_MAG0], ELFMAG0, "0x%x");
281 assert_eq(elf.ehdr->e_ident[EI_MAG1], ELFMAG1, "0x%x");
282 assert_eq(elf.ehdr->e_ident[EI_MAG2], ELFMAG2, "0x%x");
283 assert_eq(elf.ehdr->e_ident[EI_MAG3], ELFMAG3, "0x%x");
286 assert_eq(elf.ehdr->e_ident[EI_CLASS], ELFCLASS64, "%u");
287 assert_eq(elf.ehdr->e_ident[EI_DATA], ELFENDIAN, "%u");
288 assert_eq(elf16toh(elf.ehdr->e_type), ET_REL, "%u");
289 assert_eq(elf16toh(elf.ehdr->e_machine), EM_AARCH64, "%u");
292 elf.sh_table = section_by_off(elf64toh(elf.ehdr->e_shoff));
293 elf.sh_string = section_begin(section_by_idx(elf16toh(elf.ehdr->e_shstrndx)));
362 Elf64_Shdr *sh_orig = &elf.sh_table[elf32toh(sh_rela->sh_info)];