diff --git a/Makefile b/Makefile index 7e9d8b99991b6f424848aff7affcfd1b567e09b2..b548989ac6c6c5d4259c5609302ad385a4cfc9e6 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ sysboost: ninja -C build -v binfmt_rto: - make -C src/binfmt_rto + make -C src/binfmt_rto || true release: rm -rf Cargo.lock diff --git a/src/elf_check_elf.c b/src/elf_check_elf.c index 3cc23081d98f8d5aa33e899ffe82a6e41d51182e..b70ef9d3cd936bb1cfc7f09f1f827444f5f3fd19 100644 --- a/src/elf_check_elf.c +++ b/src/elf_check_elf.c @@ -115,8 +115,8 @@ static void check_func(elf_file_t *out_ef, unsigned long func_point) // 00000000001222d0 0000000000000008 R_X86_64_RELATIVE 30720 // rela must be type R_X86_64_RELATIVE - if (ELF64_R_TYPE(rela->r_info) != R_X86_64_RELATIVE) { - si_panic("rela type wrong, %lx\n", rela->r_addend); + if (!elf_rela_is_relative(rela)) { + si_panic("rela type wrong, r_info %lx r_addend %lx\n", rela->r_info, rela->r_addend); } // addr must in symbol table diff --git a/src/elf_read_elf.h b/src/elf_read_elf.h index 2d047bb75a203ae0dce3241abbc62cc0c842d3e0..e68125b305aab39fbbfec806af3daef6b6a11aa8 100644 --- a/src/elf_read_elf.h +++ b/src/elf_read_elf.h @@ -221,6 +221,16 @@ int elf_find_dynsym_index_by_name(elf_file_t *ef, const char *name); char *elf_get_dynsym_name_by_index(elf_file_t *ef, unsigned int index); // rela +static inline bool elf_rela_is_relative(Elf64_Rela *rela) +{ + int type = ELF64_R_TYPE(rela->r_info); + if ((type == R_X86_64_RELATIVE) || (type == R_AARCH64_RELATIVE)) { + return true; + } + + return false; +} + Elf64_Rela *elf_get_rela_by_addr(elf_file_t *ef, unsigned long addr); // dyn diff --git a/src/elf_relocation_aarch64.c b/src/elf_relocation_aarch64.c index ed179fa21de7ab6e086338243aa06381efd70d85..34ae668e7cdf777215474e2cb50d39bff0d24f39 100644 --- a/src/elf_relocation_aarch64.c +++ b/src/elf_relocation_aarch64.c @@ -802,10 +802,16 @@ int modify_local_call_rela(elf_link_t *elf_link, elf_file_t *ef, Elf64_Rela *rel check_two_rela_insn_addr(elf_link, ef, rela, sym); return 0; case R_AARCH64_ADD_ABS_LO12_NC: + case R_AARCH64_LDST128_ABS_LO12_NC: case R_AARCH64_LDST64_ABS_LO12_NC: case R_AARCH64_LDST32_ABS_LO12_NC: case R_AARCH64_LDST16_ABS_LO12_NC: case R_AARCH64_LDST8_ABS_LO12_NC: + // 00000000000118e0 0000000d00000113 R_AARCH64_ADR_PREL_PG_HI21 000000000001cbc0 .rodata + 7730 + // 00000000000118ec 0000000d0000012b R_AARCH64_LDST128_ABS_LO12_NC 000000000001cbc0 .rodata + 7730 + // 13: 000000000001cbc0 0 SECTION LOCAL DEFAULT 15 .rodata + // 118e0: f0000080 adrp x0, 24000 <_nc_tinfo_fkeys+0x1d0> + // 118ec: 3dc0bc00 ldr q0, [x0, #752] if (is_special_symbol_redirection(ef, rela, sym)) { modify_new_special_insn(elf_link, ef, rela, sym); } @@ -841,7 +847,7 @@ int modify_local_call_rela(elf_link_t *elf_link, elf_file_t *ef, Elf64_Rela *rel modify_tls_ie(elf_link, ef, rela, sym); return SKIP_ONE_RELA; default: - si_panic("invalid type %d\n", (int)ELF64_R_TYPE(rela->r_info)); + si_panic("invalid type %x file %s offset %lx\n", (int)ELF64_R_TYPE(rela->r_info), ef->file_name, rela->r_offset); return -1; }