<div dir="ltr">I think it's fine to keep the old code since it's the same as aarch64 code.<div><br></div><div>Nelson</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 6, 2024 at 12:46 PM Hau Hsu <<a href="mailto:hau.hsu@sifive.com">hau.hsu@sifive.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Add POINTER_LOCAL_IFUNC_P which returns TRUE for pointer reference to<br>
local IFUNC symbol.<br>
Add PLT_LOCAL_IFUNC_P which returns TRUE for PLT reference to local<br>
IFUNC symbol.<br>
<br>
Copied from x86 commit: cf1070f1a1ca1f8be1cd88aa6ece55a25e6a887b<br>
---<br>
bfd/elfnn-riscv.c | 11 ++---------<br>
bfd/elfxx-riscv.h | 14 ++++++++++++++<br>
2 files changed, 16 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c<br>
index 95abf2d10e2..3a30b7a4bd9 100644<br>
--- a/bfd/elfnn-riscv.c<br>
+++ b/bfd/elfnn-riscv.c<br>
@@ -2373,9 +2373,7 @@ riscv_elf_relocate_section (bfd *output_bfd,<br>
outrel.r_offset += input_section->output_section->vma<br>
+ input_section->output_offset;<br>
<br>
- if (h->dynindx == -1<br>
- || h->forced_local<br>
- || bfd_link_executable (info))<br>
+ if (POINTER_LOCAL_IFUNC_P (info, h))<br>
{<br>
info->callbacks->minfo<br>
(_("Local IFUNC function `%s' in %pB\n"),<br>
@@ -3272,12 +3270,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
bfd_put_NN (output_bfd, sec_addr (plt), loc);<br>
<br>
rela.r_offset = got_address;<br>
-<br>
- if (h->dynindx == -1<br>
- || ((bfd_link_executable (info)<br>
- || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)<br>
- && h->def_regular<br>
- && h->type == STT_GNU_IFUNC))<br>
+ if (PLT_LOCAL_IFUNC_P (info, h))<br>
{<br>
info->callbacks->minfo (_("Local IFUNC function `%s' in %pB\n"),<br>
h->root.root.string,<br>
diff --git a/bfd/elfxx-riscv.h b/bfd/elfxx-riscv.h<br>
index 49be71746b9..9efac27864c 100644<br>
--- a/bfd/elfxx-riscv.h<br>
+++ b/bfd/elfxx-riscv.h<br>
@@ -27,6 +27,20 @@<br>
<br>
#define RISCV_UNKNOWN_VERSION -1<br>
<br>
+/* TRUE if this is a pointer reference to a local IFUNC. */<br>
+#define POINTER_LOCAL_IFUNC_P(INFO, H) \<br>
+ ((H)->dynindx == -1 \<br>
+ || (H)->forced_local \<br>
+ || bfd_link_executable (INFO))<br>
+<br>
+/* TRUE if this is a PLT reference to a local IFUNC. */<br>
+#define PLT_LOCAL_IFUNC_P(INFO, H) \<br>
+ ((H)->dynindx == -1 \<br>
+ || ((bfd_link_executable (INFO) \<br>
+ || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT) \<br>
+ && (H)->def_regular \<br>
+ && (H)->type == STT_GNU_IFUNC))<br>
+<br>
struct riscv_elf_params<br>
{<br>
/* Whether to relax code sequences to GP-relative addressing. */<br>
-- <br>
2.37.1<br>
<br>
</blockquote></div>