]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 17 Oct 2012 19:49:10 +0000 (21:49 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 17 Oct 2012 20:17:14 +0000 (22:17 +0200)
2012-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

* dwfl_module_getdwarf.c (mod_verify_build_id): New function with code
from ...
(__libdwfl_getelf): ... here.  Call it.

tests/
2012-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

* run-addrname-test.sh: New test for DSO with build-id bias.
* testfile69.core.bz2: New file.
* testfile69.so.bz2: New file.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
libdwfl/ChangeLog
libdwfl/dwfl_module_getdwarf.c
tests/ChangeLog
tests/run-addrname-test.sh
tests/testfile69.core.bz2 [new file with mode: 0644]
tests/testfile69.so.bz2 [new file with mode: 0755]

index 638a096611ba719cad45821cf6c82b7d9fbb1a2e..bdd9440f19bd4fccacd9cf120d7e1c29ae687e74 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * dwfl_module_getdwarf.c (mod_verify_build_id): New function with code
+       from ...
+       (__libdwfl_getelf): ... here.  Call it.
+
 2012-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * libdwfl.h (dwfl_module_getelf): Add __nonnull_attribute__.
index bbf9ff3d8b42b4c407a403a9995d911900e9595d..025cb8ac894781a37cfe2ea6424b8c1934b4d0f1 100644 (file)
@@ -139,6 +139,43 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
   return DWFL_E_NOERROR;
 }
 
+/* We have an authoritative build ID for this module MOD, so don't use
+   a file by name that doesn't match that ID.  */
+static void
+mod_verify_build_id (Dwfl_Module *mod)
+{
+  assert (mod->build_id_len > 0);
+
+  switch (__builtin_expect (__libdwfl_find_build_id (mod, false,
+                                                    mod->main.elf), 2))
+    {
+    case 2:
+      /* Build ID matches as it should. */
+      return;
+
+    case -1:                   /* ELF error.  */
+      mod->elferr = INTUSE(dwfl_errno) ();
+      break;
+
+    case 0:                    /* File has no build ID note.  */
+    case 1:                    /* FIle has a build ID that does not match.  */
+      mod->elferr = DWFL_E_WRONG_ID_ELF;
+      break;
+
+    default:
+      abort ();
+    }
+
+  /* We get here when it was the right ELF file.  Clear it out.  */
+  elf_end (mod->main.elf);
+  mod->main.elf = NULL;
+  if (mod->main.fd >= 0)
+    {
+      close (mod->main.fd);
+      mod->main.fd = -1;
+    }
+}
+
 /* Find the main ELF file for this module and open libelf on it.
    When we return success, MOD->main.elf and MOD->main.bias are set up.  */
 void
@@ -166,41 +203,7 @@ __libdwfl_getelf (Dwfl_Module *mod)
       mod->build_id_len = 0;
     }
   else if (fallback)
-    {
-      /* We have an authoritative build ID for this module, so
-        don't use a file by name that doesn't match that ID.  */
-
-      assert (mod->build_id_len > 0);
-
-      switch (__builtin_expect (__libdwfl_find_build_id (mod, false,
-                                                        mod->main.elf), 2))
-       {
-       case 2:
-         /* Build ID matches as it should. */
-         return;
-
-       case -1:                        /* ELF error.  */
-         mod->elferr = INTUSE(dwfl_errno) ();
-         break;
-
-       case 0:                 /* File has no build ID note.  */
-       case 1:                 /* FIle has a build ID that does not match.  */
-         mod->elferr = DWFL_E_WRONG_ID_ELF;
-         break;
-
-       default:
-         abort ();
-       }
-
-      /* We get here when it was the right ELF file.  Clear it out.  */
-      elf_end (mod->main.elf);
-      mod->main.elf = NULL;
-      if (mod->main.fd >= 0)
-       {
-         close (mod->main.fd);
-         mod->main.fd = -1;
-       }
-    }
+    mod_verify_build_id (mod);
 
   mod->main_bias = mod->e_type == ET_REL ? 0 : mod->low_addr - mod->main.vaddr;
 }
index 2495fb58ce9af4421319dec8e1871a5705b0a6b5..9e8ad2c15e417deff947251a1048cb9fd39951d5 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * run-addrname-test.sh: New test for DSO with build-id bias.
+       * testfile69.core.bz2: New file.
+       * testfile69.so.bz2: New file.
+
 2012-10-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * run-addrname-test.sh: New test for core vDSO bias.
index 4feb193658a1f071827a1451e39bc2a604ba658d..cc8aa335ac2c3ece0201ecbee43180399430be3a 100755 (executable)
@@ -298,4 +298,12 @@ __vdso_time
 ??:0
 EOF
 
+testfiles testfile69.core testfile69.so
+testrun_compare ../src/addr2line --core=./testfile69.core -S 0x7f0bc6a33535 0x7f0bc6a33546 <<\EOF
+libstatic+0x9
+??:0
+libglobal+0x9
+??:0
+EOF
+
 exit 0
diff --git a/tests/testfile69.core.bz2 b/tests/testfile69.core.bz2
new file mode 100644 (file)
index 0000000..9955318
Binary files /dev/null and b/tests/testfile69.core.bz2 differ
diff --git a/tests/testfile69.so.bz2 b/tests/testfile69.so.bz2
new file mode 100755 (executable)
index 0000000..fdddab9
Binary files /dev/null and b/tests/testfile69.so.bz2 differ