libbacktrace: walk the elf_syminfo_data chain in elf_syminfo

Alexander Monakov amonakov@ispras.ru
Mon Jul 22 13:31:00 GMT 2013


Hello,

this fixes a bug (found by inspection) that would prevent elf_syminfo from
looking up symbols defined in modules other than the executable.

Bootstrapped and regtested together with the next patch on x86_64-linux
(excluding Java, including Go), OK for trunk?

libbacktrace/Changelog:
2013-07-22  Alexander Monakov  <amonakov@ispras.ru>

	* elf.c (elf_syminfo): Loop over the elf_syminfo_data chain.

diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index ef9bcdf..a90afaa 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -454,12 +454,15 @@ elf_syminfo (struct backtrace_state *state, uintptr_t pc,
             void *data)
 {
   struct elf_syminfo_data *edata;
-  struct elf_symbol *sym;
+  struct elf_symbol *sym = NULL;
+
+  for (edata = (struct elf_syminfo_data *) state->syminfo_data;
+       edata && sym == NULL;
+       edata = edata->next)
+    sym = ((struct elf_symbol *)
+          bsearch (&pc, edata->symbols, edata->count,
+                   sizeof (struct elf_symbol), elf_symbol_search));
 
-  edata = (struct elf_syminfo_data *) state->syminfo_data;
-  sym = ((struct elf_symbol *)
-        bsearch (&pc, edata->symbols, edata->count,
-                 sizeof (struct elf_symbol), elf_symbol_search));
   if (sym == NULL)
     callback (data, pc, NULL, 0);
   else




More information about the Gcc-patches mailing list