[PATCH] orphan section creating huge output file

Alan Modra amodra@bigpond.net.au
Thu Mar 17 08:13:00 GMT 2005


On Wed, Mar 16, 2005 at 06:17:46PM -0800, Bob Wilson wrote:
> A while back, David Heine found a problem where an orphan section could 
> cause the linker to create huge output files, or even segfault when trying 
> to seek to a negative value.  (See 
> http://sourceware.org/ml/binutils/2003-04/msg00423.html) This problem was 
>  fixed earlier, but now he's found a similar problem.
> 
> David analyzed this and sent me an earlier version of this patch, so I'll 
> try to describe this as best I can.  The use of IGNORE_SECTION in 
> lang_size_sections_1() in ldlang.c is not right because at that point the 
> section sizes are all zero, and IGNORE_SECTION is true for zero size 
> sections.

Yes, I agree that a test of output section size at that point in
lang_size_sections_1 is wrong, but it might be appropriate if the memory
region checks were moved after the output section size had been
calculated.  Alex, you added the zero size check in
http://sources.redhat.com/ml/binutils/2003-10/msg00184.html, but I don't
see any testcase or description of exactly why the change was needed.
Given this situation, I'm going to approve this patch, especially
as the testcase demonstrates that zero size sections not allocated to
memory regions can cause ld to misbehave.

> Moreover, even a zero size section can cause the huge output file 
> problem.  The attached patch moves the check for zero size sections out of 
> the IGNORE_SECTION macro.  David also provided a testcase to demonstrate 
> the problem, and I've cleaned it up and added it to the testsuite.
> 
> OK for mainline?

Yes, and for the 2.16 branch too, but give Daniel and others a chance to
object.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list