public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] riscv: Add POINTER_LOCAL_IFUNC_P/PLT_LOCAL_IFUNC_P
@ 2024-05-06  4:45 Hau Hsu
  2024-05-06  4:45 ` [PATCH 2/2] riscv: Fix R_RISCV_IRELATIVE overwrite and order issues Hau Hsu
  2024-05-08  1:03 ` [PATCH 1/2] riscv: Add POINTER_LOCAL_IFUNC_P/PLT_LOCAL_IFUNC_P Nelson Chu
  0 siblings, 2 replies; 11+ messages in thread
From: Hau Hsu @ 2024-05-06  4:45 UTC (permalink / raw)
  To: binutils, kito.cheng, hau.hsu

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-05-23  6:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06  4:45 [PATCH 1/2] riscv: Add POINTER_LOCAL_IFUNC_P/PLT_LOCAL_IFUNC_P Hau Hsu
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

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).