Home | History | Annotate | Download | only in tests

Lines Matching refs:Ehdr

33 template <typename Ehdr>
34 void InitEhdr(Ehdr* ehdr, uint32_t elf_class, uint32_t machine) {
35 memset(ehdr, 0, sizeof(Ehdr));
36 memcpy(&ehdr->e_ident[0], ELFMAG, SELFMAG);
37 ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
38 ehdr->e_ident[EI_VERSION] = EV_CURRENT;
39 ehdr->e_ident[EI_OSABI] = ELFOSABI_SYSV;
40 ehdr->e_ident[EI_CLASS] = elf_class;
41 ehdr->e_type = ET_DYN;
42 ehdr->e_machine = machine;
43 ehdr->e_version = EV_CURRENT;
44 ehdr->e_ehsize = sizeof(Ehdr);
47 template <typename Ehdr, typename Shdr>
48 void GenElf(Ehdr* ehdr, int fd) {
49 uint64_t offset = sizeof(Ehdr);
50 ehdr->e_shoff = offset;
51 ehdr->e_shnum = 3;
52 ehdr->e_shentsize = sizeof(Shdr);
53 ehdr->e_shstrndx = 2;
54 TEMP_FAILURE_RETRY(write(fd, ehdr, sizeof(Ehdr)));
61 offset += ehdr->e_shentsize;
71 offset += ehdr->e_shentsize;