gold cannot handle _start in a library

Ian Lance Taylor
Wed May 25 00:18:00 GMT 2011

Roland McGrath <> writes:

> Given:
> 	$ gcc -c -xc <(echo '_start(){}') -o start.o
> 	$ ar cq libstart.a start.o
> 	$ ./gold/ld-new -o foo libstart.a
> The output file foo is an empty ELF file.
> With:
> 	$ ./gold/ld-new -o foo -e _start libstart.a
> 	./gold/ld-new: warning: cannot find entry symbol '_start'
> The results are the same, plus the extra warning.
> BFD ld does not have this bug.
> I tested with today's trunk builds of gold and BFD ld.

Thanks.  Fixed like so.  Committed to mainline.


2011-05-24  Ian Lance Taylor  <>

	* (Library_base::should_include_member): Pull in object
	from archive if it defines the entry symbol.
	* (Parameters::entry): New function.
	* parameters.h (class Parameters): Declare entry.
	* output.h (class Output_file_header): Remove entry_ field.
	* (Output_file_header::Output_file_header): Remove entry
	parameter.  Change all callers.
	(Output_file_header::entry): Use parameters->entry.
	* (queue_middle_tasks): Likewise.
	* (Plugin_hook::run): Likewise.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 6836 bytes
Desc: patch
URL: <>

More information about the Binutils mailing list