From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x934.google.com (mail-ua1-x934.google.com [IPv6:2607:f8b0:4864:20::934]) by sourceware.org (Postfix) with ESMTPS id 223413858D37 for ; Fri, 28 Apr 2023 07:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 223413858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-x934.google.com with SMTP id a1e0cc1a2514c-76ee8f09692so3285278241.1 for ; Fri, 28 Apr 2023 00:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682666076; x=1685258076; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QOJpMPZaitWOCVz2MQ8PVv4SEWSfYciHfbRY8v4fbyM=; b=IWijNt3UMq0IbzejlFrnl+ycv0WRjbP4oZ+LsOpk5LUgCdJv3/vxB2rUF8ZY9Wv31I 3gvPsIcOFe4S3gP/kNMZ9RJcGXXZgXWwVfZbGFo8u65qBdCaVKa3Vy6WCBUwZg05zSFf 4/Fnoki6yCpO+PWOE/GZJl/qGzTzpQLVPjPQHx6i6WQaJcKy/5Q5QsbBtpzaIKqU9fDn vT57GylKQtKsZyRN5T/NbxvJCnbanIrVChQor9hfur4mWPsWSgDnBYeMIxW6sDfsX9Bd HqPzLcL57Xji2XCnOsk76zRhV2i9to1oowkaa7P8oMCQnBbCtPdNc3+abNSTkqckQCAu 2Njw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682666076; x=1685258076; h=content-transfer-encoding:cc: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=QOJpMPZaitWOCVz2MQ8PVv4SEWSfYciHfbRY8v4fbyM=; b=NtjBZ7Dy5TTwTK48u1qa8PcdIm1mGcDZO66nMKWpIf+u5FOPU+XUym/9j7bIMTI6kw AU0wcK1d+dtg4+9iUcNVRqM3pK9GKtNG3rw27vxxqVynBX6gjxgkwuNI/dOUEPbVVSRA R2cVwbA3he4T0WSgyWdILhZ1ixXgVdg50/Y93CXGI0xnu5vl4RQeXDexuyEkpZ5oTwJB m5HD8xiJxwGWm7biLVukpYbKjU4BFb1fHUAavSnNJVJKRiM/qLJsIYbj/5tPPL6K6R69 wbQtU3v5oL6SzDvKv58fdseDr9bDYv/jjv+MBM2Ywia8KgO9QogYxhI3G4QdgoPv+d8R fYww== X-Gm-Message-State: AC+VfDz6UEKAebAPvrY+HYAmB+sa+6z9fcYZl0caypqsslLBs7QNHiQx +EL+P9wSZpCk/oljaLCeZ706xsC02BACYOc0dGBZSe2ujU+Tpw== X-Google-Smtp-Source: ACHHUZ7jMrAosSS0IEe0J+Vz5HwqfATuhXYzbXquGv3f13uwbxicI9MBIBIg/7KomryfyZ/zj95MAwnzb4FwlZ1SGdU= X-Received: by 2002:a1f:ed87:0:b0:440:8697:1ae1 with SMTP id l129-20020a1fed87000000b0044086971ae1mr1682178vkh.1.1682666076286; Fri, 28 Apr 2023 00:14:36 -0700 (PDT) MIME-Version: 1.0 References: <20230421082839.41542-1-nelson@rivosinc.com> <20230421082839.41542-2-nelson@rivosinc.com> In-Reply-To: From: Kito Cheng Date: Fri, 28 Apr 2023 15:14:24 +0800 Message-ID: Subject: Re: [PATCH 2/2] RISC-V: Enable x0 base relaxation for relax_pc even if --no-relax-gp. To: Fangrui Song Cc: Nelson Chu , binutils@sourceware.org, jim.wilson.gcc@gmail.com, palmer@dabbelt.com, kito.cheng@sifive.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,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: it called Zero-page Relaxation on psABI spec https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf= .adoc#zero-page-relaxation On Fri, Apr 28, 2023 at 3:11=E2=80=AFPM Fangrui Song wrote: > > On Thu, Apr 27, 2023 at 11:29=E2=80=AFPM Nelson Chu = wrote: > > > > Committed, thanks. > > > > Nelson > > Thanks. I cannot find any information about "x0 base relaxation" on > the Internet. > It is worth a test: if I force `bfd_vma gp =3D 0;`, check-ld > RUNTESTFLAGS=3D'ld-riscv-elf.exp' will still pass :) > > > On Fri, Apr 21, 2023 at 4:28=E2=80=AFPM Nelson Chu wrote: > > > > > Let --no-relax-gp only disable the gp relaxation for lui and pcrel > > > relaxations, since x0 base and gp relaxations are different optimizat= ions > > > 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) > > > > > >