]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
elf.c (elf_add): Don't get the wrong offsets if a debug section is missing.
authorIan Lance Taylor <iant@google.com>
Fri, 18 Oct 2013 04:24:48 +0000 (04:24 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 18 Oct 2013 04:24:48 +0000 (04:24 +0000)
* elf.c (elf_add): Don't get the wrong offsets if a debug section
is missing.

From-SVN: r203810

libbacktrace/ChangeLog
libbacktrace/elf.c

index 9c6a8839f5e549391054d975f2fd2db5bb64aff3..86536a16adbfddcae3bd2b6bcbd4fd827e235c62 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-17  Ian Lance Taylor  <iant@google.com>
+
+       * elf.c (elf_add): Don't get the wrong offsets if a debug section
+       is missing.
+
 2013-10-15  David Malcolm  <dmalcolm@redhat.com>
 
        * configure.ac: Add --enable-host-shared, setting up
index c1dbc5492e0ef261def2b99c7c177890c1172593..2161ad2a258eaa8cd5390e947c0be038d2b3bbdd 100644 (file)
@@ -759,6 +759,8 @@ elf_add (struct backtrace_state *state, int descriptor, uintptr_t base_address,
     {
       off_t end;
 
+      if (sections[i].size == 0)
+       continue;
       if (min_offset == 0 || sections[i].offset < min_offset)
        min_offset = sections[i].offset;
       end = sections[i].offset + sections[i].size;
@@ -785,8 +787,13 @@ elf_add (struct backtrace_state *state, int descriptor, uintptr_t base_address,
   descriptor = -1;
 
   for (i = 0; i < (int) DEBUG_MAX; ++i)
-    sections[i].data = ((const unsigned char *) debug_view.data
-                       + (sections[i].offset - min_offset));
+    {
+      if (sections[i].size == 0)
+       sections[i].data = NULL;
+      else
+       sections[i].data = ((const unsigned char *) debug_view.data
+                           + (sections[i].offset - min_offset));
+    }
 
   if (!backtrace_dwarf_add (state, base_address,
                            sections[DEBUG_INFO].data,