From abb8fb6d1af1fe3db06b97bfae87466685b23007 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ana=C3=ABlle=20Cazuc?= Date: Tue, 2 Sep 2025 11:50:51 +0200 Subject: [PATCH] util/grub-mkimagexx: Fix riscv32 relocation offset MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Daniel Kiper --- util/grub-mkimagexx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 448862b2e..45ac77558 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -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)) { -- 2.47.3