Lines Matching refs:mod
91 cache_sections (Dwfl_Module *mod)
97 if (unlikely (elf_getshstrndx (mod->main.elf, &shstrndx) < 0))
106 while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
116 if (__libdwfl_relocate_value (mod, mod->main.elf, &shstrndx,
127 const char *name = elf_strptr (mod->main.elf, shstrndx,
136 newref->start = shdr->sh_addr + mod->main.bias;
143 if (mod->e_type == ET_REL
146 && mod->dwfl->callbacks->section_address != NULL)
151 Elf_Scn *tscn = elf_getscn (mod->main.elf, shdr->sh_info);
166 mod->reloc_info = malloc (offsetof (struct dwfl_relocation, refs[nrefs]));
167 if (mod->reloc_info == NULL)
180 mod->reloc_info->count = nrefs;
183 mod->reloc_info->refs[i].name = sortrefs[i]->name;
184 mod->reloc_info->refs[i].scn = sortrefs[i]->scn;
185 mod->reloc_info->refs[i].relocs = sortrefs[i]->relocs;
186 mod->reloc_info->refs[i].start = sortrefs[i]->start;
187 mod->reloc_info->refs[i].end = sortrefs[i]->end;
197 while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
207 Elf_Scn *tscn = elf_getscn (mod->main.elf, shdr->sh_info);
210 if (mod->reloc_info->refs[i].scn == tscn)
212 mod->reloc_info->refs[i].relocs = scn;
224 dwfl_module_relocations (Dwfl_Module *mod)
226 if (mod == NULL)
229 if (mod->reloc_info != NULL)
230 return mod->reloc_info->count;
232 switch (mod->e_type)
235 return cache_sections (mod);
241 assert (mod->main.bias == 0);
242 assert (mod->debug.bias == 0);
250 dwfl_module_relocation_info (Dwfl_Module *mod, unsigned int idx,
253 if (mod == NULL)
256 switch (mod->e_type)
272 if (unlikely (mod->reloc_info == NULL) && cache_sections (mod) < 0)
275 struct dwfl_relocation *sections = mod->reloc_info;
286 /* Check that MOD is valid and make sure its relocation has been done. */
288 check_module (Dwfl_Module *mod)
290 if (INTUSE(dwfl_module_getsymtab) (mod) < 0)
300 if (mod->dw == NULL)
303 if (INTUSE(dwfl_module_getdwarf) (mod, &bias) == NULL)
317 /* Find the index in MOD->reloc_info.refs containing *ADDR. */
319 find_section (Dwfl_Module *mod, Dwarf_Addr *addr)
321 if (unlikely (mod->reloc_info == NULL) && cache_sections (mod) < 0)
324 struct dwfl_relocation *sections = mod->reloc_info;
355 dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
357 if (unlikely (check_module (mod)))
360 switch (mod->e_type)
363 return find_section (mod, addr);
367 *addr -= mod->low_addr;
381 dwfl_module_address_section (Dwfl_Module *mod, Dwarf_Addr *address,
384 if (check_module (mod))
387 int idx = find_section (mod, address);
391 if (mod->reloc_info->refs[idx].relocs != NULL)
393 assert (mod->e_type == ET_REL);
395 Elf_Scn *tscn = mod->reloc_info->refs[idx].scn;
396 Elf_Scn *relocscn = mod->reloc_info->refs[idx].relocs;
397 Dwfl_Error result = __libdwfl_relocate_section (mod, mod->main.elf,
400 mod->reloc_info->refs[idx].relocs = NULL;
408 *bias = mod->main.bias;
409 return mod->reloc_info->refs[idx].scn;