From: Roland McGrath Date: Thu, 18 Dec 2008 23:08:09 +0000 (-0800) Subject: Fix last fix: ET_DYN addresses are taken as relative to MOD->low_addr. X-Git-Tag: elfutils-0.138~16^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d9b821db6bc494417a57321b419c6b9481a2128;p=thirdparty%2Felfutils.git Fix last fix: ET_DYN addresses are taken as relative to MOD->low_addr. --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 9d86f52b4..274b97d35 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,8 @@ +2008-12-18 Roland McGrath + + * 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 * derelocate.c (dwfl_module_relocate_address): Apply main.bias, not diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c index 7f390c759..f2a64675e 100644 --- a/libdwfl/derelocate.c +++ b/libdwfl/derelocate.c @@ -238,6 +238,7 @@ dwfl_module_relocations (Dwfl_Module *mod) return 1; case ET_EXEC: + assert (mod->main.bias == 0); assert (mod->debug.bias == 0); break; } @@ -353,16 +354,26 @@ find_section (Dwfl_Module *mod, Dwarf_Addr *addr) 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)