From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 4223F3858C53 for ; Wed, 21 Sep 2022 03:48:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4223F3858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-oi1-x230.google.com with SMTP id r125so6447924oia.8 for ; Tue, 20 Sep 2022 20:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=Ok3caHdbBzHoDS71oqmLj4lbcR/lISb2ISNNJwF6Fhk=; b=sAwwf+C2IYvIyySPGiJsCor0STjMm6Fp39YzuHRyJQMEW9hPtj7jdSb9TYj5+GNQda RjJKVtSzzZVZfQfqlIXjZrA3M/ecpEcz2iGC9IZcMDVXiMk40reUZ+Nq13OBMV3kBNAO KEeKQ4Go4zA8Nsw4UrpVbFW0TDcn/nHOhU0M6zSK8niuDQey613hZTx3Szas9t5HX3Zf v+nGLJiFi113Ju9dlBFDSI8KMK49dmx+g6bkkv58S8q9goUKGlvBwIKgDN2yWovjQBAO cEbxtx0BcfMrkEkCjzH15NwLSX0qKmVDf2+Wbotfq3JaGBU0JGVgOlMtFnByn5T0rAPv OUGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=Ok3caHdbBzHoDS71oqmLj4lbcR/lISb2ISNNJwF6Fhk=; b=614P+94q65uOP+Emf+7hAPfDv9A6H6H1/0/0Ez6T8iuiTl7Za4LYAp3A1nfWTdVr+G Z2DEGVFjERk6HY2w24i5Ug4vfRBfOeRR/lW7wK17YVscrG+ZTFyg11zDp8YdUw0SfieG fE6I8Pn+tETXa4n2TlHTyhR478Xs8f+LiucgKzU3yiHQ2IFUdjz+KRvJOSuBlEmki/g6 wM+PARvCZtkKVK7rBgPOrqseyZ4SIigQ45vY277A9kxuyMo6khCEbD5xqmyoxV7djeQD sJuIh5R9RamDwkS9GkicCzsqbC6yfCr68ZhobmggwEKR6oZWIUyjH6H27CBkG4B7hNmp Nqrw== X-Gm-Message-State: ACrzQf39jp76iaIgZId6Q1oJ2mQTmTJuXHDpnU3sZ5ZgUmpHkmDhLFmt nn7P5Sf88vpILMvh6Ak06fTEfEweAuyXr5ZOPgjj6wW0uPY= X-Google-Smtp-Source: AMsMyM4aR3bUXdUF2uNRGhsXLs6nIQZuMZMxjLpUH2OXt/KzZ2+l8cmkWAdCyKeP8p0lxoWnSbDOtOtCYPGx+4e1Yng= X-Received: by 2002:a05:6808:bca:b0:350:b22b:1283 with SMTP id o10-20020a0568080bca00b00350b22b1283mr3106394oik.82.1663732138329; Tue, 20 Sep 2022 20:48:58 -0700 (PDT) MIME-Version: 1.0 References: <20220914032202.23984-1-nelson@rivosinc.com> In-Reply-To: <20220914032202.23984-1-nelson@rivosinc.com> From: Nelson Chu Date: Wed, 21 Sep 2022 11:48:47 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: Always generate R_RISCV_CALL_PLT reloc for call in assembler. To: binutils@sourceware.org Cc: kito.cheng@gmail.com, jrtc27@jrtc27.com, i@maskray.me Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Committed since it seems like there are no objections for now. Thanks Nelson On Wed, Sep 14, 2022 at 11:22 AM Nelson Chu wrote: > > 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 | 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 df2e201fb74..ad51560a670 100644 > --- a/gas/config/tc-riscv.c > +++ b/gas/config/tc-riscv.c > @@ -3116,12 +3116,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': > diff --git a/gas/testsuite/gas/riscv/no-relax-reloc.d b/gas/testsuite/gas/riscv/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/riscv/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-riscv-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 @@ > > 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 .* > .* > -- > 2.32.1 (Apple Git-133) >