diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c index afd0de2..f836966 100644 --- a/grub-core/kern/arm64/dl.c +++ b/grub-core/kern/arm64/dl.c @@ -110,6 +110,14 @@ do_relX (Elf_Shdr * relhdr, Elf_Ehdr * e, grub_dl_t mod) case R_AARCH64_JUMP26: retval = grub_arm64_reloc_xxxx26 (place, sym_addr); break; + case R_AARCH64_PREL32: + { + grub_uint32_t *p32 = place; + grub_dprintf ("dl", " reloc_prel32 %p => 0x%016llx, sym_addr 0x%016llx\n", + place, (unsigned long long) (sym_addr - place), sym_addr); + *p32 = (grub_uint32_t)(sym_addr - place); + } + break; default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("relocation 0x%x is not implemented yet"), diff --git a/include/grub/elf.h b/include/grub/elf.h index f2d67a7..64b8e20 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -2067,6 +2067,7 @@ typedef Elf32_Addr Elf32_Conflict; #define R_AARCH64_NONE 0 /* No relocation. */ #define R_AARCH64_ABS64 257 /* Direct 64 bit. */ #define R_AARCH64_ABS32 258 /* Direct 32 bit. */ +#define R_AARCH64_PREL32 261 /* PC-relative 32 bit. */ #define R_AARCH64_JUMP26 282 /* 26-bit relative. */ #define R_AARCH64_CALL26 283 /* 26-bit relative. */ #define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */ diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index f8180f3..247b3dc 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -431,6 +431,16 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, grub_util_error ("%s", grub_errmsg); } break; + case R_AARCH64_PREL32: + { + grub_uint32_t *t32 = (grub_uint32_t *) target; + *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) + + sym_addr /*S+A*/ + - /*-P*/(target_section_addr + offset + image_target->vaddr_offset)); + grub_util_info ("relocating an R_AARCH64_PREL32 entry to 0x%x at the offset 0x%llx", + *t32, (unsigned long long) offset); + } + break; default: grub_util_error (_("relocation %d is not implemented yet"), (unsigned long long) ELF_R_TYPE (info)); @@ -731,6 +741,7 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, } break; /* Relative relocations do not require fixup entries. */ + case R_AARCH64_PREL32: case R_AARCH64_CALL26: case R_AARCH64_JUMP26: break;