mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
LibELF: Refactor how arch-specific dynamic relocation types are handled
We currently expect that the relocation type numbers are unique across all architectures. But RISC-V and x86_64 use the same numbers for different relocation types (R_X86_64_COPY = R_RISCV_JUMP_SLOT = 5). So create a generic reloc type enum which maps to the arch-specific reloc types instead of checking for all arch reloc types individually everywhere.
This commit is contained in:
parent
c216e7439f
commit
f8628f94b8
6 changed files with 98 additions and 23 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibELF/Arch/GenericDynamicRelocationType.h>
|
||||
#include <LibELF/ELFABI.h>
|
||||
#include <LibELF/Relocation.h>
|
||||
|
||||
|
@ -59,7 +60,7 @@ bool perform_relative_relocations(FlatPtr base_address)
|
|||
for (unsigned i = 0; i < relocation_count; ++i) {
|
||||
size_t offset_in_section = i * relocation_entry_size;
|
||||
auto* relocation = (Elf_Rela*)(relocation_section_addr + offset_in_section);
|
||||
VERIFY(ELF64_R_TYPE(relocation->r_info) == R_X86_64_RELATIVE || ELF64_R_TYPE(relocation->r_info) == R_AARCH64_RELATIVE);
|
||||
VERIFY(static_cast<GenericDynamicRelocationType>(ELF64_R_TYPE(relocation->r_info)) == GenericDynamicRelocationType::RELATIVE);
|
||||
auto* patch_address = (FlatPtr*)(base_address + relocation->r_offset);
|
||||
FlatPtr relocated_address;
|
||||
if (use_addend) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue