Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* 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

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