From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lQp4P-0000Sy-CC for mharc-grub-devel@gnu.org; Mon, 29 Mar 2021 06:24:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQp4O-0000SP-Dh for grub-devel@gnu.org; Mon, 29 Mar 2021 06:24:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:38612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQp4M-0006sM-QY for grub-devel@gnu.org; Mon, 29 Mar 2021 06:24:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D8925B3DF; Mon, 29 Mar 2021 10:24:23 +0000 (UTC) From: Andreas Schwab To: Khem Raj Cc: grub-devel@gnu.org, Daniel Kiper , Chester Lin , Nikita Ermakov , Alistair Francis Subject: Re: [PATCH] RISC-V: Restore the typcast to 64bit type References: <20210328224913.799167-1-raj.khem@gmail.com> X-Yow: The SAME WAVE keeps coming in and COLLAPSING like a rayon MUU-MUU.. Date: Mon, 29 Mar 2021 12:24:23 +0200 In-Reply-To: <20210328224913.799167-1-raj.khem@gmail.com> (Khem Raj's message of "Sun, 28 Mar 2021 15:49:13 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=195.135.220.15; envelope-from=schwab@suse.de; helo=mx2.suse.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2021 10:24:28 -0000 On Mär 28 2021, Khem Raj wrote: > this makes the type promotions clear and explicit > It was already typecasted to long but was accidentally dropped in [1] Note that long is 32-bit on riscv32, so the title is misleading (there was no cast to 64-bit type before). The cast really was a no-op, as it didn't change the resulting type. The issue is that the types of sym_addr, target_section_addr and offset are Elf_Addr (aka Elf32_Addr), which is an unsigned type (image_target->vaddr_offset is signed, but not wider than Elf32_Addr, so it doesn't change the overall type). Thus when the result of the expression is extended to grub_int64_t it is always a positive value instead of the desired sign-extended one. > which stated to cause failures on riscv32 as reported in [2] Most likely the missing addend masked the error. Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."