This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dwfl_module_relocate_address() versus base address


When dwfl_module_info yields a dwbias of -1, that means there is no DWARF
info known (yet); also the debug file name (last arg) would be NULL.  This
means you haven't asked for DWARF for this module yet, or that no debuginfo
was found.

Important things to note when looking at this stuff are the phdrs
(eu-readelf -l) of the DSOs in question.  The big likely differences
between libc and your example is that libc might be prelinked, and
that it has a separate debuginfo file.

When prelinked, the base bias (phdrs vs runtime address) usually winds up
0, whereas a plain DSO always has a nonzero base.

When debuginfo is separate, then the dwbias can be different when the DSO
was prelinked, because the addresses in the .debug file (i.e. in DWARF, and
in symtabs if using .debug's symtab rather than stripped-file's symtab)
were not changed by prelink though the DSO itself was changed.

I think dwfl_module_relocate_address might be applying the wrong bias.  It
subtracts the dwbias, but it should subtract the main file bias.  The
address you pass it is an absolute address in that Dwfl's address space,
and what it should yield is the address relative to the first p_vaddr in
the DSO (i.e. 0 if not prelinked).

diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c
index 402bc06..7f390c7 100644
--- a/libdwfl/derelocate.c
+++ b/libdwfl/derelocate.c
@@ -358,7 +358,7 @@ dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
 
   if (mod->e_type != ET_REL)
     {
-      *addr -= mod->debug.bias;
+      *addr -= mod->main.bias;
       return 0;
     }


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]