<div dir="ltr"><div>Can you provide the testcase to show the case which I mentioned in the pr13302?  Which is that an ifunc with a dynamic jump slot calls another ifunc, and are not in the rel.dyn.  Since according to the testcase below, it seems no requirement to apply this fix though.</div><div><br></div><div>Thanks</div><div>Nelson</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">This commit resolved two issues:<br>
<br>
1. When an ifunc is referenced by a pointer, the relocation of<br>
   the pointer in .rela.plt would be overwritten by normal ifunc call.<br>
2. R_RISCV_IRELATIVE should come last.<br>
   See <a href="https://sourceware.org/bugzilla/show_bug.cgi?id=13302" rel="noreferrer" target="_blank">https://sourceware.org/bugzilla/show_bug.cgi?id=13302</a><br>
<br>
This patch fixes above issues with the implementation similar to x86.<br>
That is, by adding two variables to record the next relocation index for<br>
R_RISCV_IRELATIVE and R_RISCV_JUMP_SLOT.<br>
<br>
A previous commit partially fixed the overwrite issue:<br>
<a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=51a8a7c2e3cc0730831963651a55d23d1fae624d" rel="noreferrer" target="_blank">https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=51a8a7c2e3cc0730831963651a55d23d1fae624d</a><br>
<br>
Details below:<br>
<br>
There are three ways to access a local (non-preemptible) ifunc:<br>
(1) Through PLT + GOT, i.e. use normal function call.<br>
(2) Through GOT, i.e. use a local function pointer.<br>
(3) Through a global function pointer.<br>
<br>
For (1) and (2), a R_RISCV_IRELATIVE is created for GOT entry.<br>
For (3), a R_RISCV_IRELATIVE is created for the global pointer.<br>
The relocations overwrite issue is that, the R_RISCV_IRELATIVE created<br>
for (1) overwrite the relocations for (2) and (3).<br>
The previous commit partially fixed the overwrite issue for (2), but not<br>
for (3).<br>
---<br>
 bfd/elfnn-riscv.c                             | 65 +++++++++----------<br>
 ld/testsuite/ld-riscv-elf/ifunc-macro.s       | 19 ++++++<br>
 .../ifunc-plt-got-overwrite-02-exe.rd         |  4 ++<br>
 .../ifunc-plt-got-overwrite-02-pic.rd         | 11 ++++<br>
 .../ifunc-plt-got-overwrite-02-pie.rd         |  7 ++<br>
 .../ld-riscv-elf/ifunc-plt-got-overwrite-02.d | 16 +++++<br>
 .../ld-riscv-elf/ifunc-plt-got-overwrite-02.s | 34 ++++++++++<br>
 ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp    |  7 ++<br>
 ld/testsuite/ld-riscv-elf/variant_cc-now.d    |  4 +-<br>
 ld/testsuite/ld-riscv-elf/variant_cc-shared.d |  4 +-<br>
 10 files changed, 132 insertions(+), 39 deletions(-)<br>
 create mode 100644 ld/testsuite/ld-riscv-elf/ifunc-macro.s<br>
 create mode 100644 ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-exe.rd<br>
 create mode 100644 ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pic.rd<br>
 create mode 100644 ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pie.rd<br>
 create mode 100644 ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.d<br>
 create mode 100644 ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.s<br>
<br>
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c<br>
index 3a30b7a4bd9..d9243648d24 100644<br>
--- a/bfd/elfnn-riscv.c<br>
+++ b/bfd/elfnn-riscv.c<br>
@@ -224,8 +224,12 @@ struct riscv_elf_link_hash_table<br>
   htab_t loc_hash_table;<br>
   void * loc_hash_memory;<br>
<br>
-  /* The index of the last unused .rel.iplt slot.  */<br>
-  bfd_vma last_iplt_index;<br>
+  /* The index of the next R_RISCV_JUMP_SLOT entry in .rela.plt.  */<br>
+  bfd_vma next_jump_slot_index;<br>
+<br>
+  /* R_RISCV_IRELATIVE entry in .rela.plt comes last.<br>
+     Use this to record the index of the next R_RISCV_IRELATIVE entry.  */<br>
+  bfd_vma next_irelative_index;<br>
<br>
   /* The data segment phase, don't relax the section<br>
      when it is exp_seg_relro_adjust.  */<br>
@@ -1273,6 +1277,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)<br>
<br>
          /* We also need to make an entry in the .rela.plt section.  */<br>
          htab->elf.srelplt->size += sizeof (ElfNN_External_Rela);<br>
+         htab->elf.srelplt->reloc_count ++;<br>
<br>
          /* If this symbol is not defined in a regular file, and we are<br>
             not generating a shared library, then set the symbol to this<br>
@@ -1622,10 +1627,14 @@ riscv_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)<br>
      local ifunc symbols.  */<br>
   htab_traverse (htab->loc_hash_table, allocate_local_ifunc_dynrelocs, info);<br>
<br>
-  /* Used to resolve the dynamic relocs overwite problems when<br>
-     generating static executable.  */<br>
-  if (htab->elf.irelplt)<br>
-    htab->last_iplt_index = htab->elf.irelplt->reloc_count - 1;<br>
+<br>
+  htab->next_jump_slot_index = 0;<br>
+<br>
+  if (htab->elf.srelplt)<br>
+    htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1;<br>
+  else if (htab->elf.irelplt)<br>
+    htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1;<br>
+<br>
<br>
   if (htab->elf.sgotplt)<br>
     {<br>
@@ -3201,15 +3210,14 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
<br>
   if (h->plt.offset != (bfd_vma) -1)<br>
     {<br>
-      /* We've decided to create a PLT entry for this symbol.  */<br>
+      /* We've decided to create a PLT entry for this symbol.<br>
+         Add a PLT entry, a GOT entry and a relocation entry.  */<br>
       bfd_byte *loc;<br>
       bfd_vma i, header_address, plt_idx, got_offset, got_address;<br>
       uint32_t plt_entry[PLT_ENTRY_INSNS];<br>
       Elf_Internal_Rela rela;<br>
       asection *plt, *gotplt, *relplt;<br>
<br>
-      /* When building a static executable, use .iplt, .igot.plt and<br>
-        .rela.iplt sections for STT_GNU_IFUNC symbols.  */<br>
       if (htab->elf.splt != NULL)<br>
         {<br>
           plt = htab->elf.splt;<br>
@@ -3218,6 +3226,8 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
         }<br>
       else<br>
         {<br>
+          /* When building a static executable, use .iplt, .igot.plt and<br>
+             .rela.iplt sections for STT_GNU_IFUNC symbols.  */<br>
           plt = htab->elf.iplt;<br>
           gotplt = htab->elf.igotplt;<br>
           relplt = htab->elf.irelplt;<br>
@@ -3238,7 +3248,8 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
       header_address = sec_addr (plt);<br>
<br>
       /* Calculate the index of the entry and the offset of .got.plt entry.<br>
-        For static executables, we don't reserve anything.  */<br>
+         The index of .got.plt is the same as .plt (exclude the header entries),<br>
+         since this section is dedicated for plt.  */<br>
       if (plt == htab->elf.splt)<br>
        {<br>
          plt_idx = (h->plt.offset - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;<br>
@@ -3246,6 +3257,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
        }<br>
       else<br>
        {<br>
+         /* For static executables, we don't need to reserve the header entry.  */<br>
          plt_idx = h->plt.offset / PLT_ENTRY_SIZE;<br>
          got_offset = plt_idx * GOT_ENTRY_SIZE;<br>
        }<br>
@@ -3269,6 +3281,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
       loc = gotplt->contents + (got_address - sec_addr (gotplt));<br>
       bfd_put_NN (output_bfd, sec_addr (plt), loc);<br>
<br>
+      /* Fill in the relocation entry.  */<br>
       rela.r_offset = got_address;<br>
       if (PLT_LOCAL_IFUNC_P (info, h))<br>
        {<br>
@@ -3283,17 +3296,20 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
          rela.r_addend = h->root.u.def.value<br>
                          + sec->output_section->vma<br>
                          + sec->output_offset;<br>
+          bfd_vma rela_idx = htab->next_irelative_index--;<br>
+          loc = relplt->contents + rela_idx * sizeof (ElfNN_External_Rela);<br>
+          bed->s->swap_reloca_out (output_bfd, &rela, loc);<br>
        }<br>
       else<br>
        {<br>
          /* Fill in the entry in the .rela.plt section.  */<br>
          rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_JUMP_SLOT);<br>
          rela.r_addend = 0;<br>
+          bfd_vma rela_idx = htab->next_jump_slot_index++;<br>
+          loc = relplt->contents + rela_idx * sizeof (ElfNN_External_Rela);<br>
+          bed->s->swap_reloca_out (output_bfd, &rela, loc);<br>
        }<br>
<br>
-      loc = relplt->contents + plt_idx * sizeof (ElfNN_External_Rela);<br>
-      bed->s->swap_reloca_out (output_bfd, &rela, loc);<br>
-<br>
       if (!h->def_regular)<br>
        {<br>
          /* Mark the symbol as undefined, rather than as defined in<br>
@@ -3315,7 +3331,6 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
       asection *sgot;<br>
       asection *srela;<br>
       Elf_Internal_Rela rela;<br>
-      bool use_elf_append_rela = true;<br>
<br>
       /* This symbol has an entry in the GOT.  Set it up.  */<br>
<br>
@@ -3338,10 +3353,6 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
                  /* Use .rela.iplt section to store .got relocations<br>
                     in static executable.  */<br>
                  srela = htab->elf.irelplt;<br>
-<br>
-                 /* Do not use riscv_elf_append_rela to add dynamic<br>
-                    relocs.  */<br>
-                 use_elf_append_rela = false;<br>
                }<br>
<br>
              if (SYMBOL_REFERENCES_LOCAL (info, h))<br>
@@ -3417,23 +3428,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,<br>
       bfd_put_NN (output_bfd, 0,<br>
                  sgot->contents + (h->got.offset & ~(bfd_vma) 1));<br>
<br>
-      if (use_elf_append_rela)<br>
-       riscv_elf_append_rela (output_bfd, srela, &rela);<br>
-      else<br>
-       {<br>
-         /* Use riscv_elf_append_rela to add the dynamic relocs into<br>
-            .rela.iplt may cause the overwrite problems.  Since we insert<br>
-            the relocs for PLT didn't handle the reloc_index of .rela.iplt,<br>
-            but the riscv_elf_append_rela adds the relocs to the place<br>
-            that are calculated from the reloc_index (in seqential).<br>
-<br>
-            One solution is that add these dynamic relocs (GOT IFUNC)<br>
-            from the last of .rela.iplt section.  */<br>
-         bfd_vma iplt_idx = htab->last_iplt_index--;<br>
-         bfd_byte *loc = srela->contents<br>
-                         + iplt_idx * sizeof (ElfNN_External_Rela);<br>
-         bed->s->swap_reloca_out (output_bfd, &rela, loc);<br>
-       }<br>
+      riscv_elf_append_rela (output_bfd, srela, &rela);<br>
     }<br>
<br>
   if (h->needs_copy)<br>
diff --git a/ld/testsuite/ld-riscv-elf/ifunc-macro.s b/ld/testsuite/ld-riscv-elf/ifunc-macro.s<br>
new file mode 100644<br>
index 00000000000..88935a55814<br>
--- /dev/null<br>
+++ b/ld/testsuite/ld-riscv-elf/ifunc-macro.s<br>
@@ -0,0 +1,19 @@<br>
+/* Define macros to handle similar behaviors for rv32/rv64.<br>
+   Assumes macro "__64_bit__" defined for rv64.<br>
+   The macro is specifically defined for ifunc tests in ld-riscv-elf.exp. */<br>
+<br>
+.macro PTR_DATA name<br>
+.ifdef __64_bit__<br>
+       .quad   \name<br>
+.else<br>
+       .long   \name<br>
+.endif<br>
+.endm<br>
+<br>
+.macro LOAD rd, rs, offset<br>
+.ifdef __64_bit__<br>
+       ld      \rd, \offset (\rs)<br>
+.else<br>
+       lw      \rd, \offset (\rs)<br>
+.endif<br>
+.endm<br>
diff --git a/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-exe.rd b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-exe.rd<br>
new file mode 100644<br>
index 00000000000..0de47a4009f<br>
--- /dev/null<br>
+++ b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-exe.rd<br>
@@ -0,0 +1,4 @@<br>
+Relocation section '.rela.plt' at .*<br>
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+[0-9a-f]*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+[0-9a-f]*<br>
diff --git a/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pic.rd b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pic.rd<br>
new file mode 100644<br>
index 00000000000..d7ecd4a4a69<br>
--- /dev/null<br>
+++ b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pic.rd<br>
@@ -0,0 +1,11 @@<br>
+Relocation section '.rela.got' at .*<br>
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_(32|64)[      ]+foo1\(\)[     ]+foo1 \+ 0<br>
+#...<br>
+Relocation section '.rela.ifunc' at .*<br>
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_(32|64)[      ]+foo2\(\)[     ]+foo2 \+ 0<br>
+#...<br>
+Relocation section '.rela.plt' at .*<br>
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+foo1\(\)[     ]+foo1 \+ 0<br>
diff --git a/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pie.rd b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pie.rd<br>
new file mode 100644<br>
index 00000000000..532cbf8a86a<br>
--- /dev/null<br>
+++ b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02-pie.rd<br>
@@ -0,0 +1,7 @@<br>
+Relocation section '.rela.ifunc' at .*<br>
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+[0-9a-f]*<br>
+<br>
+Relocation section '.rela.plt' at .*<br>
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+[0-9a-f]*<br>
diff --git a/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.d b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.d<br>
new file mode 100644<br>
index 00000000000..3e33ac619d4<br>
--- /dev/null<br>
+++ b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.d<br>
@@ -0,0 +1,16 @@<br>
+#...<br>
+Disassembly of section .plt:<br>
+#...<br>
+0+[0-9a-f]+ <(\*ABS\*\+0x[0-9a-f]+@plt|foo@plt|.plt)>:<br>
+#...<br>
+Disassembly of section .text:<br>
+#...<br>
+0+[0-9a-f]+ <foo_resolver>:<br>
+.*:[   ]+[0-9a-f]+[    ]+ret<br>
+<br>
+0+[0-9a-f]+ <_start>:<br>
+.*:[   ]+[0-9a-f]+[    ]+auipc[        ]+.*<br>
+.*:[   ]+[0-9a-f]+[    ]+(lw|ld)[      ]+.*<(.*)><br>
+.*:[   ]+[0-9a-f]+[    ]+auipc[        ]+.*<br>
+.*:[   ]+[0-9a-f]+[    ]+jalr[         ]+.*<(.*plt.*)><br>
+.*:[   ]+[0-9a-f]+[    ]+ret<br>
diff --git a/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.s b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.s<br>
new file mode 100644<br>
index 00000000000..ff6d171591c<br>
--- /dev/null<br>
+++ b/ld/testsuite/ld-riscv-elf/ifunc-plt-got-overwrite-02.s<br>
@@ -0,0 +1,34 @@<br>
+/* There are 2 ifuncs: foo1 and foo2.<br>
+   foo1 is accessed by a function call.<br>
+   foo2 is referenced by a global pointer (foo2_addr).  */<br>
+       .include "ifunc-macro.s"<br>
+       .globl foo2_addr<br>
+       .section        .data<br>
+       .type   foo2_addr, @object<br>
+foo2_addr:<br>
+       PTR_DATA foo2<br>
+<br>
+       .text<br>
+       .type   foo_resolver, @function<br>
+foo_resolver:<br>
+       ret<br>
+       .size   foo_resolver, .-foo_resolver<br>
+<br>
+       .globl  foo1<br>
+       .type   foo1, %gnu_indirect_function<br>
+       .set    foo1, foo_resolver<br>
+<br>
+       .globl  foo2<br>
+       .type   foo2, %gnu_indirect_function<br>
+       .set    foo2, foo_resolver<br>
+<br>
+       .globl  _start<br>
+       .type   _start, @function<br>
+_start:<br>
+.L1:<br>
+       auipc   x1, %got_pcrel_hi (foo1)<br>
+       LOAD    x1, x1, %pcrel_lo (.L1)<br>
+       call    foo1<br>
+<br>
+       ret<br>
+       .size   _start, .-_start<br>
diff --git a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp<br>
index a1dd0e5e37e..10011445683 100644<br>
--- a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp<br>
+++ b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp<br>
@@ -284,6 +284,13 @@ if [istarget "riscv*-*-*"] {<br>
     run_dump_test_ifunc "ifunc-plt-got-overwrite" rv64 pie<br>
     run_dump_test_ifunc "ifunc-plt-got-overwrite" rv64 pic<br>
<br>
+    run_dump_test_ifunc "ifunc-plt-got-overwrite-02" rv32 exe<br>
+    run_dump_test_ifunc "ifunc-plt-got-overwrite-02" rv32 pie<br>
+    run_dump_test_ifunc "ifunc-plt-got-overwrite-02" rv32 pic<br>
+    run_dump_test_ifunc "ifunc-plt-got-overwrite-02" rv64 exe<br>
+    run_dump_test_ifunc "ifunc-plt-got-overwrite-02" rv64 pie<br>
+    run_dump_test_ifunc "ifunc-plt-got-overwrite-02" rv64 pic<br>
+<br>
     # TODO: Make the following tests work under RV32.<br>
     if [istarget "riscv32-*-*"] {<br>
       return<br>
diff --git a/ld/testsuite/ld-riscv-elf/variant_cc-now.d b/ld/testsuite/ld-riscv-elf/variant_cc-now.d<br>
index 9453554a159..3ed5ab3cae0 100644<br>
--- a/ld/testsuite/ld-riscv-elf/variant_cc-now.d<br>
+++ b/ld/testsuite/ld-riscv-elf/variant_cc-now.d<br>
@@ -7,11 +7,11 @@ Relocation section '.rela.plt' at .*<br>
 #...<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+0000[       ]+nocc_global_default_undef \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+0000[       ]+cc_global_default_undef \+ 0<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+8000[       ]+cc_global_default_def \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+8000[       ]+nocc_global_default_def \+ 0<br>
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8000<br>
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8000<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8050<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8050<br>
diff --git a/ld/testsuite/ld-riscv-elf/variant_cc-shared.d b/ld/testsuite/ld-riscv-elf/variant_cc-shared.d<br>
index ffb69a392f2..6b73cf1de20 100644<br>
--- a/ld/testsuite/ld-riscv-elf/variant_cc-shared.d<br>
+++ b/ld/testsuite/ld-riscv-elf/variant_cc-shared.d<br>
@@ -7,11 +7,11 @@ Relocation section '.rela.plt' at .*<br>
 #...<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+0000[       ]+nocc_global_default_undef \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+0000[       ]+cc_global_default_undef \+ 0<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0<br>
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+8000[       ]+cc_global_default_def \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+0+8000[       ]+nocc_global_default_def \+ 0<br>
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8000<br>
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_JUMP_SLOT[    ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8000<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8050<br>
 [0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_IRELATIVE[    ]+8050<br>
-- <br>
2.37.1<br>
<br>
</blockquote></div></div>