From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id D6BE63858D37 for ; Fri, 28 Apr 2023 06:30:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D6BE63858D37 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-oo1-xc2c.google.com with SMTP id 006d021491bc7-546ef028d62so5715964eaf.1 for ; Thu, 27 Apr 2023 23:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1682663405; x=1685255405; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=xLpYgyRrzV47IvGqjGRgiBPgo8eJMqwegUTntgUCsuc=; b=r+jbqnAzChCoW+oXM7MunGwL+pFYnWz4EwwmhbrMRFIqg7W/AzPHgUtY/a1vddfPOf Zpl/u09SQqN6GODdyldnXFbsNgnDTRiqxum9xygl+4NN7YFumyY8sKiKaO+OVp3DneiV BRHvtnQNrymHUHmDUYH9os27HL3vrBSGFMrMzbqVAsaHn1NwjKP/k7+HD1OrC6E9NuUT crwrUYMm2GITmKlu1kj+70zCh1vCEQux6AAurJfpcmDrwe0yOmypdGzGB75u/cJOVZSk 6CV8g93G638GJt+CXT2AYDLLryvpVZz0HZR+dgIHyH3dyzE6KRjRzxDAm234YLnmxHQ8 zS0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682663405; x=1685255405; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xLpYgyRrzV47IvGqjGRgiBPgo8eJMqwegUTntgUCsuc=; b=Jb/MzyrSf5BnjPm50ah7kuCJCh8da3wyd3h7l9sn3p3xCLepmTt8/UTSPXE8kdCMke CHkSuYt158YtXNmSMacAvXW1KKiIY5rJqiAuyQFmRUWtINLC9868R2ZnM4fc8P9Ke6mF u3pq5cqRL3i7YlXQeDLB0U/iJOQW242YZBDlh1uTlRaj/yohuDD7G/Xv5uknc1N3nDRi gGfJtzkwWmFTVu6PPN6vuoTg+haOAKlIC7ijuFgWC1tZSzYLCVZ2j9IY0vCAs7cYlFej FEo2PzTFg4T+0v1LX0DjLmoQNY1QNoPohiTIUfj1s7rZ64GApQ5c7JlBx9A4j+F+dN4x Bdaw== X-Gm-Message-State: AC+VfDxgDdSwsFf6NZg13bJHWt79gwy+GbQLpGkAi/0VsmnWvJGj2sXk yJmWwEGVzBGhgjqEXVQ4Ot4Mt2SJ9zQNFvxqW60xxMTTWutntjGJpw/T0A== X-Google-Smtp-Source: ACHHUZ6lY0on662PUD0N+mQPxIbNjzAuGG+wVJXxVND8dzuWWVUwdrO3D5qYc7ioCkFuUj5ur8T8OMknC1EYpLXlQqQ= X-Received: by 2002:aca:906:0:b0:38e:c5d4:19c with SMTP id 6-20020aca0906000000b0038ec5d4019cmr1871165oij.5.1682663405056; Thu, 27 Apr 2023 23:30:05 -0700 (PDT) MIME-Version: 1.0 References: <20230421082839.41542-1-nelson@rivosinc.com> <20230421082839.41542-2-nelson@rivosinc.com> In-Reply-To: <20230421082839.41542-2-nelson@rivosinc.com> From: Nelson Chu Date: Fri, 28 Apr 2023 14:29:54 +0800 Message-ID: Subject: Re: [PATCH 2/2] RISC-V: Enable x0 base relaxation for relax_pc even if --no-relax-gp. To: binutils@sourceware.org, jim.wilson.gcc@gmail.com, palmer@dabbelt.com, kito.cheng@sifive.com Content-Type: multipart/alternative; boundary="000000000000890aec05fa5f9ae5" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: --000000000000890aec05fa5f9ae5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Committed, thanks. Nelson On Fri, Apr 21, 2023 at 4:28=E2=80=AFPM Nelson Chu wr= ote: > Let --no-relax-gp only disable the gp relaxation for lui and pcrel > relaxations, since x0 base and gp relaxations are different optimizations > in fact, but just use the same function to handle. > > bfd/ > * elfnn-riscv.c (_bfd_riscv_relax_pc): Like _bfd_riscv_relax_lui, > set gp to zero when --no-relax-gp, then we should still keep the > x0 base relaxation. > (_bfd_riscv_relax_section): Enable _bfd_riscv_relax_pc when > --no-relax-gp, we will disable the gp relaxation in the > _bfd_riscv_relax_pc. > --- > bfd/elfnn-riscv.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c > index 499f51ee857..77a732b6a08 100644 > --- a/bfd/elfnn-riscv.c > +++ b/bfd/elfnn-riscv.c > @@ -4721,7 +4721,9 @@ _bfd_riscv_relax_pc (bfd *abfd ATTRIBUTE_UNUSED, > bool undefined_weak) > { > struct riscv_elf_link_hash_table *htab =3D riscv_elf_hash_table > (link_info); > - bfd_vma gp =3D riscv_global_pointer_value (link_info); > + bfd_vma gp =3D htab->params->relax_gp > + ? riscv_global_pointer_value (link_info) > + : 0; > > BFD_ASSERT (rel->r_offset + 4 <=3D sec->size); > > @@ -4942,7 +4944,7 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, > || type =3D=3D R_RISCV_TPREL_LO12_I > || type =3D=3D R_RISCV_TPREL_LO12_S) > relax_func =3D _bfd_riscv_relax_tls_le; > - else if (!bfd_link_pic (info) && htab->params->relax_gp > + else if (!bfd_link_pic (info) > && (type =3D=3D R_RISCV_PCREL_HI20 > || type =3D=3D R_RISCV_PCREL_LO12_I > || type =3D=3D R_RISCV_PCREL_LO12_S)) > -- > 2.39.2 (Apple Git-143) > > --000000000000890aec05fa5f9ae5--