[gold][patch] Add a add_input_library callback

Rafael Espindola espindola@google.com
Thu Oct 1 21:54:00 GMT 2009


GCC can introduce calls to libc functions when for example converting
printf calls into puts calls. This is a problem when using the plugin
and linking libc statically: When the plugin first scans the inputs,
there is no references to puts. When the final objects are generated
there is and gold reports an undefined reference.

The problem with libc is similar to the problem with libgcc. The
difference is that gcc doesn't know exactly which libc is used. It
just passes -lc to the linker. What this patch does is add a new
callback called add_input_library. It is similar to add_input_file,
but causes gold to search for the library.

I tested this with a modified gcc plugin that uses this feature and
was able to correctly statically like a program that fails with the
current plugin.

I also added some documentation to the plugin-api.h file that was
already in the gcc copy.

gold/
2009-10-01  Rafael Avila de Espindola  <espindola@google.com>

	* plugin.cc (add_input_library): New.
	(Plugin::load): Add add_input_library to tv.
	(Plugin_manager::add_input_file): Add the search argument.
	(add_input_file): Update call to Plugin_manager::add_input_file.
	(add_input_library): New.
	* plugin.h (Plugin_manager::add_input_file): Add the search argument.

include/
2009-10-01  Rafael Avila de Espindola  <espindola@google.com>

	* plugin-api.h (ld_plugin_symbol_resolution): Document.
	(ld_plugin_add_input_library): New.
	(ld_plugin_tag): Add LDPT_ADD_INPUT_LIBRARY.
	(ld_plugin_tv): Add tv_add_input_library.

Cheers,
-- 
Rafael Ávila de Espíndola
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gold.patch
Type: text/x-diff
Size: 4378 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20091001/c8538b32/attachment.bin>


More information about the Binutils mailing list