+2008-12-18 Roland McGrath <roland@redhat.com>
+
+ * derelocate.c (dwfl_module_relocate_address): Fix last fix: ET_DYN
+ addresses are taken as relative to MOD->low_addr.
+
2008-12-15 Roland McGrath <roland@redhat.com>
* derelocate.c (dwfl_module_relocate_address): Apply main.bias, not
return 1;
case ET_EXEC:
+ assert (mod->main.bias == 0);
assert (mod->debug.bias == 0);
break;
}
int
dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
{
- if (check_module (mod))
+ if (unlikely (check_module (mod)))
return -1;
- if (mod->e_type != ET_REL)
+ switch (mod->e_type)
{
- *addr -= mod->main.bias;
- return 0;
+ case ET_REL:
+ return find_section (mod, addr);
+
+ case ET_DYN:
+ /* All relative to first and only relocation base: module start. */
+ *addr -= mod->low_addr;
+ break;
+
+ default:
+ /* Already absolute, dwfl_module_relocations returned zero. We
+ shouldn't really have been called, but it's a harmless no-op. */
+ break;
}
- return find_section (mod, addr);
+ return 0;
}
INTDEF (dwfl_module_relocate_address)