diff options
author | Brendan Coles <bcoles@gmail.com> | 2021-03-22 05:57:39 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-22 17:46:05 +0100 |
commit | 8ad74684ea249c179d76e2624668b6d2dd3a8085 (patch) | |
tree | 2379c6a23c67a3c256a28a5c792b27020d5efb50 /Userland/Libraries/LibELF | |
parent | 2efa17184d10f1b19ba55743ab4bd415a726fcdb (diff) | |
download | serenity-8ad74684ea249c179d76e2624668b6d2dd3a8085.zip |
LibELF: DynamicObject: Add rpath and runpath helpers
Diffstat (limited to 'Userland/Libraries/LibELF')
-rw-r--r-- | Userland/Libraries/LibELF/DynamicObject.cpp | 12 | ||||
-rw-r--r-- | Userland/Libraries/LibELF/DynamicObject.h | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index 8d2b08ca6b..c379d21e82 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -72,6 +72,10 @@ void DynamicObject::dump() const if (m_has_soname) builder.appendff("DT_SONAME: {}\n", soname()); // FIXME: Validate that this string is null terminated? + if (m_has_rpath) + builder.appendff("DT_RPATH: {}\n", rpath()); + if (m_has_runpath) + builder.appendff("DT_RUNPATH: {}\n", runpath()); dbgln_if(DYNAMIC_LOAD_DEBUG, "Dynamic section at address {} contains {} entries:", m_dynamic_address.as_ptr(), num_dynamic_sections); dbgln_if(DYNAMIC_LOAD_DEBUG, "{}", builder.string_view()); @@ -163,6 +167,14 @@ void DynamicObject::parse() case DT_BIND_NOW: m_dt_flags |= DF_BIND_NOW; break; + case DT_RPATH: + m_rpath_index = entry.val(); + m_has_rpath = true; + break; + case DT_RUNPATH: + m_runpath_index = entry.val(); + m_has_runpath = true; + break; case DT_DEBUG: break; case DT_FLAGS_1: diff --git a/Userland/Libraries/LibELF/DynamicObject.h b/Userland/Libraries/LibELF/DynamicObject.h index 151f5d898d..8fa50bc18c 100644 --- a/Userland/Libraries/LibELF/DynamicObject.h +++ b/Userland/Libraries/LibELF/DynamicObject.h @@ -238,6 +238,8 @@ public: 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; } + StringView rpath() const { return m_has_rpath ? symbol_string_table_string(m_rpath_index) : StringView {}; } + StringView runpath() const { return m_has_runpath ? symbol_string_table_string(m_runpath_index) : StringView {}; } StringView soname() const { return m_has_soname ? symbol_string_table_string(m_soname_index) : StringView {}; } Optional<FlatPtr> tls_offset() const { return m_tls_offset; } @@ -320,6 +322,10 @@ private: bool m_has_soname { false }; Elf32_Word m_soname_index { 0 }; // Index into dynstr table for SONAME + bool m_has_rpath { false }; + Elf32_Word m_rpath_index { 0 }; // Index into dynstr table for RPATH + bool m_has_runpath { false }; + Elf32_Word m_runpath_index { 0 }; // Index into dynstr table for RUNPATH Optional<FlatPtr> m_tls_offset; Optional<FlatPtr> m_tls_size; |