From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.86_2) id 1hg9FR-0007wP-7y for mharc-grub-devel@gnu.org; Wed, 26 Jun 2019 10:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33805) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hg9FP-0007tE-92 for grub-devel@gnu.org; Wed, 26 Jun 2019 10:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hg9FO-00078y-6C for grub-devel@gnu.org; Wed, 26 Jun 2019 10:50:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:45054 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hg9FN-00076W-Vc for grub-devel@gnu.org; Wed, 26 Jun 2019 10:50:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7E287AEA3 for ; Wed, 26 Jun 2019 14:50:03 +0000 (UTC) From: Andreas Schwab To: grub-devel@gnu.org Subject: [PATCH] riscv: fix computation of pc-relative relocation offset X-Yow: Not enough people play SKEE-BALL.. They're always thinking about COCAINE or and ALIEN BEINGS!! Date: Wed, 26 Jun 2019 16:50:03 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 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: Wed, 26 Jun 2019 14:50:08 -0000 The offset calculation was missing the relocation addend. Signed-off-by: Andreas Schwab --- util/grub-mkimagexx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index bc087c2b5..d16ec63a1 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1232,8 +1232,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, grub_uint32_t *t32 = (grub_uint32_t *) target; grub_uint16_t *t16 = (grub_uint16_t *) target; grub_uint8_t *t8 = (grub_uint8_t *) target; - grub_int64_t off = (long)sym_addr - target_section_addr - offset - - image_target->vaddr_offset; + grub_int64_t off; /* * Instructions and instruction encoding are documented in the RISC-V @@ -1243,6 +1242,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd, */ sym_addr += addend; + off = sym_addr - target_section_addr - offset - image_target->vaddr_offset; switch (ELF_R_TYPE (info)) { -- 2.22.0 -- 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."