/third_party/elfutils/libelf/ |
H A 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 in write_file() 168 elf_update(Elf *elf, Elf_Cmd cmd) elf_update() argument [all...] |
H A 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 in ElfW2() [all...] |
H A D | elf_newscn.c | 44 elf_newscn (Elf *elf) in elf_newscn() argument 49 if (elf == NULL) in elf_newscn() 52 /* We rely on the prefix of the `elf', `elf32', and `elf64' element 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 in elf_newscn() [all...] |
H A 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() 59 /* We rely here on the fact that the `elf' element is a common prefix 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 in elf_getshdrstrndx() [all...] |
H A 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 in elf_end() [all...] |
H A 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 in __libelf_readall() [all...] |
H A 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 in __elfw2() [all...] |
H A 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() 296 if the file handle or elf file is invalid. Returns zero if there in file_read_elf() 322 Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, in file_read_elf() local 324 if (elf in file_read_elf() 725 read_long_names(Elf *elf) read_long_names() argument 848 __libelf_next_arhdr_wrlock(Elf *elf) __libelf_next_arhdr_wrlock() argument [all...] |
H A 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 in ElfW2() [all...] |
H A 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 in ElfW2() [all...] |
H A 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 in __elf_getphdrnum_rdlock() 92 __elf_getphdrnum_chk_rdlock(Elf *elf, size_t *dst) __elf_getphdrnum_chk_rdlock() argument 133 elf_getphdrnum(Elf *elf, size_t *dst) elf_getphdrnum() argument [all...] |
H A 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 in elf_getarsym() [all...] |
H A 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 in ElfW2() [all...] |
H A 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 in __elf_getshdrnum_rdlock() 73 elf_getshdrnum(Elf *elf, size_t *dst) elf_getshdrnum() argument [all...] |
H A 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,LIBELFBIT in ElfW2() [all...] |
H A 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 in elf_getdata_rawchunk() [all...] |
H A 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 in elf_clone() [all...] |
H A 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, in gelf_getphdr() [all...] |
H A 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, in gelf_update_phdr() [all...] |
/third_party/elfutils/tests/ |
H A 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_NUL in test() 158 Elf *elf; main() local [all...] |
H A 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() 160 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL); read_elf() local 171 check_section_size(Elf *elf, size_t size) check_section_size() argument 199 check_section_data(Elf *elf, char *data, size_t len, size_t times) check_section_data() argument 254 Elf *elf = create_elf (fd, class, use_mmap); check_elf() local [all...] |
H A 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, nd in check_strings() 145 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL); check_elf() local [all...] |
H A D | fillfile.c | 32 #include ELFUTILS_HEADER(elf) 66 create_strtab (Elf *elf) in create_strtab() argument 69 Elf_Scn *scn = elf_newscn (elf); in create_strtab() 100 GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); in create_strtab() 110 if (gelf_update_ehdr (elf, ehdr) == 0) in create_strtab() 130 add_data_section (Elf *elf, Elf_Scn *strtab, const char *sname) in add_data_section() argument 133 Elf_Scn *scn = elf_newscn (elf); in add_data_section() 212 Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL); in check_elf() local 213 if (elf == NULL) in check_elf() 220 if (gelf_newehdr (elf, clas in check_elf() [all...] |
H A 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) in main() [all...] |
/third_party/elfutils/libdwfl/ |
H A 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 in libdw_open_elf() [all...] |