public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Another dwfl_module_relocate_address fixlet
@ 2009-02-21 14:27 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2009-02-21 14:27 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

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

[-- Attachment #2: translate-et-dyn.patch --]
[-- Type: text/x-patch, Size: 1094 bytes --]

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")
                 {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-20 23:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-21 14:27 Another dwfl_module_relocate_address fixlet Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).