/external/elfutils/libelf/ |
D | elf_update.c | 42 write_file (Elf *elf, int64_t size, int change_bo, size_t shnum) in write_file() argument 44 int class = elf->class; in write_file() 48 if (unlikely (fstat (elf->fildes, &st) != 0)) in write_file() 59 if (elf->parent == NULL in write_file() 60 && (elf->maximum_size == ~((size_t) 0) in write_file() 61 || (size_t) size > elf->maximum_size) in write_file() 62 && unlikely (ftruncate (elf->fildes, size) != 0)) in write_file() 69 if (elf->map_address == NULL && elf->cmd == ELF_C_WRITE_MMAP) in write_file() 71 elf->map_address = mmap (NULL, size, PROT_READ | PROT_WRITE, in write_file() 72 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() 68 rwlock_wrlock (elf->lock); in ElfW2() 70 if (elf->class == 0) in ElfW2() 71 elf->class = ELFW(ELFCLASS,LIBELFBITS); in ElfW2() 72 else if (unlikely (elf->class != ELFW(ELFCLASS,LIBELFBITS))) in ElfW2() 79 if (unlikely (elf->state.ELFW(elf,LIBELFBITS).ehdr == NULL)) in ElfW2() 90 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL) in ElfW2() 92 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 | 42 elf_end (Elf *elf) in elf_end() argument 46 if (elf == NULL) in elf_end() 51 rwlock_wrlock (elf->lock); in elf_end() 53 if (elf->ref_count != 0 && --elf->ref_count != 0) in elf_end() 56 int result = elf->ref_count; in elf_end() 57 rwlock_unlock (elf->lock); in elf_end() 61 if (elf->kind == ELF_K_AR) in elf_end() 69 if (elf->state.ar.ar_sym != (Elf_Arsym *) -1l) in elf_end() 70 free (elf->state.ar.ar_sym); in elf_end() 71 elf->state.ar.ar_sym = NULL; in elf_end() [all …]
|
D | elf_getshdrstrndx.c | 44 elf_getshdrstrndx (Elf *elf, size_t *dst) in elf_getshdrstrndx() argument 48 if (elf == NULL) in elf_getshdrstrndx() 51 if (unlikely (elf->kind != ELF_K_ELF)) in elf_getshdrstrndx() 57 rwlock_rdlock (elf->lock); in elf_getshdrstrndx() 61 assert (offsetof (struct Elf, state.elf.ehdr) in elf_getshdrstrndx() 63 assert (sizeof (elf->state.elf.ehdr) in elf_getshdrstrndx() 64 == sizeof (elf->state.elf32.ehdr)); in elf_getshdrstrndx() 65 assert (offsetof (struct Elf, state.elf.ehdr) in elf_getshdrstrndx() 67 assert (sizeof (elf->state.elf.ehdr) in elf_getshdrstrndx() 68 == sizeof (elf->state.elf64.ehdr)); in elf_getshdrstrndx() [all …]
|
D | elf_readall.c | 42 set_address (Elf *elf, size_t offset) in set_address() argument 44 if (elf->kind == ELF_K_AR) in set_address() 46 Elf *child = elf->state.ar.children; in set_address() 52 child->map_address = elf->map_address; in set_address() 68 __libelf_readall (Elf *elf) in __libelf_readall() argument 71 rwlock_wrlock (elf->lock); in __libelf_readall() 73 if (elf->map_address == NULL && unlikely (elf->fildes == -1)) in __libelf_readall() 76 rwlock_unlock (elf->lock); in __libelf_readall() 81 if (elf->map_address == NULL) in __libelf_readall() 87 libelf_acquire_all (elf); in __libelf_readall() [all …]
|
D | elf32_getphdr.c | 47 __elfw2(LIBELFBITS,getphdr_wrlock) (Elf *elf) in ElfW2() 54 result = elf->state.ELFW(elf,LIBELFBITS).phdr; in ElfW2() 58 if (elf->class == 0) in ElfW2() 59 elf->class = ELFW(ELFCLASS,LIBELFBITS); in ElfW2() 60 else if (elf->class != ELFW(ELFCLASS,LIBELFBITS)) in ElfW2() 70 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in ElfW2() 74 if (__elf_getphdrnum_rdlock (elf, &phnum) != 0) in ElfW2() 86 || ehdr->e_phoff > elf->maximum_size in ElfW2() 87 || elf->maximum_size - ehdr->e_phoff < size) in ElfW2() 93 if (elf->map_address != NULL) in ElfW2() [all …]
|
D | elf_begin.c | 53 Elf *elf; in file_read_ar() local 56 elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_ar() 58 if (elf != NULL) in file_read_ar() 62 elf->state.ar.offset = offset + SARMAG; in file_read_ar() 64 elf->state.ar.elf_ar_hdr.ar_rawname = elf->state.ar.raw_name; in file_read_ar() 67 return elf; in file_read_ar() 322 Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_elf() local 324 if (elf == NULL) in file_read_elf() 331 elf->state.elf32.scns.cnt = scncnt; in file_read_elf() 332 elf->state.elf32.scns.max = scnmax; in file_read_elf() [all …]
|
D | elf_getarsym.c | 46 read_number_entries (uint64_t *nump, Elf *elf, size_t *offp, bool index64_p) in read_number_entries() argument 55 if (elf->map_address != NULL) in read_number_entries() 58 memcpy (&u, elf->map_address + *offp, sizeof u); in read_number_entries() 59 else if ((size_t) pread_retry (elf->fildes, &u, w, *offp) != w) in read_number_entries() 73 elf_getarsym (Elf *elf, size_t *ptr) in elf_getarsym() argument 75 if (elf->kind != ELF_K_AR) in elf_getarsym() 85 *ptr = elf->state.ar.ar_sym_num; in elf_getarsym() 87 if (elf->state.ar.ar_sym == (Elf_Arsym *) -1l) in elf_getarsym() 94 Elf_Arsym *result = elf->state.ar.ar_sym; in elf_getarsym() 98 rwlock_wrlock (elf->lock); in elf_getarsym() [all …]
|
D | elf32_updatefile.c | 125 __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) in __elfw2() 130 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in __elfw2() 133 if ((elf->state.ELFW(elf,LIBELFBITS).ehdr_flags | elf->flags) & ELF_F_DIRTY) in __elfw2() 147 (*fctp) ((char *) elf->map_address + elf->start_offset, ehdr, in __elfw2() 150 else if (elf->map_address + elf->start_offset != ehdr) in __elfw2() 151 memcpy (elf->map_address + elf->start_offset, ehdr, in __elfw2() 154 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags &= ~ELF_F_DIRTY; in __elfw2() 158 previous_scn_changed = elf->state.ELFW(elf,LIBELFBITS).phdr == NULL; in __elfw2() 162 if (unlikely (__elf_getphdrnum_rdlock (elf, &phnum) != 0)) in __elfw2() 166 if (elf->state.ELFW(elf,LIBELFBITS).phdr != NULL in __elfw2() [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() 52 *dst = (elf->class == ELFCLASS32 in __elf_getphdrnum_rdlock() 53 ? elf->state.elf32.ehdr->e_phnum in __elf_getphdrnum_rdlock() 54 : elf->state.elf64.ehdr->e_phnum); in __elf_getphdrnum_rdlock() 58 const Elf_ScnList *const scns = (elf->class == ELFCLASS32 in __elf_getphdrnum_rdlock() 59 ? &elf->state.elf32.scns in __elf_getphdrnum_rdlock() 60 : &elf->state.elf64.scns); in __elf_getphdrnum_rdlock() 65 if (elf->class == ELFCLASS32) in __elf_getphdrnum_rdlock() 69 Elf_Scn *scn = &elf->state.elf32.scns.data[0]; in __elf_getphdrnum_rdlock() [all …]
|
D | elf32_getshdr.c | 52 Elf *elf = scn->elf; in ElfW2() local 53 ElfW2(LIBELFBITS,Ehdr) *ehdr = elf->state.ELFW(elf,LIBELFBITS).ehdr; in ElfW2() 61 if (__elf_getshdrnum_rdlock (elf, &shnum) != 0 in ElfW2() 68 ElfW2(LIBELFBITS,Shdr) *shdr = elf->state.ELFW(elf,LIBELFBITS).shdr = in ElfW2() 70 if (elf->state.ELFW(elf,LIBELFBITS).shdr == NULL) in ElfW2() 75 elf->state.ELFW(elf,LIBELFBITS).shdr_malloced = 1; in ElfW2() 77 if (elf->map_address != NULL) in ElfW2() 81 if (unlikely (ehdr->e_shoff >= elf->maximum_size) in ElfW2() 82 || unlikely (elf->maximum_size - ehdr->e_shoff < size)) in ElfW2() 95 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 | 43 elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type) in elf_getdata_rawchunk() argument 45 if (unlikely (elf == NULL)) in elf_getdata_rawchunk() 48 if (unlikely (elf->kind != ELF_K_ELF)) in elf_getdata_rawchunk() 55 if (unlikely (offset < 0 || (uint64_t) offset > elf->maximum_size in elf_getdata_rawchunk() 56 || elf->maximum_size - (uint64_t) offset < size)) in elf_getdata_rawchunk() 75 rwlock_rdlock (elf->lock); in elf_getdata_rawchunk() 78 Elf_Data_Chunk *rawchunks = elf->state.elf.rawchunks; in elf_getdata_rawchunk() 91 size_t align = __libelf_type_align (elf->class, type); in elf_getdata_rawchunk() 92 if (elf->map_address != NULL) in elf_getdata_rawchunk() 95 char *rawdata = elf->map_address + elf->start_offset + offset; 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 | 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 | elf32_updatenull.c | 53 ELFW(default_ehdr,LIBELFBITS) (Elf *elf, ElfW2(LIBELFBITS,Ehdr) *ehdr, in ELFW() 60 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 65 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 72 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 87 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 92 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 103 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 107 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags); in ELFW() 112 elf->state.ELFW(elf,LIBELFBITS).ehdr_flags |= ELF_F_DIRTY; in ELFW() 120 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 …]
|
/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 | 31 #include ELFUTILS_HEADER(elf) 39 add_section_data (Elf *elf, char *buf, size_t len) in add_section_data() argument 43 Elf_Scn *scn = elf_getscn (elf, 1); in add_section_data() 64 if (elf_update (elf, ELF_C_NULL) < 0) in add_section_data() 75 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL); in create_elf() local 76 if (elf == NULL) in create_elf() 83 if (gelf_newehdr (elf, class) == 0) in create_elf() 90 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); in create_elf() 105 if (gelf_update_ehdr (elf, ehdr) == 0) in create_elf() 112 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 | 31 #include ELFUTILS_HEADER(elf) 55 check_orig_strings (Elf *elf, int ndx, const char *msg) in check_orig_strings() argument 59 const char *str = elf_strptr (elf, ndx, 0); in check_orig_strings() 64 str = elf_strptr (elf, ndx, 1); in check_orig_strings() 69 str = elf_strptr (elf, ndx, orig_str1_off); in check_orig_strings() 74 str = elf_strptr (elf, ndx, orig_str2_off); in check_orig_strings() 79 str = elf_strptr (elf, ndx, orig_str3_off); in check_orig_strings() 86 check_strings (Elf *elf, int ndx, const char *msg) in check_strings() argument 88 check_orig_strings (elf, ndx, msg); in check_strings() 90 const char *str = elf_strptr (elf, ndx, str1_off); in check_strings() [all …]
|
/external/crosvm/kernel_loader/src/ |
D | lib.rs | 27 mod elf; module 121 Some(elf::ELFCLASS32), in load_elf32() 150 Some(elf::ELFCLASS64), in load_elf64() 187 let elf = read_elf(kernel_image, ei_class)?; in load_elf_for_class() localVariable 192 for phdr in &elf.program_headers { in load_elf_for_class() 193 if phdr.p_type != elf::PT_LOAD { in load_elf_for_class() 238 let entry = elf in load_elf_for_class() 286 file_header: elf::Elf64_Ehdr, 287 program_headers: Vec<elf::Elf64_Phdr>, 304 if ident[elf::EI_MAG0 as usize] != elf::ELFMAG0 as u8 in read_elf() [all …]
|
/external/elfutils/libdwfl/ |
D | open.c | 52 decompress (int fd __attribute__ ((unused)), Elf **elf) in decompress() argument 61 const off_t offset = (*elf)->start_offset; in decompress() 62 void *const mapped = ((*elf)->map_address == NULL ? NULL in decompress() 63 : (*elf)->map_address + offset); in decompress() 64 const size_t mapped_size = (*elf)->maximum_size; in decompress() 94 elf_end (*elf); in decompress() 95 *elf = memelf; in decompress() 133 Elf *elf = in libdw_open_elf() local 137 Dwfl_Error error = what_kind (*fdp, &elf, &kind, &may_close_fd); in libdw_open_elf() 143 off_t offset = elf->start_offset; in libdw_open_elf() [all …]
|