[PATCH] LTO: Ignore undefined symbols without relocation

Alan Modra amodra@gmail.com
Thu Jul 30 09:32:14 GMT 2020


On Wed, Jul 29, 2020 at 03:22:58PM -0700, H.J. Lu via Binutils wrote:
> Normally an undefined symbol is treated as a reference.  Linker will
> try to satisfy the reference.  This feature is used to bring a symbol
> definition into output without explicit relocation.  If there is no
> definition nor relocation, linker will remove undefined symbol from
> symbol table in output (PR ld/4317).  But GCC 10 LTO may generate
> separate debug info files which contain undefined symbols without
> relocations:

Surely this is just a gcc bug?  We search libraries again after
loading the LTO output, so one would expect that undefined symbols
satisfied by an archive (or as-needed shared library) would lead to
extra files being linked.

I'd like to better understand just how this problem occurs though.  As
it is, I suspect there might be something else going on here, for
example, ranlib being run without a plugin when building the archives.

> 	(sym_cache): Moved before elf_link_hash_table.
> 	(elf_link_hash_table): Add sym_cache.

Please commit the above and related backend changes as a separate
patch, preapproved.

> 	* elflink.c (_bfd_elf_merge_symbol): After all LTO IR symbols
> 	have been read, skip all undefined symbols without relocation.
> 	(elf_link_add_object_symbols): Set has_reloc_after_lto_all_symbols_read
> 	after all LTO IR symbols have been read.

But not this bit just yet.

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list