public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Hau Hsu <hau.hsu@sifive.com>
To: binutils@sourceware.org, kito.cheng@gmail.com, hau.hsu@sifive.com
Subject: [PATCH 1/2] riscv: Add POINTER_LOCAL_IFUNC_P/PLT_LOCAL_IFUNC_P
Date: Mon,  6 May 2024 12:45:19 +0800	[thread overview]
Message-ID: <20240506044520.2780464-1-hau.hsu@sifive.com> (raw)

Add POINTER_LOCAL_IFUNC_P which returns TRUE for pointer reference to
local IFUNC symbol.
Add PLT_LOCAL_IFUNC_P which returns TRUE for PLT reference to local
IFUNC symbol.

Copied from x86 commit: cf1070f1a1ca1f8be1cd88aa6ece55a25e6a887b
---
 bfd/elfnn-riscv.c | 11 ++---------
 bfd/elfxx-riscv.h | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 95abf2d10e2..3a30b7a4bd9 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2373,9 +2373,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
 		    outrel.r_offset += input_section->output_section->vma
 				       + input_section->output_offset;
 
-		    if (h->dynindx == -1
-			|| h->forced_local
-			|| bfd_link_executable (info))
+		    if (POINTER_LOCAL_IFUNC_P (info, h))
 		      {
 			info->callbacks->minfo
 			  (_("Local IFUNC function `%s' in %pB\n"),
@@ -3272,12 +3270,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
       bfd_put_NN (output_bfd, sec_addr (plt), loc);
 
       rela.r_offset = got_address;
-
-      if (h->dynindx == -1
-	  || ((bfd_link_executable (info)
-	       || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
-	      && h->def_regular
-	      && h->type == STT_GNU_IFUNC))
+      if (PLT_LOCAL_IFUNC_P (info, h))
 	{
 	  info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"),
 				  h->root.root.string,
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h
index 49be71746b9..9efac27864c 100644
--- a/bfd/elfxx-riscv.h
+++ b/bfd/elfxx-riscv.h
@@ -27,6 +27,20 @@
 
 #define RISCV_UNKNOWN_VERSION -1
 
+/* TRUE if this is a pointer reference to a local IFUNC.  */
+#define POINTER_LOCAL_IFUNC_P(INFO, H) \
+  ((H)->dynindx == -1 \
+   || (H)->forced_local \
+   || bfd_link_executable (INFO))
+
+/* TRUE if this is a PLT reference to a local IFUNC.  */
+#define PLT_LOCAL_IFUNC_P(INFO, H) \
+  ((H)->dynindx == -1 \
+   || ((bfd_link_executable (INFO) \
+	|| ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \
+	&& (H)->def_regular \
+	&& (H)->type == STT_GNU_IFUNC))
+
 struct riscv_elf_params
 {
   /* Whether to relax code sequences to GP-relative addressing.  */
-- 
2.37.1


             reply	other threads:[~2024-05-06  4:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06  4:45 Hau Hsu [this message]
2024-05-06  4:45 ` [PATCH 2/2] riscv: Fix R_RISCV_IRELATIVE overwrite and order issues Hau Hsu
2024-05-08  1:00   ` Nelson Chu
2024-05-16  6:16     ` Hau Hsu
2024-05-16  7:07       ` Nelson Chu
2024-05-16  7:30         ` Hau Hsu
2024-05-16  8:28           ` Nelson Chu
2024-05-17  2:32             ` Hau Hsu
2024-05-23  3:53               ` Hau Hsu
2024-05-23  6:43                 ` Nelson Chu
2024-05-08  1:03 ` [PATCH 1/2] riscv: Add POINTER_LOCAL_IFUNC_P/PLT_LOCAL_IFUNC_P Nelson Chu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240506044520.2780464-1-hau.hsu@sifive.com \
    --to=hau.hsu@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=kito.cheng@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).