summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-30 18:06:14 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-30 18:06:14 +0000
commit7463879947b12d6aa4a5e087c57ef5925d31e3da (patch)
tree360b3b34bba35615b1353743c6cfe9680e996b0e
parente39bb9f67fd9b6692777d030749f8d0eff613152 (diff)
downloadgcc-7463879947b12d6aa4a5e087c57ef5925d31e3da.tar.gz
Backport from mainline:
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@205553 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libbacktrace/ChangeLog8
-rw-r--r--libbacktrace/elf.c11
2 files changed, 17 insertions, 2 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 5046ccbe136..36ec71a57bb 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,3 +1,11 @@
+2013-11-30 Ian Lance Taylor <iant@google.com>
+
+ Backport from mainline:
+ 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-16 Release Manager
* GCC 4.8.2 released.
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index ef9bcdfb495..49c6fe554af 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -725,6 +725,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;
@@ -751,8 +753,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,