Home | History | Annotate | Download | only in tests

Lines Matching refs:elf

30 #include ELFUTILS_HEADER(elf)
38 add_section_data (Elf *elf, char *buf, size_t len)
42 Elf_Scn *scn = elf_getscn (elf, 1);
63 if (elf_update (elf, ELF_C_NULL) < 0)
71 static Elf *
74 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
75 if (elf == NULL)
77 printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
81 // Create an ELF header.
82 if (gelf_newehdr (elf, class) == 0)
84 printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
89 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
92 printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
103 // Update the ELF header.
104 if (gelf_update_ehdr (elf, ehdr) == 0)
106 printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
111 Elf_Scn *scn = elf_newscn (elf);
143 add_section_data (elf, DATA, DATA_LEN);
146 if (elf_update (elf, ELF_C_WRITE) < 0)
152 return elf;
155 static Elf *
158 printf ("Reading ELF file\n");
159 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL);
160 if (elf == NULL)
162 printf ("cannot create ELF descriptor read-again: %s\n", elf_errmsg (-1));
166 return elf;
170 check_section_size (Elf *elf, size_t size)
172 Elf_Scn *scn = elf_getscn (elf, 1);
198 check_section_data (Elf *elf, char *data, size_t len, size_t times)
200 Elf_Scn *scn = elf_getscn (elf, 1);
253 Elf *elf = create_elf (fd, class, use_mmap);
254 check_section_size (elf, DATA_LEN);
255 check_section_data (elf, DATA, DATA_LEN, 1);
258 add_section_data (elf, DATA, DATA_LEN);
259 check_section_size (elf, 2 * DATA_LEN);
260 check_section_data (elf, DATA, DATA_LEN, 2);
262 if (elf_end (elf) != 0)
270 // Read the ELF from disk now. And add new data directly.
278 elf = read_elf (fd, use_mmap);
279 check_section_size (elf, DATA_LEN);
283 add_section_data (elf, DATA, DATA_LEN);
284 check_section_size (elf, 2 * DATA_LEN);
285 check_section_data (elf, DATA, DATA_LEN, 2);
288 add_section_data (elf, DATA, DATA_LEN);
289 check_section_size (elf, 3 * DATA_LEN);
290 check_section_data (elf, DATA, DATA_LEN, 3);
292 if (elf_end (elf) != 0)
300 // Read the ELF from disk now. And add new data after raw reading.
308 elf = read_elf (fd, use_mmap);
309 check_section_size (elf, DATA_LEN);
313 Elf_Scn *scn = elf_getscn (elf, 1);
335 add_section_data (elf, DATA, DATA_LEN);
336 check_section_size (elf, 2 * DATA_LEN);
337 check_section_data (elf, DATA, DATA_LEN, 2);
340 add_section_data (elf, DATA, DATA_LEN);
341 check_section_size (elf, 3 * DATA_LEN);
342 check_section_data (elf, DATA, DATA_LEN, 3);
344 if (elf_end (elf) != 0)
352 // Read the ELF from disk now. And add new data after data reading.
360 elf = read_elf (fd, use_mmap);
361 check_section_size (elf, DATA_LEN);
363 check_section_data (elf, DATA, DATA_LEN, 1);
368 add_section_data (elf, DATA, DATA_LEN);
369 check_section_size (elf, 2 * DATA_LEN);
370 check_section_data (elf, DATA, DATA_LEN, 2);
373 add_section_data (elf, DATA, DATA_LEN);
374 check_section_size (elf, 3 * DATA_LEN);
375 check_section_data (elf, DATA, DATA_LEN, 3);
377 if (elf_end (elf) != 0)