Jakub Jelinek 0332e1
--- valgrind-3.5.0/coregrind/m_debuginfo/readelf.c.jj	2009-12-02 05:38:20.000000000 -0500
Jakub Jelinek 0332e1
+++ valgrind-3.5.0/coregrind/m_debuginfo/readelf.c	2009-12-02 06:50:44.061404000 -0500
Jakub Jelinek 0332e1
@@ -1062,6 +1062,8 @@ Bool ML_(read_elf_debug_info) ( struct _
Jakub Jelinek 0332e1
    Bool          res, ok;
Jakub Jelinek 0332e1
    SysRes        fd, sres;
Jakub Jelinek 0332e1
    Word          i;
Jakub Jelinek 0332e1
+   Bool          dynbss_present = False;
Jakub Jelinek 0332e1
+   Bool          sdynbss_present = False;
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
    /* Image addresses for the ELF file we're working with. */
Jakub Jelinek 0332e1
    Addr          oimage   = 0;
Jakub Jelinek 0332e1
@@ -1476,8 +1478,40 @@ Bool ML_(read_elf_debug_info) ( struct _
Jakub Jelinek 0332e1
          }
Jakub Jelinek 0332e1
       }
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
+      if (0 == VG_(strcmp)(name, ".dynbss")) {
Jakub Jelinek 0332e1
+         if (inrw && size > 0 && !di->bss_present) {
Jakub Jelinek 0332e1
+            dynbss_present = True;
Jakub Jelinek 0332e1
+            di->bss_present = True;
Jakub Jelinek 0332e1
+            di->bss_svma = svma;
Jakub Jelinek 0332e1
+            di->bss_avma = svma + rw_bias;
Jakub Jelinek 0332e1
+            di->bss_size = size;
Jakub Jelinek 0332e1
+            di->bss_bias = rw_bias;
Jakub Jelinek 0332e1
+            di->bss_debug_svma = svma;
Jakub Jelinek 0332e1
+            di->bss_debug_bias = rw_bias;
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .dynbss svma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         di->bss_svma,
Jakub Jelinek 0332e1
+                         di->bss_svma + di->bss_size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .dynbss avma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         di->bss_avma,
Jakub Jelinek 0332e1
+                         di->bss_avma + di->bss_size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .dynbss bias = %#lx\n", di->bss_bias);
Jakub Jelinek 0332e1
+         }
Jakub Jelinek 0332e1
+      }
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
       /* Accept .bss where mapped as rw (data), even if zero-sized */
Jakub Jelinek 0332e1
       if (0 == VG_(strcmp)(name, ".bss")) {
Jakub Jelinek 0332e1
+         if (inrw && size > 0 && dynbss_present) {
Jakub Jelinek 0332e1
+            vg_assert(di->bss_present);
Jakub Jelinek 0332e1
+            dynbss_present = False;
Jakub Jelinek 0332e1
+            vg_assert(di->bss_svma + di->bss_size == svma);
Jakub Jelinek 0332e1
+            di->bss_size += size;
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .bss svma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         svma, svma + size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .bss avma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         svma + rw_bias, svma + rw_bias + size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .bss bias = %#lx\n", di->bss_bias);
Jakub Jelinek 0332e1
+         } else
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
          if (inrw && size >= 0 && !di->bss_present) {
Jakub Jelinek 0332e1
             di->bss_present = True;
Jakub Jelinek 0332e1
             di->bss_svma = svma;
Jakub Jelinek 0332e1
@@ -1529,8 +1563,40 @@ Bool ML_(read_elf_debug_info) ( struct _
Jakub Jelinek 0332e1
          }
Jakub Jelinek 0332e1
       }
Jakub Jelinek 0332e1
 
Jakub Jelinek 0332e1
+      if (0 == VG_(strcmp)(name, ".sdynbss")) {
Jakub Jelinek 0332e1
+         if (inrw && size >= 0 && !di->sbss_present) {
Jakub Jelinek 0332e1
+            sdynbss_present = True;
Jakub Jelinek 0332e1
+            di->sbss_present = True;
Jakub Jelinek 0332e1
+            di->sbss_svma = svma;
Jakub Jelinek 0332e1
+            di->sbss_avma = svma + rw_bias;
Jakub Jelinek 0332e1
+            di->sbss_size = size;
Jakub Jelinek 0332e1
+            di->sbss_bias = rw_bias;
Jakub Jelinek 0332e1
+            di->sbss_debug_svma = svma;
Jakub Jelinek 0332e1
+            di->sbss_debug_bias = rw_bias;
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .sdynbss svma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         di->sbss_svma,
Jakub Jelinek 0332e1
+                         di->sbss_svma + di->sbss_size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .sdynbss avma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         di->sbss_avma,
Jakub Jelinek 0332e1
+                         di->sbss_avma + di->sbss_size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .sdynbss bias = %#lx\n", di->sbss_bias);
Jakub Jelinek 0332e1
+         }
Jakub Jelinek 0332e1
+      }
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
       /* Accept .sbss where mapped as rw (data) */
Jakub Jelinek 0332e1
       if (0 == VG_(strcmp)(name, ".sbss")) {
Jakub Jelinek 0332e1
+         if (inrw && size > 0 && sdynbss_present) {
Jakub Jelinek 0332e1
+            vg_assert(di->sbss_present);
Jakub Jelinek 0332e1
+            sdynbss_present = False;
Jakub Jelinek 0332e1
+            vg_assert(di->sbss_svma + di->sbss_size == svma);
Jakub Jelinek 0332e1
+            di->sbss_size += size;
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .sbss svma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         svma, svma + size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .sbss avma = %#lx .. %#lx\n",
Jakub Jelinek 0332e1
+                         svma + rw_bias, svma + rw_bias + size - 1);
Jakub Jelinek 0332e1
+            TRACE_SYMTAB("acquiring .sbss bias = %#lx\n", di->sbss_bias);
Jakub Jelinek 0332e1
+         } else
Jakub Jelinek 0332e1
+
Jakub Jelinek 0332e1
          if (inrw && size > 0 && !di->sbss_present) {
Jakub Jelinek 0332e1
             di->sbss_present = True;
Jakub Jelinek 0332e1
             di->sbss_svma = svma;