:: commit c9cbc359e79adbe188e7aa4e7c80a9978fdcd243

mintsuki <mintsuki@protonmail.com> — 2024-06-02 22:42

parents: 77a8af1d0a

lib/elf: aarch64: Support ABS64 reloc/add r_addend in JUMP_SLOT/GLOB_DAT relocs

diff --git a/common/lib/elf.c b/common/lib/elf.c
index 74035d42..7a4efc6d 100644
--- a/common/lib/elf.c
+++ b/common/lib/elf.c
@@ -51,6 +51,7 @@
 #define R_RISCV_JUMP_SLOT  0x00000005
 #define R_X86_64_64        0x00000001
 #define R_RISCV_64         0x00000002
+#define R_AARCH64_ABS64    0x00000101
 
 /* Indices into identification array */
 #define EI_CLASS    4
@@ -329,12 +330,17 @@ static bool elf64_apply_relocations(uint8_t *elf, struct elf64_hdr *hdr, void *b
 #elif defined (__aarch64__)
                 case R_AARCH64_GLOB_DAT:
                 case R_AARCH64_JUMP_SLOT:
+                case R_AARCH64_ABS64:
 #elif defined (__riscv64)
                 case R_RISCV_JUMP_SLOT:
 #endif
                 {
                     struct elf64_sym *s = (void *)elf + symtab_offset + symtab_ent * relocation->r_symbol;
-                    *ptr = slide + s->st_value;
+                    *ptr = slide + s->st_value
+#if defined (__aarch64__)
+                           + relocation->r_addend;
+#endif
+                    ;
                     break;
                 }
 #if defined (__x86_64__) || defined (__i386__) || defined (__riscv64)
tab: 248 wrap: offon