Lines Matching refs:mod
80 cache_sections (Dwfl_Module *mod)
82 if (likely (mod->reloc_info != NULL))
83 return mod->reloc_info->count;
89 if (unlikely (elf_getshdrstrndx (mod->main.elf, &shstrndx) < 0))
99 while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
107 && mod->e_type == ET_REL)
110 if (__libdwfl_relocate_value (mod, mod->main.elf, &shstrndx,
121 const char *name = elf_strptr (mod->main.elf, shstrndx,
138 newref->start = dwfl_adjusted_address (mod, shdr->sh_addr);
145 if (mod->e_type == ET_REL
148 && mod->dwfl->callbacks->section_address != NULL)
153 Elf_Scn *tscn = elf_getscn (mod->main.elf, shdr->sh_info);
168 mod->reloc_info = malloc (offsetof (struct dwfl_relocation, refs[nrefs]));
169 if (unlikely (mod->reloc_info == NULL))
182 mod->reloc_info->count = nrefs;
185 mod->reloc_info->refs[i].name = sortrefs[i]->name;
186 mod->reloc_info->refs[i].scn = sortrefs[i]->scn;
187 mod->reloc_info->refs[i].relocs = sortrefs[i]->relocs;
188 mod->reloc_info->refs[i].start = sortrefs[i]->start;
189 mod->reloc_info->refs[i].end = sortrefs[i]->end;
202 while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
212 Elf_Scn *tscn = elf_getscn (mod->main.elf, shdr->sh_info);
215 if (mod->reloc_info->refs[i].scn == tscn)
217 mod->reloc_info->refs[i].relocs = scn;
237 dwfl_module_relocations (Dwfl_Module *mod)
239 if (mod == NULL)
242 switch (mod->e_type)
245 return cache_sections (mod);
251 assert (mod->main.vaddr == mod->low_addr);
259 dwfl_module_relocation_info (Dwfl_Module *mod, unsigned int idx,
262 if (mod == NULL)
265 switch (mod->e_type)
281 if (cache_sections (mod) < 0)
284 struct dwfl_relocation *sections = mod->reloc_info;
297 check_module (Dwfl_Module *mod)
299 if (mod == NULL)
302 if (INTUSE(dwfl_module_getsymtab) (mod) < 0)
312 if (mod->dw == NULL)
315 if (INTUSE(dwfl_module_getdwarf) (mod, &bias) == NULL)
331 find_section (Dwfl_Module *mod, Dwarf_Addr *addr)
333 if (cache_sections (mod) < 0)
336 struct dwfl_relocation *sections = mod->reloc_info;
368 __libdwfl_find_section_ndx (Dwfl_Module *mod, Dwarf_Addr *addr)
370 int idx = find_section (mod, addr);
374 return elf_ndxscn (mod->reloc_info->refs[idx].scn);
378 dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
380 if (unlikely (check_module (mod)))
383 switch (mod->e_type)
386 return find_section (mod, addr);
390 *addr -= mod->low_addr;
404 dwfl_module_address_section (Dwfl_Module *mod, Dwarf_Addr *address,
407 if (check_module (mod))
410 int idx = find_section (mod, address);
414 if (mod->reloc_info->refs[idx].relocs != NULL)
416 assert (mod->e_type == ET_REL);
418 Elf_Scn *tscn = mod->reloc_info->refs[idx].scn;
419 Elf_Scn *relocscn = mod->reloc_info->refs[idx].relocs;
420 Dwfl_Error result = __libdwfl_relocate_section (mod, mod->main.elf,
423 mod->reloc_info->refs[idx].relocs = NULL;
431 *bias = dwfl_adjusted_address (mod, 0);
432 return mod->reloc_info->refs[idx].scn;