From patchwork Fri Apr 21 08:28:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nelson Chu X-Patchwork-Id: 86170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp909034vqo; Fri, 21 Apr 2023 01:28:58 -0700 (PDT) X-Google-Smtp-Source: AKy350a6NIeNGmq5+mx1i3aoL9Dmq0Ka9ceQ7ZXZGEOJkS4AF9DPR+kP0cQ1KsjDdpEesFztYwGL X-Received: by 2002:a05:6402:510e:b0:506:71bd:3931 with SMTP id m14-20020a056402510e00b0050671bd3931mr8500682edd.2.1682065738097; Fri, 21 Apr 2023 01:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682065738; cv=none; d=google.com; s=arc-20160816; b=NaS2xxlDDX2gx4J5t+O7c8g+j8+i+zEmoLqjSw8JHe6zlJ7uimB2aTBQizywqXXqcD 2aBkoTl0zeNY6TGZAVU//KvSB8lT/93PyLr+qsu2SUcfu+Upua31U0UBcad5DC1phn6x JkFA42TkicsSuL0OWYQMw13Oe9Ko9WcNnhpzHWmy0obW+cecZe+0kSU5YcaF2tLnWg7r /ik1TSiP7ir2ZQpKElodRXxzxI3LXgUrZu9CE8r3fjn6Abkgs3vol0ECi0L+QfWFxqei rTQ0QFYYnOQq1EEkmO15SHiQ3BQ6fVmiuEYfkUTLU9vr5HGQoBBaaVw0FOM96pcBcYod /Bog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dmarc-filter:delivered-to; bh=peIXHy+4LOdjxcQjRu+LcyhBYBnnCHUQhBiuvjTmUgk=; b=NM0ERnmF5aL/wpeMVC2IbGH/i270w9MssKW0C8TUyfyVjBRwAC/kMNdqXY+Cn6XASq RAb8BIN0tHHp/nRanpIZjqmOHkBeHu4Anq+efC4Urxbyrg0oIfYrpfsS53puDCuefr5D Cu6D2714IDZAi5BNGJjeLxekIkotAT6cXLeskw8JV95a8sFaQG0V10hHoXm4cqir7CWw XNyY+xDWQ9/fzCvrLhsF9NuSScUupalVw1uWElXPvPiYje4isGuu2o0MDXzZiMEXt0ZR YMOrpUzmF2gWcJ+luWHa410yUy2WO4PhvFJaqnQDTyNUcN02doElecu0gIOVMNMyinuF iHlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j12-20020aa7de8c000000b005050661fdfcsi3399637edv.451.2023.04.21.01.28.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 01:28:58 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1BF63857735 for ; Fri, 21 Apr 2023 08:28:56 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from NelsondeMBP.localdomain (114-25-92-140.dynamic-ip.hinet.net [114.25.92.140]) by sourceware.org (Postfix) with ESMTP id 9A1973858D37 for ; Fri, 21 Apr 2023 08:28:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A1973858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=NelsondeMBP.localdomain Received: by NelsondeMBP.localdomain (Postfix, from userid 501) id 644C4BDB05D; Fri, 21 Apr 2023 16:28:42 +0800 (CST) From: Nelson Chu To: binutils@sourceware.org, jim.wilson.gcc@gmail.com, palmer@dabbelt.com, kito.cheng@sifive.com Cc: nelson@rivosinc.com Subject: [PATCH 2/2] RISC-V: Enable x0 base relaxation for relax_pc even if --no-relax-gp. Date: Fri, 21 Apr 2023 16:28:39 +0800 Message-Id: <20230421082839.41542-2-nelson@rivosinc.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230421082839.41542-1-nelson@rivosinc.com> References: <20230421082839.41542-1-nelson@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, NO_DNS_FOR_FROM, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_PBL, RCVD_IN_SORBS_DUL, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763773763483770917?= X-GMAIL-MSGID: =?utf-8?q?1763773763483770917?= 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 = riscv_elf_hash_table (link_info); - bfd_vma gp = riscv_global_pointer_value (link_info); + bfd_vma gp = htab->params->relax_gp + ? riscv_global_pointer_value (link_info) + : 0; BFD_ASSERT (rel->r_offset + 4 <= sec->size); @@ -4942,7 +4944,7 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, || type == R_RISCV_TPREL_LO12_I || type == R_RISCV_TPREL_LO12_S) relax_func = _bfd_riscv_relax_tls_le; - else if (!bfd_link_pic (info) && htab->params->relax_gp + else if (!bfd_link_pic (info) && (type == R_RISCV_PCREL_HI20 || type == R_RISCV_PCREL_LO12_I || type == R_RISCV_PCREL_LO12_S))