From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7803) id ABCCA3858D38; Wed, 21 Sep 2022 03:47:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABCCA3858D38 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nelson Chu To: bfd-cvs@sourceware.org Subject: [binutils-gdb] RISC-V: Always generate R_RISCV_CALL_PLT reloc for call in assembler. X-Act-Checkin: binutils-gdb X-Git-Author: Nelson Chu X-Git-Refname: refs/heads/master X-Git-Oldrev: e348122963d188295fcdd3758a112f1e089d1d14 X-Git-Newrev: 70f35d72ef04cd23771875c1661c9975044a749c Message-Id: <20220921034701.ABCCA3858D38@sourceware.org> Date: Wed, 21 Sep 2022 03:47:01 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2022 03:47:01 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D70f35d72ef04= cd23771875c1661c9975044a749c commit 70f35d72ef04cd23771875c1661c9975044a749c Author: Nelson Chu Date: Wed Sep 14 10:25:44 2022 +0800 RISC-V: Always generate R_RISCV_CALL_PLT reloc for call in assembler. =20 Since we have the same behaviors of CALL and CALL_PLT relocs in linker = for now, https://github.com/bminor/binutils-gdb/commit/3b1450b38c644f99aa2e21174= 7b428b9f8d15cca =20 And the psabi already deprecate the CALL reloc, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018= d7a0ec17023c9389cbd70b1dbc1b0 =20 Therefore, we should always generate R_RISCV_CALL_PLT reloc for call, e= ven if it has @plt postfix. I believe LLVM (https://reviews.llvm.org/D132530)= already support this, so GNU as should do the same thing. =20 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_PL= T. * testsuite/gas/riscv/relax-reloc.d: Likewise. ld/ * testsuite/ld-riscv-elf/variant_cc-r.d: Updated CALL to CALL_P= LT. Diff: --- gas/config/tc-riscv.c | 8 ++--- gas/testsuite/gas/riscv/no-relax-reloc.d | 2 +- gas/testsuite/gas/riscv/relax-reloc.d | 2 +- ld/testsuite/ld-riscv-elf/variant_cc-r.d | 56 ++++++++++++++++------------= ---- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 2f5ee18e451..629d4be0624 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -3113,12 +3113,8 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expre= ssionS *imm_expr, my_getExpression (imm_expr, asarg); asarg =3D expr_end; if (strcmp (asarg, "@plt") =3D=3D 0) - { - *imm_reloc =3D BFD_RELOC_RISCV_CALL_PLT; - asarg +=3D 4; - } - else - *imm_reloc =3D BFD_RELOC_RISCV_CALL; + asarg +=3D 4; + *imm_reloc =3D BFD_RELOC_RISCV_CALL_PLT; continue; =20 case 'O': diff --git a/gas/testsuite/gas/riscv/no-relax-reloc.d b/gas/testsuite/gas/r= iscv/no-relax-reloc.d index c2ca1aa6e72..d7269a71037 100644 --- a/gas/testsuite/gas/riscv/no-relax-reloc.d +++ b/gas/testsuite/gas/riscv/no-relax-reloc.d @@ -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.* diff --git a/gas/testsuite/gas/riscv/relax-reloc.d b/gas/testsuite/gas/risc= v/relax-reloc.d index 623218ec5d1..4a368806066 100644 --- a/gas/testsuite/gas/riscv/relax-reloc.d +++ b/gas/testsuite/gas/riscv/relax-reloc.d @@ -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.* diff --git a/ld/testsuite/ld-riscv-elf/variant_cc-r.d b/ld/testsuite/ld-ris= cv-elf/variant_cc-r.d index 5235b8e90d7..7df449bfd2a 100644 --- a/ld/testsuite/ld-riscv-elf/variant_cc-r.d +++ b/ld/testsuite/ld-riscv-elf/variant_cc-r.d @@ -6,34 +6,34 @@ =20 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_d= ef \+ 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_loc= al_ifunc \+ 0 -[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL[ ]+0+0000[ ]+nocc_global_defaul= t_def \+ 0 -[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL[ ]+0+0000[ ]+nocc_global_defaul= t_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_d= ef \+ 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_lo= cal2_ifunc \+ 0 -[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL[ ]+0+0000[ ]+nocc_global_defaul= t_def \+ 0 -[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL[ ]+0+0000[ ]+nocc_global_defaul= t_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\(\)[ ]+noc= c_local2_ifunc \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+cc_global_defa= ult_def \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+cc_global_defa= ult_undef \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+cc_global_hidd= en_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_de= fault_def \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+nocc_global_de= fault_undef \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+nocc_global_hi= dden_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_defa= ult_def \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+cc_global_defa= ult_undef \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+cc_global_hidd= en_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\(\)[ ]+c= c_local2_ifunc \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+nocc_global_de= fault_def \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+nocc_global_de= fault_undef \+ 0 +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_RISCV_CALL_PLT[ ]+0+0000[ ]+nocc_global_hi= dden_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 .* .*