Lines Matching refs:elf
55 Elf *elf; in file_read_ar() local
58 elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_ar()
60 if (elf != NULL) in file_read_ar()
64 elf->state.ar.offset = offset + SARMAG; in file_read_ar()
66 elf->state.ar.elf_ar_hdr.ar_rawname = elf->state.ar.raw_name; in file_read_ar()
69 return elf; in file_read_ar()
310 Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_elf() local
312 if (elf == NULL) in file_read_elf()
319 elf->state.elf32.scns.cnt = scncnt; in file_read_elf()
320 elf->state.elf32.scns.max = scnmax; in file_read_elf()
323 elf->state.elf.scnincr = 10; in file_read_elf()
326 elf->class = e_ident[EI_CLASS]; in file_read_elf()
340 elf->state.elf32.ehdr = ehdr; in file_read_elf()
345 elf->state.elf32.ehdr = memcpy (&elf->state.elf32.ehdr_mem, e_ident, in file_read_elf()
350 CONVERT (elf->state.elf32.ehdr_mem.e_type); in file_read_elf()
351 CONVERT (elf->state.elf32.ehdr_mem.e_machine); in file_read_elf()
352 CONVERT (elf->state.elf32.ehdr_mem.e_version); in file_read_elf()
353 CONVERT (elf->state.elf32.ehdr_mem.e_entry); in file_read_elf()
354 CONVERT (elf->state.elf32.ehdr_mem.e_phoff); in file_read_elf()
355 CONVERT (elf->state.elf32.ehdr_mem.e_shoff); in file_read_elf()
356 CONVERT (elf->state.elf32.ehdr_mem.e_flags); in file_read_elf()
357 CONVERT (elf->state.elf32.ehdr_mem.e_ehsize); in file_read_elf()
358 CONVERT (elf->state.elf32.ehdr_mem.e_phentsize); in file_read_elf()
359 CONVERT (elf->state.elf32.ehdr_mem.e_phnum); in file_read_elf()
360 CONVERT (elf->state.elf32.ehdr_mem.e_shentsize); in file_read_elf()
361 CONVERT (elf->state.elf32.ehdr_mem.e_shnum); in file_read_elf()
362 CONVERT (elf->state.elf32.ehdr_mem.e_shstrndx); in file_read_elf()
369 Elf32_Off e_shoff = elf->state.elf32.ehdr->e_shoff; in file_read_elf()
381 free (elf); in file_read_elf()
385 elf->state.elf32.shdr in file_read_elf()
390 elf->state.elf32.scns.data[cnt].index = cnt; in file_read_elf()
391 elf->state.elf32.scns.data[cnt].elf = elf; in file_read_elf()
392 elf->state.elf32.scns.data[cnt].shdr.e32 = in file_read_elf()
393 &elf->state.elf32.shdr[cnt]; in file_read_elf()
394 if (likely (elf->state.elf32.shdr[cnt].sh_offset < maxsize) in file_read_elf()
395 && likely (elf->state.elf32.shdr[cnt].sh_size in file_read_elf()
396 <= maxsize - elf->state.elf32.shdr[cnt].sh_offset)) in file_read_elf()
397 elf->state.elf32.scns.data[cnt].rawdata_base = in file_read_elf()
398 elf->state.elf32.scns.data[cnt].data_base = in file_read_elf()
400 + elf->state.elf32.shdr[cnt].sh_offset); in file_read_elf()
401 elf->state.elf32.scns.data[cnt].list = &elf->state.elf32.scns; in file_read_elf()
406 if (elf->state.elf32.shdr[cnt].sh_type == SHT_SYMTAB_SHNDX in file_read_elf()
407 && elf->state.elf32.shdr[cnt].sh_link < scncnt) in file_read_elf()
408 elf->state.elf32.scns.data[elf->state.elf32.shdr[cnt].sh_link].shndx_index in file_read_elf()
413 if (elf->state.elf32.scns.data[cnt].shndx_index == 0) in file_read_elf()
414 elf->state.elf32.scns.data[cnt].shndx_index = -1; in file_read_elf()
421 elf->state.elf32.scns.data[cnt].index = cnt; in file_read_elf()
422 elf->state.elf32.scns.data[cnt].elf = elf; in file_read_elf()
423 elf->state.elf32.scns.data[cnt].list = &elf->state.elf32.scns; in file_read_elf()
428 elf->state.elf32.scns_last = &elf->state.elf32.scns; in file_read_elf()
442 elf->state.elf64.ehdr = ehdr; in file_read_elf()
447 elf->state.elf64.ehdr = memcpy (&elf->state.elf64.ehdr_mem, e_ident, in file_read_elf()
452 CONVERT (elf->state.elf64.ehdr_mem.e_type); in file_read_elf()
453 CONVERT (elf->state.elf64.ehdr_mem.e_machine); in file_read_elf()
454 CONVERT (elf->state.elf64.ehdr_mem.e_version); in file_read_elf()
455 CONVERT (elf->state.elf64.ehdr_mem.e_entry); in file_read_elf()
456 CONVERT (elf->state.elf64.ehdr_mem.e_phoff); in file_read_elf()
457 CONVERT (elf->state.elf64.ehdr_mem.e_shoff); in file_read_elf()
458 CONVERT (elf->state.elf64.ehdr_mem.e_flags); in file_read_elf()
459 CONVERT (elf->state.elf64.ehdr_mem.e_ehsize); in file_read_elf()
460 CONVERT (elf->state.elf64.ehdr_mem.e_phentsize); in file_read_elf()
461 CONVERT (elf->state.elf64.ehdr_mem.e_phnum); in file_read_elf()
462 CONVERT (elf->state.elf64.ehdr_mem.e_shentsize); in file_read_elf()
463 CONVERT (elf->state.elf64.ehdr_mem.e_shnum); in file_read_elf()
464 CONVERT (elf->state.elf64.ehdr_mem.e_shstrndx); in file_read_elf()
471 Elf64_Off e_shoff = elf->state.elf64.ehdr->e_shoff; in file_read_elf()
482 elf->state.elf64.shdr in file_read_elf()
487 elf->state.elf64.scns.data[cnt].index = cnt; in file_read_elf()
488 elf->state.elf64.scns.data[cnt].elf = elf; in file_read_elf()
489 elf->state.elf64.scns.data[cnt].shdr.e64 = in file_read_elf()
490 &elf->state.elf64.shdr[cnt]; in file_read_elf()
491 if (likely (elf->state.elf64.shdr[cnt].sh_offset < maxsize) in file_read_elf()
492 && likely (elf->state.elf64.shdr[cnt].sh_size in file_read_elf()
493 <= maxsize - elf->state.elf64.shdr[cnt].sh_offset)) in file_read_elf()
494 elf->state.elf64.scns.data[cnt].rawdata_base = in file_read_elf()
495 elf->state.elf64.scns.data[cnt].data_base = in file_read_elf()
497 + elf->state.elf64.shdr[cnt].sh_offset); in file_read_elf()
498 elf->state.elf64.scns.data[cnt].list = &elf->state.elf64.scns; in file_read_elf()
503 if (elf->state.elf64.shdr[cnt].sh_type == SHT_SYMTAB_SHNDX in file_read_elf()
504 && elf->state.elf64.shdr[cnt].sh_link < scncnt) in file_read_elf()
505 elf->state.elf64.scns.data[elf->state.elf64.shdr[cnt].sh_link].shndx_index in file_read_elf()
510 if (elf->state.elf64.scns.data[cnt].shndx_index == 0) in file_read_elf()
511 elf->state.elf64.scns.data[cnt].shndx_index = -1; in file_read_elf()
518 elf->state.elf64.scns.data[cnt].index = cnt; in file_read_elf()
519 elf->state.elf64.scns.data[cnt].elf = elf; in file_read_elf()
520 elf->state.elf64.scns.data[cnt].list = &elf->state.elf64.scns; in file_read_elf()
525 elf->state.elf64.scns_last = &elf->state.elf64.scns; in file_read_elf()
528 return elf; in file_read_elf()
709 read_long_names (Elf *elf) in read_long_names() argument
719 if (elf->map_address != NULL) in read_long_names()
721 if ((size_t) offset > elf->maximum_size in read_long_names()
722 || elf->maximum_size - offset < sizeof (struct ar_hdr)) in read_long_names()
726 hdr = (struct ar_hdr *) (elf->map_address + offset); in read_long_names()
731 if (unlikely (pread_retry (elf->fildes, &hdrm, sizeof (hdrm), in read_long_names()
732 elf->start_offset + offset) in read_long_names()
758 if (elf->map_address != NULL) in read_long_names()
760 if (len > elf->maximum_size - offset - sizeof (struct ar_hdr)) in read_long_names()
772 if (elf->map_address != NULL) in read_long_names()
775 elf->state.ar.long_names = (char *) memcpy (newp, in read_long_names()
776 elf->map_address + offset in read_long_names()
782 if (unlikely ((size_t) pread_retry (elf->fildes, newp, len, in read_long_names()
783 elf->start_offset + offset in read_long_names()
789 elf->state.ar.long_names = NULL; in read_long_names()
792 elf->state.ar.long_names = newp; in read_long_names()
795 elf->state.ar.long_names_len = len; in read_long_names()
827 __libelf_next_arhdr_wrlock (Elf *elf) in __libelf_next_arhdr_wrlock() argument
832 if (elf->map_address != NULL) in __libelf_next_arhdr_wrlock()
835 if (unlikely ((size_t) elf->state.ar.offset in __libelf_next_arhdr_wrlock()
836 > elf->start_offset + elf->maximum_size in __libelf_next_arhdr_wrlock()
837 || (elf->start_offset + elf->maximum_size in __libelf_next_arhdr_wrlock()
838 - elf->state.ar.offset) < sizeof (struct ar_hdr))) in __libelf_next_arhdr_wrlock()
844 ar_hdr = (struct ar_hdr *) (elf->map_address + elf->state.ar.offset); in __libelf_next_arhdr_wrlock()
848 ar_hdr = &elf->state.ar.ar_hdr; in __libelf_next_arhdr_wrlock()
850 if (unlikely (pread_retry (elf->fildes, ar_hdr, sizeof (struct ar_hdr), in __libelf_next_arhdr_wrlock()
851 elf->state.ar.offset) in __libelf_next_arhdr_wrlock()
869 *((char *) mempcpy (elf->state.ar.raw_name, ar_hdr->ar_name, 16)) = '\0'; in __libelf_next_arhdr_wrlock()
871 elf_ar_hdr = &elf->state.ar.elf_ar_hdr; in __libelf_next_arhdr_wrlock()
880 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "/", 2); in __libelf_next_arhdr_wrlock()
884 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "/SYM64/", 8); in __libelf_next_arhdr_wrlock()
888 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "//", 3); in __libelf_next_arhdr_wrlock()
895 if (unlikely (elf->state.ar.long_names == NULL in __libelf_next_arhdr_wrlock()
896 && read_long_names (elf) == NULL)) in __libelf_next_arhdr_wrlock()
905 if (unlikely (offset >= elf->state.ar.long_names_len)) in __libelf_next_arhdr_wrlock()
911 elf_ar_hdr->ar_name = elf->state.ar.long_names + offset; in __libelf_next_arhdr_wrlock()
925 endp = (char *) memccpy (elf->state.ar.ar_name, ar_hdr->ar_name, in __libelf_next_arhdr_wrlock()
935 elf->state.ar.ar_name[i] = '\0'; in __libelf_next_arhdr_wrlock()
936 while (i > 0 && elf->state.ar.ar_name[--i] == ' '); in __libelf_next_arhdr_wrlock()
939 elf_ar_hdr->ar_name = elf->state.ar.ar_name; in __libelf_next_arhdr_wrlock()
990 maxsize = (elf->start_offset + elf->maximum_size in __libelf_next_arhdr_wrlock()
991 - elf->state.ar.offset - sizeof (struct ar_hdr)); in __libelf_next_arhdr_wrlock()
1079 result->state.elf.scnincr = NSCNSALLOC; in write_file()
1084 result->state.elf.scns_last = &result->state.elf32.scns; in write_file()