This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Debug info read problem
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Thu, 12 Mar 2009 14:25:35 +0000
- Subject: [PATCH] Debug info read problem
I have been investigating a problem in which I see this message, in
addition to "undefined reference to" messages:
arm-none-eabi-ld: Dwarf Error: Offset (273) greater than or equal to .debug_str size (268).
The problem is that it mis-reads the size of the .debug_str section.
This leads to valid offsets appearing out-of-range.
Debugging shows that the section "rawsize" field contains the correct
size, but the code prefers the "size" field, which does not.
It's not entirely clear to me why there would be two different sizes for
this section - the comments on the fields talk about relaxation and
such, but I don't understand how this related to debug info. It does say
that, if set, the field contains the original size of the input section
on disk. This would appear to be the right thing, in this case.
The attached patch fixes the problem for the test case, but I don't if
I'm fixing the symptom, or the root cause.
Note that this code is usually only called for building diagnostic
messages from debug info.
OK?
Andrew
2009-03-12 Andrew Stubbs <ams@codesourcery.com>
bfd/
* dwarf2.c (read_section): Always use rawsize, if available.
---
src/binutils-mainline/bfd/dwarf2.c | 3 +--
1 files changed, 1 insertion(+), 2 deletions(-)
Index: src/binutils-mainline/bfd/dwarf2.c
===================================================================
--- src/binutils-mainline/bfd/dwarf2.c.orig
+++ src/binutils-mainline/bfd/dwarf2.c
@@ -432,9 +432,9 @@ read_section (bfd * abfd,
return FALSE;
}
+ *section_size = msec->rawsize ? msec->rawsize : msec->size;
if (syms)
{
- *section_size = msec->size;
*section_buffer
= bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
if (! *section_buffer)
@@ -442,7 +442,6 @@ read_section (bfd * abfd,
}
else
{
- *section_size = msec->rawsize ? msec->rawsize : msec->size;
*section_buffer = bfd_malloc (*section_size);
if (! *section_buffer)
return FALSE;