Lines Matching refs:elf
56 Elf *elf; in file_read_ar() local
59 elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_ar()
61 if (elf != NULL) in file_read_ar()
65 elf->state.ar.offset = offset + SARMAG; in file_read_ar()
67 elf->state.ar.elf_ar_hdr.ar_rawname = elf->state.ar.raw_name; in file_read_ar()
70 return elf; in file_read_ar()
282 Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_elf() local
284 if (elf == NULL) in file_read_elf()
291 elf->state.elf32.scns.cnt = scncnt; in file_read_elf()
292 elf->state.elf32.scns.max = scnmax; in file_read_elf()
295 elf->state.elf.scnincr = 10; in file_read_elf()
298 elf->class = e_ident[EI_CLASS]; in file_read_elf()
312 elf->state.elf32.ehdr = ehdr; in file_read_elf()
317 elf->state.elf32.ehdr = memcpy (&elf->state.elf32.ehdr_mem, e_ident, in file_read_elf()
322 CONVERT (elf->state.elf32.ehdr_mem.e_type); in file_read_elf()
323 CONVERT (elf->state.elf32.ehdr_mem.e_machine); in file_read_elf()
324 CONVERT (elf->state.elf32.ehdr_mem.e_version); in file_read_elf()
325 CONVERT (elf->state.elf32.ehdr_mem.e_entry); in file_read_elf()
326 CONVERT (elf->state.elf32.ehdr_mem.e_phoff); in file_read_elf()
327 CONVERT (elf->state.elf32.ehdr_mem.e_shoff); in file_read_elf()
328 CONVERT (elf->state.elf32.ehdr_mem.e_flags); in file_read_elf()
329 CONVERT (elf->state.elf32.ehdr_mem.e_ehsize); in file_read_elf()
330 CONVERT (elf->state.elf32.ehdr_mem.e_phentsize); in file_read_elf()
331 CONVERT (elf->state.elf32.ehdr_mem.e_phnum); in file_read_elf()
332 CONVERT (elf->state.elf32.ehdr_mem.e_shentsize); in file_read_elf()
333 CONVERT (elf->state.elf32.ehdr_mem.e_shnum); in file_read_elf()
334 CONVERT (elf->state.elf32.ehdr_mem.e_shstrndx); in file_read_elf()
341 Elf32_Off e_shoff = elf->state.elf32.ehdr->e_shoff; in file_read_elf()
353 free (elf); in file_read_elf()
357 elf->state.elf32.shdr in file_read_elf()
362 elf->state.elf32.scns.data[cnt].index = cnt; in file_read_elf()
363 elf->state.elf32.scns.data[cnt].elf = elf; in file_read_elf()
364 elf->state.elf32.scns.data[cnt].shdr.e32 = in file_read_elf()
365 &elf->state.elf32.shdr[cnt]; in file_read_elf()
366 if (likely (elf->state.elf32.shdr[cnt].sh_offset < maxsize) in file_read_elf()
367 && likely (elf->state.elf32.shdr[cnt].sh_size in file_read_elf()
368 <= maxsize - elf->state.elf32.shdr[cnt].sh_offset)) in file_read_elf()
369 elf->state.elf32.scns.data[cnt].rawdata_base = in file_read_elf()
370 elf->state.elf32.scns.data[cnt].data_base = in file_read_elf()
372 + elf->state.elf32.shdr[cnt].sh_offset); in file_read_elf()
373 elf->state.elf32.scns.data[cnt].list = &elf->state.elf32.scns; in file_read_elf()
378 if (elf->state.elf32.shdr[cnt].sh_type == SHT_SYMTAB_SHNDX in file_read_elf()
379 && elf->state.elf32.shdr[cnt].sh_link < scncnt) in file_read_elf()
380 elf->state.elf32.scns.data[elf->state.elf32.shdr[cnt].sh_link].shndx_index in file_read_elf()
385 if (elf->state.elf32.scns.data[cnt].shndx_index == 0) in file_read_elf()
386 elf->state.elf32.scns.data[cnt].shndx_index = -1; in file_read_elf()
393 elf->state.elf32.scns.data[cnt].index = cnt; in file_read_elf()
394 elf->state.elf32.scns.data[cnt].elf = elf; in file_read_elf()
395 elf->state.elf32.scns.data[cnt].list = &elf->state.elf32.scns; in file_read_elf()
400 elf->state.elf32.scns_last = &elf->state.elf32.scns; in file_read_elf()
414 elf->state.elf64.ehdr = ehdr; in file_read_elf()
419 elf->state.elf64.ehdr = memcpy (&elf->state.elf64.ehdr_mem, e_ident, in file_read_elf()
424 CONVERT (elf->state.elf64.ehdr_mem.e_type); in file_read_elf()
425 CONVERT (elf->state.elf64.ehdr_mem.e_machine); in file_read_elf()
426 CONVERT (elf->state.elf64.ehdr_mem.e_version); in file_read_elf()
427 CONVERT (elf->state.elf64.ehdr_mem.e_entry); in file_read_elf()
428 CONVERT (elf->state.elf64.ehdr_mem.e_phoff); in file_read_elf()
429 CONVERT (elf->state.elf64.ehdr_mem.e_shoff); in file_read_elf()
430 CONVERT (elf->state.elf64.ehdr_mem.e_flags); in file_read_elf()
431 CONVERT (elf->state.elf64.ehdr_mem.e_ehsize); in file_read_elf()
432 CONVERT (elf->state.elf64.ehdr_mem.e_phentsize); in file_read_elf()
433 CONVERT (elf->state.elf64.ehdr_mem.e_phnum); in file_read_elf()
434 CONVERT (elf->state.elf64.ehdr_mem.e_shentsize); in file_read_elf()
435 CONVERT (elf->state.elf64.ehdr_mem.e_shnum); in file_read_elf()
436 CONVERT (elf->state.elf64.ehdr_mem.e_shstrndx); in file_read_elf()
443 Elf64_Off e_shoff = elf->state.elf64.ehdr->e_shoff; in file_read_elf()
454 elf->state.elf64.shdr in file_read_elf()
459 elf->state.elf64.scns.data[cnt].index = cnt; in file_read_elf()
460 elf->state.elf64.scns.data[cnt].elf = elf; in file_read_elf()
461 elf->state.elf64.scns.data[cnt].shdr.e64 = in file_read_elf()
462 &elf->state.elf64.shdr[cnt]; in file_read_elf()
463 if (likely (elf->state.elf64.shdr[cnt].sh_offset < maxsize) in file_read_elf()
464 && likely (elf->state.elf64.shdr[cnt].sh_size in file_read_elf()
465 <= maxsize - elf->state.elf64.shdr[cnt].sh_offset)) in file_read_elf()
466 elf->state.elf64.scns.data[cnt].rawdata_base = in file_read_elf()
467 elf->state.elf64.scns.data[cnt].data_base = in file_read_elf()
469 + elf->state.elf64.shdr[cnt].sh_offset); in file_read_elf()
470 elf->state.elf64.scns.data[cnt].list = &elf->state.elf64.scns; in file_read_elf()
475 if (elf->state.elf64.shdr[cnt].sh_type == SHT_SYMTAB_SHNDX in file_read_elf()
476 && elf->state.elf64.shdr[cnt].sh_link < scncnt) in file_read_elf()
477 elf->state.elf64.scns.data[elf->state.elf64.shdr[cnt].sh_link].shndx_index in file_read_elf()
482 if (elf->state.elf64.scns.data[cnt].shndx_index == 0) in file_read_elf()
483 elf->state.elf64.scns.data[cnt].shndx_index = -1; in file_read_elf()
490 elf->state.elf64.scns.data[cnt].index = cnt; in file_read_elf()
491 elf->state.elf64.scns.data[cnt].elf = elf; in file_read_elf()
492 elf->state.elf64.scns.data[cnt].list = &elf->state.elf64.scns; in file_read_elf()
497 elf->state.elf64.scns_last = &elf->state.elf64.scns; in file_read_elf()
500 return elf; in file_read_elf()
676 read_long_names (Elf *elf) in read_long_names() argument
686 if (elf->map_address != NULL) in read_long_names()
688 if ((size_t) offset > elf->maximum_size in read_long_names()
689 || elf->maximum_size - offset < sizeof (struct ar_hdr)) in read_long_names()
693 hdr = (struct ar_hdr *) (elf->map_address + offset); in read_long_names()
698 if (unlikely (pread_retry (elf->fildes, &hdrm, sizeof (hdrm), in read_long_names()
699 elf->start_offset + offset) in read_long_names()
722 if (elf->map_address != NULL) in read_long_names()
724 if (len > elf->maximum_size - offset - sizeof (struct ar_hdr)) in read_long_names()
727 elf->state.ar.long_names = (char *) memcpy (newp, in read_long_names()
728 elf->map_address + offset in read_long_names()
734 if (unlikely ((size_t) pread_retry (elf->fildes, newp, len, in read_long_names()
735 elf->start_offset + offset in read_long_names()
742 elf->state.ar.long_names = NULL; in read_long_names()
745 elf->state.ar.long_names = newp; in read_long_names()
748 elf->state.ar.long_names_len = len; in read_long_names()
780 __libelf_next_arhdr_wrlock (Elf *elf) in __libelf_next_arhdr_wrlock() argument
785 if (elf->map_address != NULL) in __libelf_next_arhdr_wrlock()
788 if (unlikely ((size_t) elf->state.ar.offset in __libelf_next_arhdr_wrlock()
789 > elf->start_offset + elf->maximum_size in __libelf_next_arhdr_wrlock()
790 || (elf->start_offset + elf->maximum_size in __libelf_next_arhdr_wrlock()
791 - elf->state.ar.offset) < sizeof (struct ar_hdr))) in __libelf_next_arhdr_wrlock()
797 ar_hdr = (struct ar_hdr *) (elf->map_address + elf->state.ar.offset); in __libelf_next_arhdr_wrlock()
801 ar_hdr = &elf->state.ar.ar_hdr; in __libelf_next_arhdr_wrlock()
803 if (unlikely (pread_retry (elf->fildes, ar_hdr, sizeof (struct ar_hdr), in __libelf_next_arhdr_wrlock()
804 elf->state.ar.offset) in __libelf_next_arhdr_wrlock()
822 *((char *) mempcpy (elf->state.ar.raw_name, ar_hdr->ar_name, 16)) = '\0'; in __libelf_next_arhdr_wrlock()
824 elf_ar_hdr = &elf->state.ar.elf_ar_hdr; in __libelf_next_arhdr_wrlock()
833 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "/", 2); in __libelf_next_arhdr_wrlock()
837 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "/SYM64/", 8); in __libelf_next_arhdr_wrlock()
841 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "//", 3); in __libelf_next_arhdr_wrlock()
848 if (unlikely (elf->state.ar.long_names == NULL in __libelf_next_arhdr_wrlock()
849 && read_long_names (elf) == NULL)) in __libelf_next_arhdr_wrlock()
858 if (unlikely (offset >= elf->state.ar.long_names_len)) in __libelf_next_arhdr_wrlock()
864 elf_ar_hdr->ar_name = elf->state.ar.long_names + offset; in __libelf_next_arhdr_wrlock()
878 endp = (char *) memccpy (elf->state.ar.ar_name, ar_hdr->ar_name, in __libelf_next_arhdr_wrlock()
888 elf->state.ar.ar_name[i] = '\0'; in __libelf_next_arhdr_wrlock()
889 while (i > 0 && elf->state.ar.ar_name[--i] == ' '); in __libelf_next_arhdr_wrlock()
892 elf_ar_hdr->ar_name = elf->state.ar.ar_name; in __libelf_next_arhdr_wrlock()
943 maxsize = (elf->start_offset + elf->maximum_size in __libelf_next_arhdr_wrlock()
944 - elf->state.ar.offset - sizeof (struct ar_hdr)); in __libelf_next_arhdr_wrlock()
1032 result->state.elf.scnincr = NSCNSALLOC; in write_file()
1037 result->state.elf.scns_last = &result->state.elf32.scns; in write_file()