I think it's fine to keep the old code since it's the same as aarch64 code. Nelson On Mon, May 6, 2024 at 12:46 PM Hau Hsu wrote: > 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 > >