/external/elfutils/libelf/ |
D | elf32_newphdr.c | 46 elfw2(LIBELFBITS,newphdr) (Elf *elf, size_t count) in ElfW2() 50 if (elf == NULL) in ElfW2() 53 if (unlikely (elf->kind != ELF_K_ELF)) in ElfW2() 65 rwlock_wrlock (elf->lock); in ElfW2() 67 if (elf->class == 0) in ElfW2() 68 elf->class = ELFW(ELFCLASS,LIBELFBITS); in ElfW2() 69 else if (unlikely (elf->class != ELFW(ELFCLASS,LIBELFBITS))) in ElfW2() 76 if (unlikely (elf->state.ELFW(elf,LIBELFBITS).ehdr == NULL)) in ElfW2() 87 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL) in ElfW2() 89 if (elf->state.ELFW(elf,LIBELFBITS).phdr_flags & ELF_F_MALLOCED) in ElfW2() [all …]
|
D | elf_update.c | 44 write_file (Elf *elf, off_t size, int change_bo, size_t shnum) in write_file() argument 46 int class = elf->class; in write_file() 50 if (unlikely (fstat (elf->fildes, &st) != 0)) in write_file() 61 if (elf->parent == NULL in write_file() 62 && (elf->maximum_size == ~((size_t) 0) in write_file() 63 || (size_t) size > elf->maximum_size) in write_file() 64 && unlikely (ftruncate (elf->fildes, size) != 0)) in write_file() 71 if (elf->map_address == NULL && elf->cmd == ELF_C_WRITE_MMAP) in write_file() 73 elf->map_address = mmap (NULL, size, PROT_READ | PROT_WRITE, in write_file() 74 MAP_SHARED, elf->fildes, 0); in write_file() [all …]
|
D | elf_newscn.c | 44 elf_newscn (Elf *elf) in elf_newscn() argument 49 if (elf == NULL) in elf_newscn() 54 assert (offsetof (Elf, state.elf.scns_last) in elf_newscn() 56 assert (offsetof (Elf, state.elf.scns_last) in elf_newscn() 61 rwlock_wrlock (elf->lock); in elf_newscn() 64 if (elf->state.elf.scns_last->cnt < elf->state.elf.scns_last->max) in elf_newscn() 66 result = &elf->state.elf.scns_last->data[elf->state.elf.scns_last->cnt]; in elf_newscn() 68 if (++elf->state.elf.scns_last->cnt == 1 in elf_newscn() 69 && (elf->state.elf.scns_last in elf_newscn() 70 == (elf->class == ELFCLASS32 in elf_newscn() [all …]
|
D | elf_end.c | 43 elf_end (Elf *elf) in elf_end() argument 47 if (elf == NULL) in elf_end() 52 rwlock_wrlock (elf->lock); in elf_end() 54 if (elf->ref_count != 0 && --elf->ref_count != 0) in elf_end() 57 int result = elf->ref_count; in elf_end() 58 rwlock_unlock (elf->lock); in elf_end() 62 if (elf->kind == ELF_K_AR) in elf_end() 70 if (elf->state.ar.ar_sym != (Elf_Arsym *) -1l) in elf_end() 71 free (elf->state.ar.ar_sym); in elf_end() 72 elf->state.ar.ar_sym = NULL; in elf_end() [all …]
|
D | elf_getshdrstrndx.c | 46 elf_getshdrstrndx (Elf *elf, size_t *dst) in elf_getshdrstrndx() argument 50 if (elf == NULL) in elf_getshdrstrndx() 53 if (unlikely (elf->kind != ELF_K_ELF)) in elf_getshdrstrndx() 59 rwlock_rdlock (elf->lock); in elf_getshdrstrndx() 63 assert (offsetof (struct Elf, state.elf.ehdr) in elf_getshdrstrndx() 65 assert (sizeof (elf->state.elf.ehdr) in elf_getshdrstrndx() 66 == sizeof (elf->state.elf32.ehdr)); in elf_getshdrstrndx() 67 assert (offsetof (struct Elf, state.elf.ehdr) in elf_getshdrstrndx() 69 assert (sizeof (elf->state.elf.ehdr) in elf_getshdrstrndx() 70 == sizeof (elf->state.elf64.ehdr)); in elf_getshdrstrndx() [all …]
|
D | elf_readall.c | 44 set_address (Elf *elf, size_t offset) in set_address() argument 46 if (elf->kind == ELF_K_AR) in set_address() 48 Elf *child = elf->state.ar.children; in set_address() 54 child->map_address = elf->map_address; in set_address() 70 __libelf_readall (Elf *elf) in __libelf_readall() argument 73 rwlock_wrlock (elf->lock); in __libelf_readall() 75 if (elf->map_address == NULL && unlikely (elf->fildes == -1)) in __libelf_readall() 78 rwlock_unlock (elf->lock); in __libelf_readall() 83 if (elf->map_address == NULL) in __libelf_readall() 89 libelf_acquire_all (elf); in __libelf_readall() [all …]
|
D | elf32_getphdr.c | 49 __elfw2(LIBELFBITS,getphdr_wrlock) (Elf *elf) in ElfW2() 56 result = elf->state.ELFW(elf,LIBELFBITS).phdr; in ElfW2() 60 if (elf->class == 0) in ElfW2() 61 elf->class = ELFW(ELFCLASS,LIBELFBITS); in ElfW2() 62 else if (elf->class != ELFW(ELFCLASS,LIBELFBITS)) in ElfW2() 72 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in ElfW2() 76 if (__elf_getphdrnum_rdlock (elf, &phnum) != 0) in ElfW2() 88 || ehdr->e_phoff > elf->maximum_size in ElfW2() 89 || elf->maximum_size - ehdr->e_phoff < size) in ElfW2() 95 if (elf->map_address != NULL) in ElfW2() [all …]
|
D | elf_begin.c | 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() [all …]
|
D | elf_getarsym.c | 50 read_number_entries (uint64_t *nump, Elf *elf, size_t *offp, bool index64_p) in read_number_entries() argument 59 if (elf->map_address != NULL) in read_number_entries() 62 memcpy (&u, elf->map_address + *offp, sizeof u); in read_number_entries() 63 else if ((size_t) pread_retry (elf->fildes, &u, w, *offp) != w) in read_number_entries() 77 elf_getarsym (Elf *elf, size_t *ptr) in elf_getarsym() argument 79 if (elf->kind != ELF_K_AR) in elf_getarsym() 89 *ptr = elf->state.ar.ar_sym_num; in elf_getarsym() 91 if (elf->state.ar.ar_sym == (Elf_Arsym *) -1l) in elf_getarsym() 98 Elf_Arsym *result = elf->state.ar.ar_sym; in elf_getarsym() 102 rwlock_wrlock (elf->lock); in elf_getarsym() [all …]
|
D | elf_getphdrnum.c | 42 __elf_getphdrnum_rdlock (Elf *elf, size_t *dst) in __elf_getphdrnum_rdlock() argument 44 if (unlikely (elf->state.elf64.ehdr == NULL)) in __elf_getphdrnum_rdlock() 51 *dst = (elf->class == ELFCLASS32 in __elf_getphdrnum_rdlock() 52 ? elf->state.elf32.ehdr->e_phnum in __elf_getphdrnum_rdlock() 53 : elf->state.elf64.ehdr->e_phnum); in __elf_getphdrnum_rdlock() 57 const Elf_ScnList *const scns = (elf->class == ELFCLASS32 in __elf_getphdrnum_rdlock() 58 ? &elf->state.elf32.scns in __elf_getphdrnum_rdlock() 59 : &elf->state.elf64.scns); in __elf_getphdrnum_rdlock() 64 if (elf->class == ELFCLASS32) in __elf_getphdrnum_rdlock() 67 && elf->state.elf32.scns.data[0].shdr.e32 != NULL)) in __elf_getphdrnum_rdlock() [all …]
|
D | elf32_updatefile.c | 129 __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) in __elfw2() 134 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in __elfw2() 137 if ((elf->state.ELFW(elf,LIBELFBITS).ehdr_flags | elf->flags) & ELF_F_DIRTY) in __elfw2() 156 (*fctp) ((char *) elf->map_address + elf->start_offset, ehdr, in __elfw2() 159 else if (elf->map_address + elf->start_offset != ehdr) in __elfw2() 160 memcpy (elf->map_address + elf->start_offset, ehdr, in __elfw2() 163 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags &= ~ELF_F_DIRTY; in __elfw2() 167 previous_scn_changed = elf->state.ELFW(elf,LIBELFBITS).phdr == NULL; in __elfw2() 171 if (unlikely (__elf_getphdrnum_rdlock (elf, &phnum) != 0)) in __elfw2() 175 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL in __elfw2() [all …]
|
D | elf32_getshdr.c | 54 Elf *elf = scn->elf; in ElfW2() local 55 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in ElfW2() 63 if (__elf_getshdrnum_rdlock (elf, &shnum) != 0 in ElfW2() 70 ElfW2(LIBELFBITS,Shdr) *shdr = elf->state.ELFW(elf,LIBELFBITS).shdr = in ElfW2() 72 if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL) in ElfW2() 77 elf->state.ELFW(elf,LIBELFBITS).shdr_malloced = 1; in ElfW2() 79 if (elf->map_address != NULL) in ElfW2() 83 if (unlikely (ehdr->e_shoff >= elf->maximum_size) in ElfW2() 84 || unlikely (elf->maximum_size - ehdr->e_shoff < size)) in ElfW2() 97 void *file_shdr = ((char *) elf->map_address in ElfW2() [all …]
|
D | elf32_newehdr.c | 45 elfw2(LIBELFBITS,newehdr) (Elf *elf) in ElfW2() 49 if (elf == NULL) in ElfW2() 52 if (unlikely (elf->kind != ELF_K_ELF)) in ElfW2() 58 rwlock_wrlock (elf->lock); in ElfW2() 60 if (elf->class == 0) in ElfW2() 61 elf->class = ELFW(ELFCLASS,LIBELFBITS); in ElfW2() 62 else if (unlikely (elf->class != ELFW(ELFCLASS,LIBELFBITS))) in ElfW2() 70 if (elf->state.ELFW(elf,LIBELFBITS).ehdr == NULL) in ElfW2() 73 elf->state.ELFW(elf,LIBELFBITS).ehdr = in ElfW2() 74 &elf->state.ELFW(elf,LIBELFBITS).ehdr_mem; in ElfW2() [all …]
|
D | elf_getshdrnum.c | 43 __elf_getshdrnum_rdlock (Elf *elf, size_t *dst) in __elf_getshdrnum_rdlock() argument 48 if (elf == NULL) in __elf_getshdrnum_rdlock() 51 if (unlikely (elf->kind != ELF_K_ELF)) in __elf_getshdrnum_rdlock() 57 idx = elf->state.elf.scns_last->cnt; in __elf_getshdrnum_rdlock() 59 || (elf->state.elf.scns_last in __elf_getshdrnum_rdlock() 60 != (elf->class == ELFCLASS32 in __elf_getshdrnum_rdlock() 63 ? &elf->state.elf32.scns : &elf->state.elf64.scns))) in __elf_getshdrnum_rdlock() 65 *dst = 1 + elf->state.elf.scns_last->data[idx - 1].index; in __elf_getshdrnum_rdlock() 73 elf_getshdrnum (Elf *elf, size_t *dst) in elf_getshdrnum() argument 77 if (elf == NULL) in elf_getshdrnum() [all …]
|
D | elf32_getehdr.c | 45 getehdr_impl (Elf *elf, int wrlock) in ElfW2() 47 if (elf == NULL) in ElfW2() 50 if (unlikely (elf->kind != ELF_K_ELF)) in ElfW2() 57 if (elf->class == 0) in ElfW2() 61 rwlock_unlock (elf->lock); in ElfW2() 62 rwlock_wrlock (elf->lock); in ElfW2() 66 elf->class = ELFW(ELFCLASS,LIBELFBITS); in ElfW2() 68 else if (unlikely (elf->class != ELFW(ELFCLASS,LIBELFBITS))) in ElfW2() 74 return elf->state.ELFW(elf,LIBELFBITS).ehdr; in ElfW2() 79 __elfw2(LIBELFBITS,getehdr_wrlock) (Elf *elf) in ElfW2() [all …]
|
D | elf_clone.c | 41 elf_clone (Elf *elf, Elf_Cmd cmd) in elf_clone() argument 45 if (elf == NULL) in elf_clone() 50 rwlock_rdlock (elf->lock); in elf_clone() 56 retval = allocate_elf (elf->fildes, elf->map_address, elf->start_offset, in elf_clone() 57 elf->maximum_size, elf->cmd, elf->parent, elf->kind, in elf_clone() 58 elf->state.elf32.scns.max * sizeof (Elf_Scn)); in elf_clone() 65 retval->state.elf.scnincr = 10; in elf_clone() 70 retval->state.elf.scns_last = &retval->state.elf32.scns; in elf_clone() 71 retval->state.elf32.scns.max = elf->state.elf32.scns.max; in elf_clone() 73 retval->class = elf->class; in elf_clone() [all …]
|
D | elf_getdata_rawchunk.c | 44 elf_getdata_rawchunk (Elf *elf, off_t offset, size_t size, Elf_Type type) in elf_getdata_rawchunk() argument 46 if (unlikely (elf == NULL)) in elf_getdata_rawchunk() 49 if (unlikely (elf->kind != ELF_K_ELF)) in elf_getdata_rawchunk() 56 if (unlikely (offset < 0 || (uint64_t) offset > elf->maximum_size in elf_getdata_rawchunk() 57 || elf->maximum_size - (uint64_t) offset < size)) in elf_getdata_rawchunk() 76 rwlock_rdlock (elf->lock); in elf_getdata_rawchunk() 78 size_t align = __libelf_type_align (elf->class, type); in elf_getdata_rawchunk() 79 if (elf->map_address != NULL) in elf_getdata_rawchunk() 82 char *rawdata = elf->map_address + elf->start_offset + offset; in elf_getdata_rawchunk() 108 if (unlikely ((size_t) pread_retry (elf->fildes, rawchunk, size, in elf_getdata_rawchunk() [all …]
|
D | elf32_updatenull.c | 51 ELFW(default_ehdr,LIBELFBITS) (Elf *elf, ElfW2(LIBELFBITS,Ehdr) *ehdr, in ELFW() 58 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 63 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 70 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 85 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 90 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 101 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 105 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 110 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 118 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() [all …]
|
D | gelf_update_phdr.c | 41 gelf_update_phdr (Elf *elf, int ndx, GElf_Phdr *src) in gelf_update_phdr() argument 45 if (elf == NULL) in gelf_update_phdr() 48 if (unlikely (elf->kind != ELF_K_ELF)) in gelf_update_phdr() 54 rwlock_wrlock (elf->lock); in gelf_update_phdr() 56 if (elf->class == ELFCLASS32) in gelf_update_phdr() 58 Elf32_Phdr *phdr = elf->state.elf32.phdr; in gelf_update_phdr() 76 phdr = __elf32_getphdr_wrlock (elf); in gelf_update_phdr() 84 if (ndx >= elf->state.elf32.ehdr->e_phnum in gelf_update_phdr() 85 && (elf->state.elf32.ehdr->e_phnum != PN_XNUM in gelf_update_phdr() 86 || __elf_getphdrnum_rdlock (elf, &phnum) != 0 in gelf_update_phdr() [all …]
|
D | gelf_getphdr.c | 42 gelf_getphdr (Elf *elf, int ndx, GElf_Phdr *dst) in gelf_getphdr() argument 46 if (elf == NULL) in gelf_getphdr() 49 if (unlikely (elf->kind != ELF_K_ELF)) in gelf_getphdr() 61 rwlock_rdlock (elf->lock); in gelf_getphdr() 63 if (elf->class == ELFCLASS32) in gelf_getphdr() 66 Elf32_Phdr *phdr = elf->state.elf32.phdr; in gelf_getphdr() 70 rwlock_unlock (elf->lock); in gelf_getphdr() 71 phdr = INTUSE(elf32_getphdr) (elf); in gelf_getphdr() 75 rwlock_rdlock (elf->lock); in gelf_getphdr() 80 if (__elf_getphdrnum_chk_rdlock (elf, &phnum) != 0 in gelf_getphdr() [all …]
|
/external/elfutils/tests/ |
D | elfshphehdr.c | 20 #include ELFUTILS_HEADER(elf) 58 test (Elf *elf, int class, bool layout) in test() argument 62 check_elf ("gelf_newehdr", gelf_newehdr (elf, class) != 0); in test() 63 check_elf ("gelf_getclass", gelf_getclass (elf) == class); in test() 65 check_elf ("elf_flagelf", elf_flagelf (elf, layout ? ELF_C_SET : ELF_C_CLR, in test() 69 check_elf ("gelf_getehdr", gelf_getehdr (elf, &ehdr) != NULL); in test() 76 check_elf ("elf_getshdrnum", elf_getshdrnum (elf, &shnum) == 0); in test() 80 check_elf ("elf_getphdrnum", elf_getphdrnum (elf, &phnum) == 0); in test() 88 check_elf ("gelf_update_ehdr", gelf_update_ehdr (elf, &ehdr) != 0); in test() 90 check_elf ("elf_update", elf_update (elf, ELF_C_NULL) > 0); in test() [all …]
|
D | newdata.c | 30 #include ELFUTILS_HEADER(elf) 38 add_section_data (Elf *elf, char *buf, size_t len) in add_section_data() argument 42 Elf_Scn *scn = elf_getscn (elf, 1); in add_section_data() 63 if (elf_update (elf, ELF_C_NULL) < 0) in add_section_data() 74 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL); in create_elf() local 75 if (elf == NULL) in create_elf() 82 if (gelf_newehdr (elf, class) == 0) in create_elf() 89 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); in create_elf() 104 if (gelf_update_ehdr (elf, ehdr) == 0) in create_elf() 111 Elf_Scn *scn = elf_newscn (elf); in create_elf() [all …]
|
D | elfstrtab.c | 30 #include ELFUTILS_HEADER(elf) 54 check_orig_strings (Elf *elf, int ndx, const char *msg) in check_orig_strings() argument 58 const char *str = elf_strptr (elf, ndx, 0); in check_orig_strings() 63 str = elf_strptr (elf, ndx, 1); in check_orig_strings() 68 str = elf_strptr (elf, ndx, orig_str1_off); in check_orig_strings() 73 str = elf_strptr (elf, ndx, orig_str2_off); in check_orig_strings() 78 str = elf_strptr (elf, ndx, orig_str3_off); in check_orig_strings() 85 check_strings (Elf *elf, int ndx, const char *msg) in check_strings() argument 87 check_orig_strings (elf, ndx, msg); in check_strings() 89 const char *str = elf_strptr (elf, ndx, str1_off); in check_strings() [all …]
|
D | showptable.c | 30 Elf *elf; in main() local 50 elf = elf_begin (fd, ELF_C_READ, NULL); in main() 51 if (elf == NULL) in main() 57 if (elf_kind (elf) != ELF_K_ELF) in main() 63 if (gelf_getehdr (elf, &ehdr) == NULL) in main() 70 gelf_getclass (elf) == ELFCLASS32 ? 9 : 17, "offset", in main() 71 gelf_getclass (elf) == ELFCLASS32 ? 10 : 18, "vaddr", in main() 72 gelf_getclass (elf) == ELFCLASS32 ? 10 : 18, "paddr", in main() 73 gelf_getclass (elf) == ELFCLASS32 ? 9 : 12, "filesz", in main() 74 gelf_getclass (elf) == ELFCLASS32 ? 9 : 12, "memsz"); in main() [all …]
|
/external/elfutils/libdwfl/ |
D | open.c | 45 decompress (int fd __attribute__ ((unused)), Elf **elf) in decompress() argument 51 const off_t offset = (*elf)->start_offset; in decompress() 52 void *const mapped = ((*elf)->map_address == NULL ? NULL in decompress() 53 : (*elf)->map_address + offset); in decompress() 54 const size_t mapped_size = (*elf)->maximum_size; in decompress() 82 elf_end (*elf); in decompress() 83 *elf = memelf; in decompress() 120 Elf *elf = elf_begin (*fdp, ELF_C_READ_MMAP_PRIVATE, NULL); in __libdw_open_file() local 123 Dwfl_Error error = what_kind (*fdp, &elf, &kind, &close_fd); in __libdw_open_file() 129 off_t offset = elf->start_offset; in __libdw_open_file() [all …]
|