]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
RISC-V: Fix computation of pc-relative relocation offset
authorAndreas Schwab <schwab@suse.de>
Wed, 26 Jun 2019 14:50:03 +0000 (16:50 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 11 Jul 2019 15:50:40 +0000 (17:50 +0200)
The offset calculation was missing the relocation addend.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Tested-by: Chester Lin <clin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-mkimagexx.c

index bc087c2b57f81cb05f4fa34ccc8ae6f4544086a3..d16ec63a16ff629d49eba1ccb14233eef397c5d7 100644 (file)
@@ -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))
                   {