mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibELF: Remove (FlatPtr)something.as_ptr()
idiom
This is equivalent to `something.get()`, but more verbose.
This commit is contained in:
parent
e0e3198d51
commit
18b2484985
Notes:
sideshowbarker
2024-07-18 07:10:35 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/18b24849858 Pull-request: https://github.com/SerenityOS/serenity/pull/9315
|
@ -468,9 +468,9 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
||||||
// We could explicitly do them first using m_number_of_relocations from DT_RELCOUNT
|
// We could explicitly do them first using m_number_of_relocations from DT_RELCOUNT
|
||||||
// However, our compiler is nice enough to put them at the front of the relocations for us :)
|
// However, our compiler is nice enough to put them at the front of the relocations for us :)
|
||||||
if (relocation.addend_used())
|
if (relocation.addend_used())
|
||||||
*patch_ptr = (FlatPtr)m_dynamic_object->base_address().as_ptr() + relocation.addend();
|
*patch_ptr = m_dynamic_object->base_address().offset(relocation.addend()).get();
|
||||||
else
|
else
|
||||||
*patch_ptr += (FlatPtr)m_dynamic_object->base_address().as_ptr();
|
*patch_ptr += m_dynamic_object->base_address().get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if ARCH(I386)
|
#if ARCH(I386)
|
||||||
|
@ -508,10 +508,10 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
||||||
// The patch method returns the address for the LAZY fixup path, but we don't need it here
|
// The patch method returns the address for the LAZY fixup path, but we don't need it here
|
||||||
m_dynamic_object->patch_plt_entry(relocation.offset_in_section());
|
m_dynamic_object->patch_plt_entry(relocation.offset_in_section());
|
||||||
} else {
|
} else {
|
||||||
u8* relocation_address = relocation.address().as_ptr();
|
auto relocation_address = (FlatPtr*)relocation.address().as_ptr();
|
||||||
|
|
||||||
if (m_elf_image.is_dynamic())
|
if (m_elf_image.is_dynamic())
|
||||||
*(FlatPtr*)relocation_address += (FlatPtr)m_dynamic_object->base_address().as_ptr();
|
*relocation_address += m_dynamic_object->base_address().get();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,19 +67,19 @@ void DynamicObject::parse()
|
||||||
for_each_dynamic_entry([&](const DynamicEntry& entry) {
|
for_each_dynamic_entry([&](const DynamicEntry& entry) {
|
||||||
switch (entry.tag()) {
|
switch (entry.tag()) {
|
||||||
case DT_INIT:
|
case DT_INIT:
|
||||||
m_init_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_init_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_FINI:
|
case DT_FINI:
|
||||||
m_fini_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_fini_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_INIT_ARRAY:
|
case DT_INIT_ARRAY:
|
||||||
m_init_array_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_init_array_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_INIT_ARRAYSZ:
|
case DT_INIT_ARRAYSZ:
|
||||||
m_init_array_size = entry.val();
|
m_init_array_size = entry.val();
|
||||||
break;
|
break;
|
||||||
case DT_FINI_ARRAY:
|
case DT_FINI_ARRAY:
|
||||||
m_fini_array_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_fini_array_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_FINI_ARRAYSZ:
|
case DT_FINI_ARRAYSZ:
|
||||||
m_fini_array_size = entry.val();
|
m_fini_array_size = entry.val();
|
||||||
|
@ -87,18 +87,18 @@ void DynamicObject::parse()
|
||||||
case DT_HASH:
|
case DT_HASH:
|
||||||
// Use SYSV hash only if GNU hash is not available
|
// Use SYSV hash only if GNU hash is not available
|
||||||
if (m_hash_type == HashType::SYSV) {
|
if (m_hash_type == HashType::SYSV) {
|
||||||
m_hash_table_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_hash_table_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DT_GNU_HASH:
|
case DT_GNU_HASH:
|
||||||
m_hash_type = HashType::GNU;
|
m_hash_type = HashType::GNU;
|
||||||
m_hash_table_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_hash_table_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_SYMTAB:
|
case DT_SYMTAB:
|
||||||
m_symbol_table_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_symbol_table_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_STRTAB:
|
case DT_STRTAB:
|
||||||
m_string_table_offset = entry.ptr() - (FlatPtr)m_elf_base_address.as_ptr();
|
m_string_table_offset = entry.ptr() - m_elf_base_address.get();
|
||||||
break;
|
break;
|
||||||
case DT_STRSZ:
|
case DT_STRSZ:
|
||||||
m_size_of_string_table = entry.val();
|
m_size_of_string_table = entry.val();
|
||||||
|
@ -457,7 +457,7 @@ VirtualAddress DynamicObject::patch_plt_entry(u32 relocation_offset)
|
||||||
VERIFY(relocation.type() == R_X86_64_JUMP_SLOT);
|
VERIFY(relocation.type() == R_X86_64_JUMP_SLOT);
|
||||||
#endif
|
#endif
|
||||||
auto symbol = relocation.symbol();
|
auto symbol = relocation.symbol();
|
||||||
u8* relocation_address = relocation.address().as_ptr();
|
auto relocation_address = (FlatPtr*)relocation.address().as_ptr();
|
||||||
|
|
||||||
VirtualAddress symbol_location;
|
VirtualAddress symbol_location;
|
||||||
auto result = DynamicLoader::lookup_symbol(symbol);
|
auto result = DynamicLoader::lookup_symbol(symbol);
|
||||||
|
@ -470,7 +470,7 @@ VirtualAddress DynamicObject::patch_plt_entry(u32 relocation_offset)
|
||||||
|
|
||||||
dbgln_if(DYNAMIC_LOAD_DEBUG, "DynamicLoader: Jump slot relocation: putting {} ({}) into PLT at {}", symbol.name(), symbol_location, (void*)relocation_address);
|
dbgln_if(DYNAMIC_LOAD_DEBUG, "DynamicLoader: Jump slot relocation: putting {} ({}) into PLT at {}", symbol.name(), symbol_location, (void*)relocation_address);
|
||||||
|
|
||||||
*(FlatPtr*)relocation_address = symbol_location.get();
|
*relocation_address = symbol_location.get();
|
||||||
|
|
||||||
return symbol_location;
|
return symbol_location;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue