gcc/lto-plugin
Joseph Myers c49d51fa81 Implement LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook [PR109128]
This is one part of the fix for PR109128, along with a corresponding
binutils's linker change.  Without this patch, what happens in the
linker, when an unused object in a .a file has offload data, is that
elf_link_is_defined_archive_symbol calls bfd_link_plugin_object_p,
which ends up calling the plugin's claim_file_handler, which then
records the object as one with offload data. That is, the linker never
decides to use the object in the first place, but use of this _p
interface (called as part of trying to decide whether to use the
object) results in the plugin deciding to use its offload data (and a
consequent mismatch in the offload data present at runtime).

The new hook allows the linker plugin to distinguish calls to
claim_file_handler that know the object is being used by the linker
(from ldmain.c:add_archive_element), from calls that don't know it's
being used by the linker (from elf_link_is_defined_archive_symbol); in
the latter case, the plugin should avoid recording the object as one
with offload data.

	PR middle-end/109128

	include/
	* plugin-api.h (ld_plugin_claim_file_handler_v2)
	(ld_plugin_register_claim_file_v2)
	(LDPT_REGISTER_CLAIM_FILE_HOOK_V2): New.
	(struct ld_plugin_tv): Add tv_register_claim_file_v2.

	lto-plugin/
	* lto-plugin.c (register_claim_file_v2): New.
	(claim_file_handler_v2): New.
	(claim_file_handler): Wrap claim_file_handler_v2.
	(onload): Handle LDPT_REGISTER_CLAIM_FILE_HOOK_V2.
2023-05-11 10:08:50 +02:00
..
aclocal.m4 Enable Intel CET in liblto_plugin.so on Intel CET enabled host 2020-04-25 10:07:16 -07:00
ChangeLog Daily bump. 2022-11-24 00:17:47 +00:00
config.h.in lto-plugin: use locking only for selected targets 2022-07-07 15:18:58 +02:00
configure Revert "configure: Implement --enable-host-bind-now" 2022-11-22 21:10:19 -05:00
configure.ac Revert "configure: Implement --enable-host-bind-now" 2022-11-22 21:10:19 -05:00
lto-plugin.c Implement LDPT_REGISTER_CLAIM_FILE_HOOK_V2 linker plugin hook [PR109128] 2023-05-11 10:08:50 +02:00
lto-plugin.map lto-plugin: Use GNU ld or Solaris ld version script in preference to -export-symbols-regex [PR102426] 2022-03-22 11:03:54 +01:00
Makefile.am lto-plugin: use -pthread only for detected targets 2022-07-14 13:26:21 +02:00
Makefile.in lto-plugin: use -pthread only for detected targets 2022-07-14 13:26:21 +02:00