From patchwork Fri Oct 14 06:35:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Zeng X-Patchwork-Id: 2532 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp32149wrs; Thu, 13 Oct 2022 23:36:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7mFpcRM792bLerddcrF6AZtNNbOADFlHjIZM+VXo9FoO/Z3Ett7fwK5R0HBndAkHg0m7gb X-Received: by 2002:a17:906:4fd1:b0:787:434f:d755 with SMTP id i17-20020a1709064fd100b00787434fd755mr2387835ejw.356.1665729365028; Thu, 13 Oct 2022 23:36:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665729365; cv=none; d=google.com; s=arc-20160816; b=PO+grMA+8XTkfm7eFj6AVA8iAl+5pfMA9/jHGJo/TXGApOIFXKuKFsd+Ad015+qkW+ MCcJsvSchmeNQTEIXLpyVwsxAQZldnZFPw6lee1lkd3kIkqjaM8chUGjGcB7cHo0tPt5 104S+4inMrvIZfglyDuqQlpA6KrhALjGpuU54qq4ooUjzf5FvE0irAs9Rhf1lVqEBGF1 g9jfZLMpmVBXqY283Fwa+hreMGot6Fs6ivx8vpPSP1Mm+zOjF+mEelUjqUMEpDukZB5p 3zh6Y1FqqTJHeMWO4V5QFoLxSgf6/Hi3tbsXENdrNQuRyRZvwZDkzIGhJeveCN+9s3Zn AAOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dmarc-filter:delivered-to; bh=QFGcx4MJtb7juUi3jKq7W6AA3HVzRW0IS8vWpRf2Zto=; b=Dz0dgjw0HZMhVghVbQw720M8LsHX+/TbONNYR/LiIIzTGWjfT1B8VoOW1W9qFOI9sm C6mmksyQfuFtt1KZoid9BWPUlR2R6hue0lhlsSzWNKWhmth8EMhSsHWunx7PWuTDXmBx cXK2iWOng2EaxY8ylQdib3zmAvtcoyd3dtHlcbZjCCaBXgALYEkAD9mh6lVvag7p6qEI S1v8pUFiHtAq43Z58qsHAIeroN7aQnzM10/glSDJMhXn4jjNXWOhspShrKdT2vq8drjj wmUOq6QBuBJQWaQsmeskhQL2h65oSfytEEFfzR+EXVkPvyu5dTu7p1zqP7lR0uSz0Gi9 i0DA== 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x7-20020a170906148700b0078200f94d06si1521391ejc.237.2022.10.13.23.36.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 23:36:05 -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 0F0AF3854145 for ; Fri, 14 Oct 2022 06:36:02 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [52.187.6.220]) by sourceware.org (Postfix) with SMTP id 573413858C39 for ; Fri, 14 Oct 2022 06:35:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 573413858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eswincomputing.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eswincomputing.com Received: from user.. (unknown [10.12.130.38]) by app2 (Coremail) with SMTP id EggMCgB3BjBBA0ljOSUKAA--.7885S5; Fri, 14 Oct 2022 14:35:47 +0800 (CST) From: zengxiao@eswincomputing.com To: binutils@sourceware.org Subject: [PATCH 1/1] RISC-V: Make R_RISCV_SUB6 conforms to riscv abi standard Date: Fri, 14 Oct 2022 14:35:20 +0800 Message-Id: <20221014063520.1428330-2-zengxiao@eswincomputing.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221014063520.1428330-1-zengxiao@eswincomputing.com> References: <20221014063520.1428330-1-zengxiao@eswincomputing.com> MIME-Version: 1.0 X-CM-TRANSID: EggMCgB3BjBBA0ljOSUKAA--.7885S5 X-Coremail-Antispam: 1UD129KBjvJXoW7Wr18WF1fWryUJw1kJry3CFg_yoW8JryDpr 1fJr15C3WfZw17Xay2vayjka4rKw1v9r4FqwsIvw47X3srJay7tr1ktFyIkayDJF95XrW3 ZFyYgr4rAw4UArUanT9S1TB71UUUUjUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUHY14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1Y6r1xM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAa w2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrV C2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE 7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lw4CEc2 x0rVAKj4xxMxkF7I0En4kS14v26r1q6r43MxkIecxEwVCm-wCF04k20xvY0x0EwIxGrwCF x2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUtVW8ZwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr 0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUmtCcUUUUU= X-CM-SenderInfo: p2hqw5xldrqvxvzl0uprps33xlqjhudrp/ X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 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: , Cc: jinyanjiang@eswincomputing.com, cri-sw-toolchain@eswincomputing.com, zengxiao , gaofei@eswincomputing.com, zhengyu@eswincomputing.com 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?1746643831517166176?= X-GMAIL-MSGID: =?utf-8?q?1746643834768061873?= From: zengxiao This patch makes R_RISCV_SUB6 conforms to riscv abi standard. R_RISCV_SUB6 only the lower 6 bits of the code are valid. The proposed specification which can be found in 8.5. Relocations of, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0-rc4/riscv-abi.pdf bfd/ChangeLog: * elfxx-riscv.c (riscv_elf_add_sub_reloc): Take the lower 6 bits as the significant bit reviewed-by: gaofei@eswincomputing.com jinyanjiang@eswincomputing.com Signed-off-by: zengxiao --- bfd/elfxx-riscv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index f0c91cc97f7..0fbfedd17fe 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -994,6 +994,13 @@ riscv_elf_add_sub_reloc (bfd *abfd, relocation = old_value + relocation; break; case R_RISCV_SUB6: + { + bfd_vma six_bit_valid_value = old_value & howto->dst_mask; + six_bit_valid_value -= relocation; + relocation = (six_bit_valid_value & howto->dst_mask) | + (old_value & ~howto->dst_mask); + } + break; case R_RISCV_SUB8: case R_RISCV_SUB16: case R_RISCV_SUB32: