[PATCH v2 4/6] ld: Discard LLVM_ADDRSIG sections.
Tatsuyuki Ishi
ishitatsuyuki@gmail.com
Thu Jun 23 15:13:52 GMT 2022
The symbol indices in addrsig sections requires update in the case of a
partial link, which we currently cannot do. Now that bfd is able to insert
a correct sh_link entry for the addrsig section, this will break the final
linker's heuristic [1] that discards such corrupt section.
As such, strip this section explicitly for ld -r.
[1]: https://github.com/llvm/llvm-project/blob/09c2b7c35af8c4bad39f03e9f60df8bd07323028/lld/ELF/InputFiles.cpp#L540-L554
---
ld/ldlang.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 839535bdb73..ba2d350bbd9 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2516,6 +2516,13 @@ lang_discard_section_p (asection *section)
&& link_info.resolve_section_groups)
discard = true;
+ /* Discard .llvm_addrsig sections. We don't do the additional processing
+ to keep the symbol indices correct, and when doing a partial link this
+ will end up getting the wrong information to the final linker. */
+ if (bfd_get_flavour (section->owner) == bfd_target_elf_flavour
+ && elf_section_type (section) == SHT_LLVM_ADDRSIG)
+ discard = true;
+
/* Discard debugging sections if we are stripping debugging
information. */
if ((link_info.strip == strip_debugger || link_info.strip == strip_all)
--
2.36.1
More information about the Binutils
mailing list