]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
util/grub-mkimagexx: Fix riscv32 relocation offset
authorAnaëlle Cazuc <acazuc@acazuc.fr>
Tue, 2 Sep 2025 09:50:51 +0000 (11:50 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 9 Sep 2025 23:12:17 +0000 (01:12 +0200)
When using grub-mkrescue for a riscv32 target, an invalid implicit cast
on the offset calculation produces an error during the relocation process:

  grub-mkrescue: error: target XXX not reachable from pc=fc.

This patch adds an explicit grub_int64_t cast to compute the offset
as a 64-bit subtraction.

Signed-off-by: Anaëlle Cazuc <acazuc@acazuc.fr>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/grub-mkimagexx.c

index 448862b2e12c0854952c38d7bd83f37700f23508..45ac7755899481d06df2360472239f4ca32a3149 100644 (file)
@@ -1354,7 +1354,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;
+                off = (grub_int64_t) sym_addr - target_section_addr - offset - image_target->vaddr_offset;
 
                 switch (ELF_R_TYPE (info))
                   {