]> sourceware.org Git - systemtap.git/commitdiff
PR10812: undo +20 build-id address offsetting
authorFrank Ch. Eigler <fche@elastic.org>
Wed, 29 Sep 2010 16:53:37 +0000 (12:53 -0400)
committerFrank Ch. Eigler <fche@elastic.org>
Wed, 29 Sep 2010 16:53:37 +0000 (12:53 -0400)
With the new relocation code, this does occasionally cause addresses
to spill over into the next section, leading to unexpected relocation
bases.

* runtime/sym.c (_stp_module_check): Remove the build_id_len
  subtraction.  Provide diagnostics on unexpected addresses/names.
* translate.cxx (dump_unwindsyms): Likewise.

runtime/sym.c
translate.cxx

index 895ec8c4dec1a30c48ad74b362da10c6add08f6f..3471f632025cd9b7301a516895b376d2e8d0e8f2 100644 (file)
@@ -267,13 +267,11 @@ static int _stp_module_check(void)
                          base_addr = m->notes_sect;
                    }
 
-                   /* build-id note payload start address */
-                    /* XXX: But see https://bugzilla.redhat.com/show_bug.cgi?id=465872;
-                       dwfl_module_build_id was not intended to return the end address. */
-                   notes_addr -= m->build_id_len;
-
-                   if (notes_addr <= base_addr)  /* shouldn't happen */
-                        continue;
+                   if (notes_addr <= base_addr) { /* shouldn't happen */
+                            _stp_warn ("build-id address %lx < base %lx\n", 
+                                       notes_addr, base_addr);
+                            continue;
+                    }
                     for (j=0; j<m->build_id_len; j++) {
                             /* Use set_fs / get_user to access
                              conceivably invalid addresses.  If
index cfdec5bc3ef8c1f565191ae19a6f247fb88a7fe9..39ea5abd10533e0a1794f3f7f9b0618a5202a45e 100644 (file)
@@ -1,6 +1,7 @@
 // translation pass
 // Copyright (C) 2005-2010 Red Hat Inc.
 // Copyright (C) 2005-2008 Intel Corporation.
+// Copyright (C) 2010 Novell Corporation.
 //
 // This file is part of systemtap, and is free software.  You can
 // redistribute it and/or modify it under the terms of the GNU General
@@ -4895,9 +4896,9 @@ dump_unwindsyms (Dwfl_Module *m,
     // Enable workaround for elfutils dwfl bug.
     // see https://bugzilla.redhat.com/show_bug.cgi?id=465872
     // and http://sourceware.org/ml/systemtap/2008-q4/msg00579.html
-#if _ELFUTILS_PREREQ(0,138)
-    // Let's standardize to the buggy "end of build-id bits" behavior.
-    build_id_vaddr += build_id_len;
+#if !_ELFUTILS_PREREQ(0,138)
+    // Let's standardize to the new "start of build-id bits" behavior.
+    build_id_vaddr -= build_id_len;
 #endif
 
     // And check for another workaround needed.
@@ -4912,26 +4913,30 @@ dump_unwindsyms (Dwfl_Module *m,
       }
 #endif
 
-    if (modname != "kernel") {
-       Dwarf_Addr reloc_vaddr = build_id_vaddr;
-       const char *secname;
-       int i;
+    if (modname != "kernel")
+      {
+        Dwarf_Addr reloc_vaddr = build_id_vaddr;
+        const char *secname;
+        int i;
 
-       i = dwfl_module_relocate_address (m, &reloc_vaddr);
-       dwfl_assert ("dwfl_module_relocate_address", i >= 0);
+        i = dwfl_module_relocate_address (m, &reloc_vaddr);
+        dwfl_assert ("dwfl_module_relocate_address", i >= 0);
 
-       secname = dwfl_module_relocation_info (m, i, NULL);
-       dwfl_assert ("dwfl_module_relocation_info", 
-               strcmp(secname, ".note.gnu.build-id") == 0);
+        secname = dwfl_module_relocation_info (m, i, NULL);
 
-       build_id_vaddr = reloc_vaddr;
-    }
+        // assert same section name as in runtime/transport/symbols.c
+        if (!secname || strcmp(secname, ".note.gnu.build-id"))
+          throw semantic_error ("unexpected build-id reloc section " +
+                                string(secname ?: "null"));
+
+        build_id_vaddr = reloc_vaddr;
+      }
 
     if (c->session.verbose > 1)
       {
         clog << "Found build-id in " << name
              << ", length " << build_id_len;
-        clog << ", end at 0x" << hex << build_id_vaddr
+        clog << ", start at 0x" << hex << build_id_vaddr
              << dec << endl;
       }
   }
This page took 0.042158 seconds and 5 git commands to generate.