From e56ebe4f4a2c84fb1e3852aff8e1a8d90ff48539 Mon Sep 17 00:00:00 2001 From: Xing Li Date: Sat, 20 May 2023 11:04:08 +0800 Subject: [PATCH] LoongArch: Fix PLT entry generate bug --- LoongArch-Fix-PLT-entry-generate-bug.patch | 35 ++++++++++++++++++++++ binutils.spec | 6 +++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 LoongArch-Fix-PLT-entry-generate-bug.patch diff --git a/LoongArch-Fix-PLT-entry-generate-bug.patch b/LoongArch-Fix-PLT-entry-generate-bug.patch new file mode 100644 index 0000000..c5bd9fb --- /dev/null +++ b/LoongArch-Fix-PLT-entry-generate-bug.patch @@ -0,0 +1,35 @@ +diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c +index a623aa32..dc9f4e49 100644 +--- a/bfd/elfnn-loongarch.c ++++ b/bfd/elfnn-loongarch.c +@@ -980,7 +980,7 @@ loongarch_elf_adjust_dynamic_symbol (struct bfd_link_info *info, + (although we could actually do it here). */ + if (h->type == STT_FUNC || h->type == STT_GNU_IFUNC || h->needs_plt) + { +- if (h->plt.refcount < 0 ++ if (h->plt.refcount <= 0 + || (h->type != STT_GNU_IFUNC + && (SYMBOL_REFERENCES_LOCAL (info, h) + || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT +@@ -993,8 +993,6 @@ loongarch_elf_adjust_dynamic_symbol (struct bfd_link_info *info, + h->plt.offset = MINUS_ONE; + h->needs_plt = 0; + } +- else +- h->needs_plt = 1; + + return true; + } +diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp +index 8b7069c2..718416b0 100644 +--- a/ld/testsuite/ld-elf/shared.exp ++++ b/ld/testsuite/ld-elf/shared.exp +@@ -502,7 +502,7 @@ run_ld_link_tests [list \ + # but that is just an optimization so don't complain loudly. + setup_xfail *-*-* + clear_xfail alpha-*-* bfin-*-linux* csky-*-* frv-*-* hppa*-*-* i?86-*-* +-clear_xfail ia64-*-* microblaze-*-* powerpc*-*-* x86_64-*-* xtensa-*-* ++clear_xfail ia64-*-* loongarch*-*-* microblaze-*-* powerpc*-*-* x86_64-*-* xtensa-*-* + run_ld_link_tests { + {"pr22374 function pointer initialization" + "" "tmpdir/pr22374.so" "" "pr22374a.s" diff --git a/binutils.spec b/binutils.spec index e6babb8..4205d6c 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.37 -Release: 14 +Release: 15 License: GPLv3+ URL: https://sourceware.org/binutils @@ -42,6 +42,7 @@ Patch19: backport-PR28540-segmentation-fault-on-NULL-byte_get.patch %ifarch loongarch64 Patch20: binutils-Add-LoongArch-support.patch Patch21: Fixup-unresolve-symbols-problem.patch +Patch23: LoongArch-Fix-PLT-entry-generate-bug.patch %endif Patch22: Fix-gold-relocation-offset-and-adrp-signed-shife.patch @@ -385,6 +386,9 @@ fi %{_infodir}/bfd*info* %changelog +* Sat May 20 2023 lixing - 2.37-15 +- DESC: Fix LoongArch PLT entry generate bug + * Wed Apr 19 2023 dingguangya - 2.37-14 - Type:bugfix - ID:NA -- Gitee