[PATCH] Fail on erroneous linker script

Maxim Kuvyrkov maxim@codesourcery.com
Mon Dec 7 12:16:00 GMT 2009


Alan Modra wrote:
> On Fri, Dec 04, 2009 at 08:03:42PM +0300, Maxim Kuvyrkov wrote:
>> In most valid cases NOBITS sections (.bss, usually) are placed at the  
>> end of the loaded segments.  However, if a user provides a custom linker  
>> scripts which puts, a .bss section in the middle of the data segment,  
>> the linker will produce a broken binary.  The proper behavior for linker  
>> is to fail with appropriate error message.
> 
> We could also treat such NOBITS sections as if they were PROGBITS.
> Like the following untested patch.  What do you think?
> 
> 	* elf.c (write_zeros): New function.
> 	(assign_file_positions_for_load_sections): Allocate file space for
> 	NOBITS sections that are followed by PROGBITS sections in a segment.

It looks good.  The patch fixes the original problem and doesn't show 
any regressions.  I tested it on i686-linux by building glibc and 
running testsuites.

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724



More information about the Binutils mailing list