public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] LoongArch: Fix PLT entry generate bug
@ 2023-05-15  1:33 liu & zhensong
  0 siblings, 0 replies; only message in thread
From: liu & zhensong @ 2023-05-15  1:33 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6a1cf1bfedbcdb977d9ead3bf6a228360d78cc1b

commit 6a1cf1bfedbcdb977d9ead3bf6a228360d78cc1b
Author: mengqinggang <mengqinggang@loongson.cn>
Date:   Thu May 11 18:03:54 2023 +0800

    LoongArch: Fix PLT entry generate bug
    
    If a function symbol only get its address by la.global, without
    directly called by bl instruction, the PLT entry is not required.
    
    bfd/ChangeLog:
    
            * elfnn-loongarch.c (loongarch_elf_adjust_dynamic_symbol): Fix PLT
            entry generate bug.
    
    ld/ChangeLog:
    
            * testsuite/ld-elf/shared.exp: Clear xfail for LoongArch.

Diff:
---
 bfd/elfnn-loongarch.c          | 4 +---
 ld/testsuite/ld-elf/shared.exp | 3 ++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index b0f9b6ec69e..3fb74edb45c 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 db9d71398de..1eef9f45667 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -504,7 +504,8 @@ 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-*-*
+clear_xfail xtensa-*-*
 run_ld_link_tests {
     {"pr22374 function pointer initialization"
 	"" "tmpdir/pr22374.so" "" "pr22374a.s"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-15  1:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15  1:33 [binutils-gdb] LoongArch: Fix PLT entry generate bug liu & zhensong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).