Lines Matching defs:elf

42 open_elf_file (Elf **elf, int *fd, char **name)
44 if (*elf == NULL)
58 return __libdw_open_file (fd, elf, true, false);
60 else if (unlikely (elf_kind (*elf) != ELF_K_ELF))
62 elf_end (*elf);
63 *elf = NULL;
74 When we return success, FILE->elf and FILE->vaddr are set up. */
78 Dwfl_Error error = open_elf_file (&file->elf, &file->fd, &file->name);
82 GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (file->elf, &ehdr_mem);
86 elf_end (file->elf);
87 file->elf = NULL;
128 if (unlikely (elf_getphdrnum (file->elf, &phnum) != 0))
135 GElf_Phdr *ph = gelf_getphdr (file->elf, i, &ph_mem);
164 assert (mod->main.elf != NULL);
177 mod->main.elf), 2))
197 elf_end (mod->main.elf);
198 mod->main.elf = NULL;
207 When we return success, MOD->main.elf and MOD->main.bias are set up. */
212 if (mod->main.elf != NULL /* Already done. */
218 &mod->main.elf);
219 const bool fallback = mod->main.elf == NULL && mod->main.fd < 0;
277 if (elf_getshdrstrndx (mod->main.elf, &shstrndx) < 0)
281 while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
291 const char *secname = elf_strptr (mod->main.elf, shstrndx,
324 src.d_size = gelf_fsize (mod->main.elf, ELF_T_EHDR, 1, EV_CURRENT);
326 if (unlikely (gelf_xlatetom (mod->main.elf, &dst, &src,
327 elf_getident (mod->main.elf, NULL)[EI_DATA])
331 size_t shentsize = gelf_fsize (mod->main.elf, ELF_T_SHDR, 1, EV_CURRENT);
332 size_t phentsize = gelf_fsize (mod->main.elf, ELF_T_PHDR, 1, EV_CURRENT);
374 if (unlikely (elf_getphdrnum (mod->main.elf, &main_phnum)))
379 if (unlikely (gelf_getphdr (mod->main.elf, i, &phdr) == NULL))
405 if (unlikely (gelf_xlatetom (mod->main.elf, &dst, &src,
439 src.d_size = gelf_fsize (mod->main.elf, ELF_T_SHDR, shnum, EV_CURRENT);
450 if (unlikely (gelf_xlatetom (mod->main.elf, &dst, &src,
477 while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
530 if (mod->debug.elf != NULL)
535 debuglink_file = INTUSE(dwelf_elf_gnu_debuglink) (mod->main.elf,
609 while ((scn = elf_nextscn (file->elf, scn)) != NULL)
666 find_offsets (Elf *elf, GElf_Addr main_bias, size_t phnum, size_t n,
673 GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
708 find_offsets (mod->main.elf, adjust, phnum, i_max, addrs, offs);
716 Elf_Data *data = elf_getdata_rawchunk (mod->main.elf,
737 Elf_Data *data = elf_getdata_rawchunk (mod->main.elf, offs[i_gnu_hash],
745 + (gelf_getclass (mod->main.elf)
756 data = elf_getdata_rawchunk (mod->main.elf, buckets_at,
772 data = elf_getdata_rawchunk (mod->main.elf,
791 / gelf_fsize (mod->main.elf,
796 mod->symdata = elf_getdata_rawchunk (mod->main.elf,
798 gelf_fsize (mod->main.elf,
805 mod->symstrdata = elf_getdata_rawchunk (mod->main.elf,
827 GElf_Ehdr *ehdr = gelf_getehdr (mod->main.elf, &ehdr_mem);
830 if (unlikely (elf_getphdrnum (mod->main.elf, &phnum) != 0))
836 GElf_Phdr *phdr = gelf_getphdr (mod->main.elf, i, &phdr_mem);
844 Elf_Data *data = elf_getdata_rawchunk (mod->main.elf,
852 size_t n = data->d_size / gelf_fsize (mod->main.elf,
908 /* Don't trust the phdrs in the minisymtab elf file to be setup correctly.
915 if (unlikely (gelf_getehdr (mod->main.elf, &ehdr_main) == NULL)
916 || unlikely (gelf_getehdr (mod->aux_sym.elf, &ehdr_aux) == NULL))
929 /* Try to find the auxiliary symbol table embedded in the main elf file
941 Elf *elf = mod->main.elf;
944 if (elf_getshdrstrndx (elf, &shstrndx) < 0)
948 while ((scn = elf_nextscn (elf, scn)) != NULL)
955 const char *name = elf_strptr (elf, shstrndx, shdr->sh_name);
983 mod->aux_sym.elf = elf_memory (buffer, size);
984 if (mod->aux_sym.elf == NULL)
989 mod->aux_sym.elf->flags |= ELF_F_MALLOCED;
994 elf_end (mod->aux_sym.elf);
995 mod->aux_sym.elf = NULL;
1002 while ((scn = elf_nextscn (mod->aux_sym.elf, scn)) != NULL)
1039 elf_end (mod->aux_sym.elf);
1040 mod->aux_sym.elf = NULL;
1050 /* Try to find a symbol table in either MOD->main.elf or MOD->debug.elf. */
1131 if (elf_strptr (mod->symfile->elf, strshndx, 0) == NULL)
1147 Elf_Scn *symstrscn = elf_getscn (mod->symfile->elf, strshndx);
1157 if (elf_getshdrstrndx (mod->symfile->elf, &shstrndx) < 0)
1160 const char *sname = elf_strptr (mod->symfile->elf, shstrndx, shdr->sh_name);
1218 if (elf_strptr (mod->aux_sym.elf, aux_strshndx, 0) == NULL)
1222 elf_end (mod->aux_sym.elf);
1223 mod->aux_sym.elf = NULL;
1230 Elf_Scn *aux_strscn = elf_getscn (mod->aux_sym.elf, aux_strshndx);
1239 if (elf_getshdrstrndx (mod->aux_sym.elf, &aux_shstrndx) < 0)
1242 sname = elf_strptr (mod->aux_sym.elf, aux_shstrndx,
1310 mod->ebl = ebl_openbackend (mod->main.elf);
1336 result = __libdwfl_relocate (mod, debugfile->elf, true);
1341 mod->dw = INTUSE(dwarf_begin_elf) (debugfile->elf, DWARF_C_READ, NULL);
1352 if (mod->main.fd != -1 && elf_cntl (mod->main.elf, ELF_C_FDREAD) == 0)
1357 if (debugfile->fd != -1 && elf_cntl (debugfile->elf, ELF_C_FDREAD) == 0)
1395 mod->debug.elf = mod->main.elf;
1455 if (mod->debug.elf != mod->main.elf)
1456 (void) __libdwfl_relocate (mod, mod->debug.elf, false);