mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
LibELF: Only set up PLT trampoline for objects with a PLT
This commit is contained in:
parent
9d471ea923
commit
4df3a34bc2
2 changed files with 6 additions and 3 deletions
|
@ -219,6 +219,7 @@ RefPtr<DynamicObject> DynamicLoader::load_stage_3(unsigned flags, size_t total_t
|
||||||
{
|
{
|
||||||
do_lazy_relocations(total_tls_size);
|
do_lazy_relocations(total_tls_size);
|
||||||
if (flags & RTLD_LAZY) {
|
if (flags & RTLD_LAZY) {
|
||||||
|
if (m_dynamic_object->has_plt())
|
||||||
setup_plt_trampoline();
|
setup_plt_trampoline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,6 +492,7 @@ extern "C" void _plt_trampoline(void) __attribute__((visibility("hidden")));
|
||||||
void DynamicLoader::setup_plt_trampoline()
|
void DynamicLoader::setup_plt_trampoline()
|
||||||
{
|
{
|
||||||
ASSERT(m_dynamic_object);
|
ASSERT(m_dynamic_object);
|
||||||
|
ASSERT(m_dynamic_object->has_plt());
|
||||||
VirtualAddress got_address = m_dynamic_object->plt_got_base_address();
|
VirtualAddress got_address = m_dynamic_object->plt_got_base_address();
|
||||||
|
|
||||||
FlatPtr* got_ptr = (FlatPtr*)got_address.as_ptr();
|
FlatPtr* got_ptr = (FlatPtr*)got_address.as_ptr();
|
||||||
|
|
|
@ -259,7 +259,8 @@ public:
|
||||||
bool must_bind_now() const { return m_dt_flags & DF_BIND_NOW; }
|
bool must_bind_now() const { return m_dt_flags & DF_BIND_NOW; }
|
||||||
bool has_static_thread_local_storage() const { return m_dt_flags & DF_STATIC_TLS; }
|
bool has_static_thread_local_storage() const { return m_dt_flags & DF_STATIC_TLS; }
|
||||||
|
|
||||||
VirtualAddress plt_got_base_address() const { return m_base_address.offset(m_procedure_linkage_table_offset); }
|
bool has_plt() const { return m_procedure_linkage_table_offset.has_value(); }
|
||||||
|
VirtualAddress plt_got_base_address() const { return m_base_address.offset(m_procedure_linkage_table_offset.value()); }
|
||||||
VirtualAddress base_address() const { return m_base_address; }
|
VirtualAddress base_address() const { return m_base_address; }
|
||||||
|
|
||||||
const char* soname() const { return m_has_soname ? symbol_string_table_string(m_soname_index) : nullptr; }
|
const char* soname() const { return m_has_soname ? symbol_string_table_string(m_soname_index) : nullptr; }
|
||||||
|
@ -328,7 +329,7 @@ private:
|
||||||
Elf32_Sword m_procedure_linkage_table_relocation_type { -1 };
|
Elf32_Sword m_procedure_linkage_table_relocation_type { -1 };
|
||||||
FlatPtr m_plt_relocation_offset_location { 0 }; // offset of PLT relocations, at end of relocations
|
FlatPtr m_plt_relocation_offset_location { 0 }; // offset of PLT relocations, at end of relocations
|
||||||
size_t m_size_of_plt_relocation_entry_list { 0 };
|
size_t m_size_of_plt_relocation_entry_list { 0 };
|
||||||
FlatPtr m_procedure_linkage_table_offset { 0 };
|
Optional<FlatPtr> m_procedure_linkage_table_offset;
|
||||||
|
|
||||||
// NOTE: We'll only ever either RELA or REL entries, not both (thank god)
|
// NOTE: We'll only ever either RELA or REL entries, not both (thank god)
|
||||||
// NOTE: The x86 ABI will only ever genrerate REL entries.
|
// NOTE: The x86 ABI will only ever genrerate REL entries.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue