* Avoid potential crashes with --gc-sections and low addresses
@ 2008-06-27 15:56 Jonathan Larmour
2008-06-27 16:01 ` Jonathan Larmour
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Larmour @ 2008-06-27 15:56 UTC (permalink / raw)
To: gdb-patches
Hi,
The attached patch deals with a problem that occurs with some embedded
targets when the linker garbage collection feature of GNU ld
(--gc-sections) is used.
Linker gc can cause DWARF2 debug info for eliminated functions and frames
to be retained in the binary, but with the location set to 0. This works
most of the time. The problem occurs when there is retained valid code with
a location close to 0, as can happen on an embedded target.
In dwarf2_frame_find_fde we have:
while (fde)
{
if (*pc >= fde->initial_location + offset
&& *pc < fde->initial_location + offset + fde->address_range)
{
*pc = fde->initial_location + offset;
return fde;
}
fde = fde->next;
}
In most executables on other targets, eliminated code would not match this,
but when there is code close to 0, the pc comparison test can succeed and
match the debug information for the eliminated code because that code is
within the address range.
The simplest solution is to prevent these sorts of FDEs being loaded in the
first place, by only incorporating FDEs with non-NULL initial locations,
as per the attached patch. This also avoids using up memory and processing
time for debug info we'll never use.
The patch was in fact written by a colleague, but since it's a one-liner, I
assume copyright assignments are superfluous under the "simple changes"
rule. I do have check-in perms (it's been a while I know) if that helps.
Jifl
2008-07-27 Bart Veer <bartv@eCosCentric.com>
* dwarf2-frame.c (decode_frame_entry_1): Only add FDE if it has
a valid location.
--
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------ Opinions==mine
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Avoid potential crashes with --gc-sections and low addresses
2008-06-27 15:56 Avoid potential crashes with --gc-sections and low addresses Jonathan Larmour
@ 2008-06-27 16:01 ` Jonathan Larmour
2008-06-27 17:14 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Larmour @ 2008-06-27 16:01 UTC (permalink / raw)
To: Jonathan Larmour; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
Jonathan Larmour wrote:
> Hi,
>
> The attached patch deals with a problem that occurs with some embedded
> targets when the linker garbage collection feature of GNU ld
> (--gc-sections) is used.
<ahem> and the patch is now attached.
Jifl
--
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------ Opinions==mine
[-- Attachment #2: dwarf2,patch --]
[-- Type: text/plain, Size: 341 bytes --]
--- gdb/dwarf2-frame.c~ 2008-05-04 00:24:17.000000000 +0100
+++ gdb/dwarf2-frame.c 2008-06-20 17:06:04.000000000 +0100
@@ -1795,7 +1795,8 @@ decode_frame_entry_1 (struct comp_unit *
fde->eh_frame_p = eh_frame_p;
- add_fde (unit, fde);
+ if (fde->initial_location)
+ add_fde (unit, fde);
}
return end;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Avoid potential crashes with --gc-sections and low addresses
2008-06-27 16:01 ` Jonathan Larmour
@ 2008-06-27 17:14 ` Daniel Jacobowitz
2008-06-27 18:31 ` Jonathan Larmour
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-06-27 17:14 UTC (permalink / raw)
To: Jonathan Larmour; +Cc: gdb-patches
On Fri, Jun 27, 2008 at 04:37:50PM +0100, Jonathan Larmour wrote:
> --- gdb/dwarf2-frame.c~ 2008-05-04 00:24:17.000000000 +0100
> +++ gdb/dwarf2-frame.c 2008-06-20 17:06:04.000000000 +0100
> @@ -1795,7 +1795,8 @@ decode_frame_entry_1 (struct comp_unit *
>
> fde->eh_frame_p = eh_frame_p;
>
> - add_fde (unit, fde);
> + if (fde->initial_location)
> + add_fde (unit, fde);
> }
>
> return end;
This won't work if there is code actually at zero. Take a look at the
.debug_info reader to see how we handled this case for symbolic debug info.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Avoid potential crashes with --gc-sections and low addresses
2008-06-27 17:14 ` Daniel Jacobowitz
@ 2008-06-27 18:31 ` Jonathan Larmour
2008-06-27 19:13 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Larmour @ 2008-06-27 18:31 UTC (permalink / raw)
To: gdb-patches
Daniel Jacobowitz wrote:
> On Fri, Jun 27, 2008 at 04:37:50PM +0100, Jonathan Larmour wrote:
>> --- gdb/dwarf2-frame.c~ 2008-05-04 00:24:17.000000000 +0100
>> +++ gdb/dwarf2-frame.c 2008-06-20 17:06:04.000000000 +0100
>> @@ -1795,7 +1795,8 @@ decode_frame_entry_1 (struct comp_unit *
>>
>> fde->eh_frame_p = eh_frame_p;
>>
>> - add_fde (unit, fde);
>> + if (fde->initial_location)
>> + add_fde (unit, fde);
>> }
>>
>> return end;
>
> This won't work if there is code actually at zero. Take a look at the
> .debug_info reader to see how we handled this case for symbolic debug info.
I've had a look, and got lost in a twisty maze of passages. The learning
curve for that stuff is probably steeper than I can manage at the moment.
If you don't mind, in that case I'll submit it to GNATS so it isn't lost.
Jifl
--
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------ Opinions==mine
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Avoid potential crashes with --gc-sections and low addresses
2008-06-27 18:31 ` Jonathan Larmour
@ 2008-06-27 19:13 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-06-27 19:13 UTC (permalink / raw)
To: Jonathan Larmour; +Cc: gdb-patches
On Fri, Jun 27, 2008 at 07:19:53PM +0100, Jonathan Larmour wrote:
> I've had a look, and got lost in a twisty maze of passages. The learning
> curve for that stuff is probably steeper than I can manage at the moment.
> If you don't mind, in that case I'll submit it to GNATS so it isn't lost.
OK. I'll warn you, being in GNATS is presently much like being lost.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-27 18:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-27 15:56 Avoid potential crashes with --gc-sections and low addresses Jonathan Larmour
2008-06-27 16:01 ` Jonathan Larmour
2008-06-27 17:14 ` Daniel Jacobowitz
2008-06-27 18:31 ` Jonathan Larmour
2008-06-27 19:13 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox