/external/elfutils/libelf/ |
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 | 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_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 | 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_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 | elf_begin.c | 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() [all …]
|
D | elf32_updatefile.c | 128 __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) in __elfw2() 133 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in __elfw2() 136 if ((elf->state.ELFW(elf,LIBELFBITS).ehdr_flags | elf->flags) & ELF_F_DIRTY) in __elfw2() 150 (*fctp) ((char *) elf->map_address + elf->start_offset, ehdr, in __elfw2() 153 else if (elf->map_address + elf->start_offset != ehdr) in __elfw2() 154 memcpy (elf->map_address + elf->start_offset, ehdr, in __elfw2() 157 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags &= ~ELF_F_DIRTY; in __elfw2() 161 previous_scn_changed = elf->state.ELFW(elf,LIBELFBITS).phdr == NULL; in __elfw2() 165 if (unlikely (__elf_getphdrnum_rdlock (elf, &phnum) != 0)) in __elfw2() 169 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL in __elfw2() [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_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 | 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() 107 if (unlikely ((size_t) pread_retry (elf->fildes, rawchunk, size, in elf_getdata_rawchunk() [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 | 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 | 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 | 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 …]
|
/external/kmod/libkmod/ |
D | libkmod-elf.c | 73 #define ELFDBG(elf, ...) \ argument 74 _elf_dbg(elf, __FILE__, __LINE__, __func__, __VA_ARGS__); 76 static inline void _elf_dbg(const struct kmod_elf *elf, const char *fname, unsigned line, const cha… in _elf_dbg() argument 81 (elf->class & KMOD_ELF_32) ? 32 : 64, in _elf_dbg() 82 (elf->class & KMOD_ELF_MSB) ? 'M' : 'L', in _elf_dbg() 89 #define ELFDBG(elf, ...) argument 130 static inline uint64_t elf_get_uint(const struct kmod_elf *elf, uint64_t offset, uint16_t size) in elf_get_uint() argument 137 assert(offset + size <= elf->size); in elf_get_uint() 138 if (offset + size > elf->size) { in elf_get_uint() 139 ELFDBG(elf, "out of bounds: %"PRIu64" + %"PRIu16" = %"PRIu64"> %"PRIu64" (ELF size)\n", in elf_get_uint() [all …]
|
/external/elfutils/tests/ |
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 | 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 | 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 | run-annobingroup.sh | 28 tempfiles merged.elf stripped.elf debugfile1.elf debugfile2.elf debugfile3.elf remerged.elf 38 testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile1.elf testfile-annobingroup.o 40 testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF 48 testrun_compare ${abs_top_builddir}/src/readelf -g debugfile1.elf << EOF 56 testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile1.elf 58 testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF 66 testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup.o remerged.elf 84 testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile2.elf testfile-annobingroup-i386.o 86 testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF 97 testrun_compare ${abs_top_builddir}/src/readelf -g debugfile2.elf << EOF [all …]
|
/external/elfutils/libdwfl/ |
D | open.c | 49 decompress (int fd __attribute__ ((unused)), Elf **elf) in decompress() argument 55 const off_t offset = (*elf)->start_offset; in decompress() 56 void *const mapped = ((*elf)->map_address == NULL ? NULL in decompress() 57 : (*elf)->map_address + offset); in decompress() 58 const size_t mapped_size = (*elf)->maximum_size; in decompress() 86 elf_end (*elf); in decompress() 87 *elf = memelf; in decompress() 125 Elf *elf = elf_begin (*fdp, ELF_C_READ_MMAP_PRIVATE, NULL); in libdw_open_elf() local 128 Dwfl_Error error = what_kind (*fdp, &elf, &kind, &may_close_fd); in libdw_open_elf() 134 off_t offset = elf->start_offset; in libdw_open_elf() [all …]
|