PATCH: Improved diagnosis of overflowed memory regions

Zack Weinberg
Thu Jul 19 03:20:00 GMT 2007

[ For the curious - I'm doing some contract work for CodeSourcery over 
the summer. ]

The linker's current diagnostics when a memory region overflows are 
unhelpful in four ways.  First, once a region is full, every output 
section targeted to that region will generate another "region is full" 
message.  Second, you *also* get a flood of "section overlap" messages 
for those sections, even though nothing the user did would have caused 
section overlap if the memory regions were big enough.  Third, while you 
do get a mapfile if you give -Map, the reported position of every 
section after the one that overflowed the region will be garbage. 
Fourth, nothing tells you how big the region needs to be.

All these problems can be fixed with a few simple changes to ldlang.c. 
The only nontrivial bit is that os_region_check was resetting 
region->current to region->origin on overflow; that was the cause of the 
section overlap messages and the unhelpful linker maps.  As at that 
point we are definitely not generating output, I believe it is safe to 
remove it altogether; that makes the memory layout as reported in the 
mapfile be what it would have been if the memory regions had all been 
big enough, and section overlap is reported only if it's "real" (i.e. if 
  a region at lower addresses would have to be so big that it overlapped 
a region at higher addresses.)



	* ldlang.c (lang_check_section_addresses): Also report size of
	overflow for any overflowed memory regions.
	(os_region_check): Diagnose an overflowed region only once per
	region.  Do not reset region->current on overflow.
	* ld-scripts/rgn-over.exp: New driver.
	* ld-scripts/rgn-over.s: New file.
	* ld-scripts/rgn-over1.d, ld-scripts/rgn-over1.t
	* ld-scripts/rgn-over2.d, ld-scripts/rgn-over2.t
	* ld-scripts/rgn-over3.d, ld-scripts/rgn-over3.t
	* ld-scripts/rgn-over4.d, ld-scripts/rgn-over4.t
	* ld-scripts/rgn-over5.d, ld-scripts/rgn-over5.t
	* ld-scripts/rgn-over6.d, ld-scripts/rgn-over6.t
	* ld-scripts/rgn-over7.d, ld-scripts/rgn-over7.t:
	New test cases.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: region-overflow-diag.diff
Type: text/x-patch
Size: 16067 bytes
Desc: not available
URL: <>

More information about the Binutils mailing list