From patchwork Tue Nov 15 06:46:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Zeng X-Patchwork-Id: 20212 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2554246wru; Mon, 14 Nov 2022 22:47:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zaFhftKIrX42d77FRtzZeQvCTusPz637LAx7E/8G21Lyll/6hm5C90uXPob2ptKic8Ar2 X-Received: by 2002:aa7:de92:0:b0:467:8fb6:d11 with SMTP id j18-20020aa7de92000000b004678fb60d11mr10645850edv.421.1668494848347; Mon, 14 Nov 2022 22:47:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668494848; cv=none; d=google.com; s=arc-20160816; b=OjmGLw8sNnw/XQhDcOfprQiBzTwMtVYRK6MP05sFlXwT72gbGLRWzAoWRFh+az7n/N WffRFuv60IK7t5seY+6eqzIxP53ciALNF5o7D3CjbjVjYfCnzdMajQZY1ZD224sdCJhy PqElykeewvdD8PH4aL7opBwrDXvuOMVJUgsPBdmDTKYwYmtsEp7WKx0Taeb2vYSqIfnG nTXTafSspIJz19JbUL/48p6/Gk7ppfhZzg1qb/JQyYuruFswGZsPRluuIPklwglvQTZi suHvb+Q+Yzdnnc9OWpTdG2BGD2VhoTRZll2pXhj4eieX26D7srGAfM1MTmcpriqhvW4N 0XUg== 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=a4wk5hD8hnsvFjUeC7dh+j6oCLJ3RvAq+i8tkwVqNv0=; b=F4rn1z/ziKuuCRTJNSX1FBKzGHDqdEl/FwsSZXkjsduIcTHU74B6nFiyWMXEzY09xX 8wxcsT+a9TdAk2oM+WaVoXJoHqIpAw5tF7B+36X2lUMcPyexwDolsOYYhSxwr1XtuaN7 Lab0We2zn/pOT87jnPv6Db0NeSeBCKb4DtEIUw5uW0otzX0egf8i20bcC8ZxAzAuTPAN kZgGlukEI14Q3PH+Eq1pjZrvheIYdxF/dtua89c2LfqpEa84e/fu2nFN5bDVYelXZ+vY V/w0iwL8DFbr1Pel3qa4vRgwXXXtdFbdRAqNxAsr+yjjUrKjW8Y7EQuE0PIdP4CbC3++ HJXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sa6-20020a1709076d0600b007418e87eea8si11499265ejc.770.2022.11.14.22.47.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 22:47:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA61A382EF14 for ; Tue, 15 Nov 2022 06:47:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [207.46.229.174]) by sourceware.org (Postfix) with SMTP id 7960B38357BB for ; Tue, 15 Nov 2022 06:46:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7960B38357BB 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.DOMAINS (unknown [10.12.130.38]) by app2 (Coremail) with SMTP id EggMCgB3SS7ENXNj83sRAA--.53785S5; Tue, 15 Nov 2022 14:46:31 +0800 (CST) From: zengxiao@eswincomputing.com To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, andrew@sifive.com, shihua@iscas.ac.cn, cri-sw-toolchain@eswincomputing.com, zengxiao Subject: [PATCH, V1 1/1] RISC-V: Make R_RISCV_SUB6 conforms to riscv abi standard Date: Tue, 15 Nov 2022 14:46:24 +0800 Message-Id: <20221115064624.2352237-2-zengxiao@eswincomputing.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221115064624.2352237-1-zengxiao@eswincomputing.com> References: <20221115064624.2352237-1-zengxiao@eswincomputing.com> MIME-Version: 1.0 X-CM-TRANSID: EggMCgB3SS7ENXNj83sRAA--.53785S5 X-Coremail-Antispam: 1UD129KBjvJXoWxXry8XrWfKr47tr1kAr4xZwb_yoW5Aw48pw 1DJwn8KF4fJrsrtrs7ta1Uua1Skw409FWF9wnFqw42yrWkJryDtrnYyF17CayDXFy8CrWr ZrsYgF4Yk3y5Aw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP014x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwAKzVCY07xG64k0F24lc2xSY4 AK6svPMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AK xVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr 1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbb18JUU UUU== X-CM-SenderInfo: p2hqw5xldrqvxvzl0uprps33xlqjhudrp/ X-Spam-Status: No, score=-9.7 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749543650342761595?= X-GMAIL-MSGID: =?utf-8?q?1749543653987150900?= 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 --- bfd/elfxx-riscv.c | 7 +++++ .../testsuite/binutils-all/riscv/dwarf-SUB6.d | 31 +++++++++++++++++++ .../testsuite/binutils-all/riscv/dwarf-SUB6.s | 12 +++++++ 3 files changed, 50 insertions(+) create mode 100644 binutils/testsuite/binutils-all/riscv/dwarf-SUB6.d create mode 100644 binutils/testsuite/binutils-all/riscv/dwarf-SUB6.s diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 300ccf49534..e71d4a456f2 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: diff --git a/binutils/testsuite/binutils-all/riscv/dwarf-SUB6.d b/binutils/testsuite/binutils-all/riscv/dwarf-SUB6.d new file mode 100644 index 00000000000..47d5ae570d7 --- /dev/null +++ b/binutils/testsuite/binutils-all/riscv/dwarf-SUB6.d @@ -0,0 +1,31 @@ +#PROG: objcopy +#objdump: --dwarf=frames + +tmpdir/riscvcopy.o: file format elf32-littleriscv + +Contents of the .eh_frame section: + + +00000000 00000020 00000000 CIE + Version: 3 + Augmentation: "zR" + Code alignment factor: 1 + Data alignment factor: -4 + Return address column: 1 + Augmentation data: 1b + DW_CFA_def_cfa_register: r2 \(sp\) + DW_CFA_def_cfa_offset: 48 + DW_CFA_offset: r1 \(ra\) at cfa-4 + DW_CFA_offset: r8 \(s0\) at cfa-8 + DW_CFA_def_cfa: r8 \(s0\) ofs 0 + DW_CFA_restore: r1 \(ra\) + DW_CFA_restore: r8 \(s0\) + DW_CFA_def_cfa: r2 \(sp\) ofs 48 + DW_CFA_def_cfa_offset: 0 + DW_CFA_nop + +00000024 00000010 00000028 FDE cie=00000000 pc=0000002c..0000002c + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + diff --git a/binutils/testsuite/binutils-all/riscv/dwarf-SUB6.s b/binutils/testsuite/binutils-all/riscv/dwarf-SUB6.s new file mode 100644 index 00000000000..fe959f59d9b --- /dev/null +++ b/binutils/testsuite/binutils-all/riscv/dwarf-SUB6.s @@ -0,0 +1,12 @@ + .attribute arch, "rv32i2p0_m2p0_a2p0_f2p0_c2p0" + .cfi_startproc + .cfi_def_cfa_offset 48 + .cfi_offset 1, -4 + .cfi_offset 8, -8 + .cfi_def_cfa 8, 0 + .cfi_restore 1 + .cfi_restore 8 + .cfi_def_cfa 2, 48 + .cfi_def_cfa_offset 0 + .cfi_endproc + \ No newline at end of file