I backported the libbacktrace fix in
http://gcc.gnu.org/ml/gcc-patches/2013-10/msg01445.html to the GCC 4.8
branch. Bootstrapped and ran libbacktrace testsuite on
x86_64-unknown-linux-gnu. Committed to 4.8 branch.
Ian
2013-11-30 Ian Lance Taylor <[email protected]>
Backport from mainline:
2013-10-17 Ian Lance Taylor <[email protected]>
* elf.c (elf_add): Don't get the wrong offsets if a debug section
is missing.
Index: elf.c
===================================================================
--- elf.c (revision 205552)
+++ elf.c (working copy)
@@ -725,6 +725,8 @@ elf_add (struct backtrace_state *state,
{
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;
@@ -751,8 +753,13 @@ elf_add (struct backtrace_state *state,
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,