diff --git a/Fixup-unresolve-symbols-problem.patch b/Fixup-unresolve-symbols-problem.patch new file mode 100644 index 0000000000000000000000000000000000000000..dea8a84db61d91a164032286e833dc8967931a64 --- /dev/null +++ b/Fixup-unresolve-symbols-problem.patch @@ -0,0 +1,117 @@ +From 534cfca985709515f4871f0aa1efc57c4e274a1a Mon Sep 17 00:00:00 2001 +From: yala +Date: Fri, 3 Mar 2023 11:19:40 +0800 +Subject: [PATCH] ld:Fix option unresolved-symbols=ignore-all does not work + when LARCH_64 appears alone + +Change-Id: Id06b7b77deefa64a2ea2c9f10a63130e5e4aaf65 +--- + bfd/elfnn-loongarch.c | 11 +++++--- + ld/testsuite/ld-undefined/undefine-ignored.c | 10 +++++++ + .../ld-undefined/undefine-ignored.exp | 26 +++++++++++++++++++ + 3 files changed, 43 insertions(+), 4 deletions(-) + create mode 100644 ld/testsuite/ld-undefined/undefine-ignored.c + create mode 100644 ld/testsuite/ld-undefined/undefine-ignored.exp + +diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c +index 459dd0df..5bf528b9 100644 +--- a/bfd/elfnn-loongarch.c ++++ b/bfd/elfnn-loongarch.c +@@ -1201,7 +1201,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) + } + } + +- if (h->root.type == bfd_link_hash_undefweak) ++ if (h->root.type == bfd_link_hash_undefweak || ++ h->root.type == bfd_link_hash_undefined) + { + if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h) + || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT +@@ -1211,7 +1212,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) + { + /* Make sure this symbol is output as a dynamic symbol. + Undefined weak syms won't yet be marked as dynamic. */ +- if (!bfd_elf_link_record_dynamic_symbol (info, h)) ++ if (h->root.type == bfd_link_hash_undefweak && ++ !bfd_elf_link_record_dynamic_symbol (info, h)) + return false; + + if (h->dynindx == -1) +@@ -2303,6 +2305,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + char tls_type; + bfd_vma relocation, off, ie_off; + int i, j; ++ bool ignored = false; + + howto = loongarch_elf_rtype_to_howto (input_bfd, r_type); + if (howto == NULL || r_type == R_LARCH_GNU_VTINHERIT +@@ -2344,8 +2347,8 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + } + else + { +- bool warned, ignored; + ++ bool warned; + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +@@ -2497,7 +2500,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + { + if (h->dynindx == -1) + { +- if (h->root.type == bfd_link_hash_undefined) ++ if (h->root.type == bfd_link_hash_undefined && !ignored) + (*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, + rel->r_offset, true); +diff --git a/ld/testsuite/ld-undefined/undefine-ignored.c b/ld/testsuite/ld-undefined/undefine-ignored.c +new file mode 100644 +index 00000000..7955df04 +--- /dev/null ++++ b/ld/testsuite/ld-undefined/undefine-ignored.c +@@ -0,0 +1,10 @@ ++#include ++// a is R_LARCH_64 type ++extern struct wl_interface a; ++ ++struct wl_interface * b = &a; ++ ++int main(void) ++{ ++ return 0; ++} +diff --git a/ld/testsuite/ld-undefined/undefine-ignored.exp b/ld/testsuite/ld-undefined/undefine-ignored.exp +new file mode 100644 +index 00000000..7975fbdc +--- /dev/null ++++ b/ld/testsuite/ld-undefined/undefine-ignored.exp +@@ -0,0 +1,26 @@ ++set testund "undefined-ignored" ++set testfn "undefined-ignored function" ++set testline "undefined-ignored line" ++ ++if [istarget loongarch*-*-*] { ++ if { ![is_remote host] && [which $CC] == 0 } { ++ verbose "Could not find C compiler!" 1 ++ untested $testund ++ untested $testfn ++ untested $testline ++ } elseif { ![ld_compile "$CC -c" "$srcdir/$subdir/undefine-ignored.c" \ ++ tmpdir/undefine-ignored.o] } { ++ verbose "Unable to compile test file!" 1 ++ unresolved $testund ++ unresolved $testfn ++ unresolved $testline ++ } ++ ++ if { ![is_elf_format] } then { ++ unsupported $testname ++ } elseif {![ld_link $ld tmpdir/a.out \ ++ "-e main --unresolved-symbols=ignore-all tmpdir/undefine-ignored.o"]} then { ++ verbose "ld faile" ++ fail $testname ++ } ++} +-- +2.27.0 + diff --git a/binutils.spec b/binutils.spec index 3a91f9c6aca30281a8748609e6420dfba18747e4..2320bf88d32d4ae3da2862161442741cf86d84d5 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.37 -Release: 12 +Release: 13 License: GPLv3+ URL: https://sourceware.org/binutils @@ -41,6 +41,7 @@ Patch18: backport-PR28422-build_id-use-after-free.patch Patch19: backport-PR28540-segmentation-fault-on-NULL-byte_get.patch %ifarch loongarch64 Patch20: binutils-Add-LoongArch-support.patch +Patch21: Fixup-unresolve-symbols-problem.patch %endif Provides: bundled(libiberty) @@ -383,6 +384,9 @@ fi %{_infodir}/bfd*info* %changelog +* Wed Mar 8 2023 lixing - 2.37-13 +- DESC: Fixup unresolved-symbols=ignore-all problem + * Tue Dec 20 2022 lixing - 2.37-12 - DESC:Add LoongArch support