RISC-V: Always generate R_RISCV_CALL_PLT reloc for call in assembler.
authorNelson Chu <nelson@rivosinc.com>
Wed, 14 Sep 2022 02:25:44 +0000 (10:25 +0800)
committerNelson Chu <nelson@rivosinc.com>
Wed, 21 Sep 2022 01:45:58 +0000 (09:45 +0800)
Since we have the same behaviors of CALL and CALL_PLT relocs in linker for now,
https://github.com/bminor/binutils-gdb/commit/3b1450b38c644f99aa2e211747b428b9f8d15cca

And the psabi already deprecate the CALL reloc,
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018d7a0ec17023c9389cbd70b1dbc1b0

Therefore, we should always generate R_RISCV_CALL_PLT reloc for call, even if
it has @plt postfix.  I believe LLVM (https://reviews.llvm.org/D132530) already
support this, so GNU as should do the same thing.

gas/
* config/tc-riscv.c (riscv_ip): Always generate CALL_PLT reloc for
call, even if it has @plt postfix.
* testsuite/gas/riscv/no-relax-reloc.d: Updated CALL to CALL_PLT.
* testsuite/gas/riscv/relax-reloc.d: Likewise.
ld/
* testsuite/ld-riscv-elf/variant_cc-r.d: Updated CALL to CALL_PLT.

gas/config/tc-riscv.c
gas/testsuite/gas/riscv/no-relax-reloc.d
gas/testsuite/gas/riscv/relax-reloc.d
ld/testsuite/ld-riscv-elf/variant_cc-r.d

index 2f5ee18e451e895b990f8f4cb5dee07f54f6a451..629d4be0624f3e6ea135d9ebde3c9fdf71e17fd5 100644 (file)
@@ -3113,12 +3113,8 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
              my_getExpression (imm_expr, asarg);
              asarg = expr_end;
              if (strcmp (asarg, "@plt") == 0)
-               {
-                 *imm_reloc = BFD_RELOC_RISCV_CALL_PLT;
-                 asarg += 4;
-               }
-             else
-               *imm_reloc = BFD_RELOC_RISCV_CALL;
+               asarg += 4;
+             *imm_reloc = BFD_RELOC_RISCV_CALL_PLT;
              continue;
 
            case 'O':
index c2ca1aa6e7213dcc6b82816398db1d5f87c23783..d7269a71037ef54027603a709188c3e7f353ff92 100644 (file)
@@ -11,4 +11,4 @@ RELOCATION RECORDS FOR .*
 0+c R_RISCV_PCREL_LO12_I.*
 0+10 R_RISCV_GOT_HI20.*
 0+14 R_RISCV_PCREL_LO12_I.*
-0+18 R_RISCV_CALL.*
+0+18 R_RISCV_CALL_PLT.*
index 623218ec5d15271d002e1186c9b6a26df8d1f49e..4a368806066b686134f15de5d5ada169d912d1ba 100644 (file)
@@ -16,5 +16,5 @@ RELOCATION RECORDS FOR .*
 0+10 R_RISCV_GOT_HI20.*
 0+14 R_RISCV_PCREL_LO12_I.*
 0+14 R_RISCV_RELAX.*
-0+18 R_RISCV_CALL.*
+0+18 R_RISCV_CALL_PLT.*
 0+18 R_RISCV_RELAX.*
index 5235b8e90d7a3424e1e21bd879b7f66a87b4a2c3..7df449bfd2a738d5cdb84e0384a485cea38eb793 100644 (file)
@@ -6,34 +6,34 @@
 
 Relocation section '.rela.text' at .*
 #...
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_global_default_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_global_default_undef \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_global_hidden_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+cc_global_hidden_ifunc\(\)[   ]+cc_global_hidden_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_local \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+cc_local_ifunc\(\)[   ]+cc_local_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_global_default_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_global_default_undef \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_global_hidden_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+nocc_global_hidden_ifunc\(\)[         ]+nocc_global_hidden_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_local \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+nocc_local_ifunc\(\)[         ]+nocc_local_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_global_default_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_global_default_undef \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+cc_global_hidden_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+cc_global_hidden_ifunc\(\)[   ]+cc_global_hidden_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0070[       ]+cc_local2 \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+cc_local2_ifunc\(\)[  ]+cc_local2_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_global_default_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_global_default_undef \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0000[       ]+nocc_global_hidden_def \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+nocc_global_hidden_ifunc\(\)[         ]+nocc_global_hidden_ifunc \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+0+0070[       ]+nocc_local2 \+ 0
-[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL[         ]+nocc_local2_ifunc\(\)[        ]+nocc_local2_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_global_default_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_global_default_undef \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_global_hidden_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+cc_global_hidden_ifunc\(\)[   ]+cc_global_hidden_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_local \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+cc_local_ifunc\(\)[   ]+cc_local_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_global_default_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_global_default_undef \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_global_hidden_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+nocc_global_hidden_ifunc\(\)[         ]+nocc_global_hidden_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_local \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+nocc_local_ifunc\(\)[         ]+nocc_local_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_global_default_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_global_default_undef \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+cc_global_hidden_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+cc_global_default_ifunc\(\)[  ]+cc_global_default_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+cc_global_hidden_ifunc\(\)[   ]+cc_global_hidden_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0070[       ]+cc_local2 \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+cc_local2_ifunc\(\)[  ]+cc_local2_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_global_default_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_global_default_undef \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0000[       ]+nocc_global_hidden_def \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+nocc_global_default_ifunc\(\)[        ]+nocc_global_default_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+nocc_global_hidden_ifunc\(\)[         ]+nocc_global_hidden_ifunc \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+0+0070[       ]+nocc_local2 \+ 0
+[0-9a-f]+[     ]+[0-9a-f]+[    ]+R_RISCV_CALL_PLT[     ]+nocc_local2_ifunc\(\)[        ]+nocc_local2_ifunc \+ 0
 #...
 Symbol table '.symtab' contains .*
 .*