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]

Another dwfl_module_relocate_address fixlet


Hi,

I pushed one fixlet from my pr6866 branch to the master branch because I
know I has bitten me in the past while working with shared libraries. So
it is good to have this on master even if the actual testcase for it is
still only on the branch, since it needs some other work that is
unfinished on the branch. I only pushed the final change, the branch has
multiple slightly wrong versions of this one, you can read back the
exchanges roland and I had that let to this latest much simpler version.
This is mostly an email to remind me to audit the other users of
dwfl_module_relocate_address in the tree.

    Adjust ET_DYN symbol addresses against module base.
    
    * translate.cxx (dump_unwindsyms): Adjust sym_addr for ET_DYN always
      against module base as workaround for buggy elfutils < 0.138.

Cheers,

Mark
diff --git a/translate.cxx b/translate.cxx
index c0e76a0..530b077 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4551,10 +4551,19 @@ dump_unwindsyms (Dwfl_Module *m,
 
               if (n > 0) // only try to relocate if there exist relocation bases
                 {
+                  Dwarf_Addr save_addr = sym_addr;
                   int ki = dwfl_module_relocate_address (m, &sym_addr);
                   dwfl_assert ("dwfl_module_relocate_address", ki >= 0);
                   secname = dwfl_module_relocation_info (m, ki, NULL);
-                }
+
+                  // For ET_DYN files (secname == "") we do ignore the
+                  // dwfl_module_relocate_address adjustment. libdwfl
+                  // up to 0.137 would substract the wrong bias. So we do
+                  // it ourself, it is always just the module base address
+                  // in this case.
+                  if (ki == 0 && secname != NULL && secname[0] == '\0')
+                    sym_addr = save_addr - base;
+		}
 
               if (n == 1 && modname == "kernel")
                 {

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