mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibELF+LibC: Add support for aarch64 relocations
This commit adds the used relocation types to elf.h, and handles the types in DynamicLoader and DynamicObject. No new functionalitty has to be added, as the same code can be reused between aarch64 and x86_64.
This commit is contained in:
parent
cfd73e5d9f
commit
ed3be5b7f5
3 changed files with 10 additions and 1 deletions
|
@ -822,4 +822,8 @@ struct elf_args {
|
|||
#define R_X86_64_TPOFF64 18
|
||||
#define R_X86_64_IRELATIVE 37
|
||||
|
||||
#define R_AARCH64_ABS64 257
|
||||
#define R_AARCH64_GLOB_DAT 1025
|
||||
#define R_AARCH64_JUMP_SLOT 1026
|
||||
#define R_AARCH64_RELATIVE 1027
|
||||
#define R_AARCH64_TLS_TPREL64 1030
|
||||
|
|
|
@ -482,6 +482,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
|||
// Apparently most loaders will just skip these?
|
||||
// Seems if the 'link editor' generates one something is funky with your code
|
||||
break;
|
||||
case R_AARCH64_ABS64:
|
||||
case R_X86_64_64: {
|
||||
auto symbol = relocation.symbol();
|
||||
auto res = lookup_symbol(symbol);
|
||||
|
@ -500,6 +501,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
|||
*patch_ptr = call_ifunc_resolver(VirtualAddress { *patch_ptr }).get();
|
||||
break;
|
||||
}
|
||||
case R_AARCH64_GLOB_DAT:
|
||||
case R_X86_64_GLOB_DAT: {
|
||||
auto symbol = relocation.symbol();
|
||||
auto res = lookup_symbol(symbol);
|
||||
|
@ -528,6 +530,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
|||
*patch_ptr = symbol_location.get();
|
||||
break;
|
||||
}
|
||||
case R_AARCH64_RELATIVE:
|
||||
case R_X86_64_RELATIVE: {
|
||||
if (!image().is_dynamic())
|
||||
break;
|
||||
|
@ -540,6 +543,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
|||
*patch_ptr += m_dynamic_object->base_address().get();
|
||||
break;
|
||||
}
|
||||
case R_AARCH64_TLS_TPREL64:
|
||||
case R_X86_64_TPOFF64: {
|
||||
auto symbol = relocation.symbol();
|
||||
FlatPtr symbol_value;
|
||||
|
@ -565,6 +569,7 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
|||
|
||||
break;
|
||||
}
|
||||
case R_AARCH64_JUMP_SLOT:
|
||||
case R_X86_64_JUMP_SLOT: {
|
||||
// FIXME: Or BIND_NOW flag passed in?
|
||||
if (m_dynamic_object->must_bind_now()) {
|
||||
|
|
|
@ -484,7 +484,7 @@ NonnullRefPtr<DynamicObject> DynamicObject::create(DeprecatedString const& filep
|
|||
VirtualAddress DynamicObject::patch_plt_entry(u32 relocation_offset)
|
||||
{
|
||||
auto relocation = plt_relocation_section().relocation_at_offset(relocation_offset);
|
||||
VERIFY(relocation.type() == R_X86_64_JUMP_SLOT);
|
||||
VERIFY(relocation.type() == R_X86_64_JUMP_SLOT || relocation.type() == R_AARCH64_JUMP_SLOT);
|
||||
auto symbol = relocation.symbol();
|
||||
auto relocation_address = (FlatPtr*)relocation.address().as_ptr();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue