diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-06-29 00:41:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-29 20:03:36 +0200 |
commit | 2eb025b2eaee9efd1024d55565bd550b269403c1 (patch) | |
tree | c782941e7aac98082b801e366c446b24efd0b43a /Userland/Libraries | |
parent | c81d959afbac852bee0c6ff940ea67977d745d5e (diff) | |
download | serenity-2eb025b2eaee9efd1024d55565bd550b269403c1.zip |
LibELF: Use correct accessor macros on x86_64 for some ELF fields
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibELF/DynamicObject.h | 36 | ||||
-rw-r--r-- | Userland/Libraries/LibELF/Image.h | 36 |
2 files changed, 64 insertions, 8 deletions
diff --git a/Userland/Libraries/LibELF/DynamicObject.h b/Userland/Libraries/LibELF/DynamicObject.h index 56b54b842c..0be9bdb3d4 100644 --- a/Userland/Libraries/LibELF/DynamicObject.h +++ b/Userland/Libraries/LibELF/DynamicObject.h @@ -63,10 +63,24 @@ public: unsigned value() const { return m_sym.st_value; } unsigned size() const { return m_sym.st_size; } unsigned index() const { return m_index; } - unsigned type() const { return ELF32_ST_TYPE(m_sym.st_info); } +#if ARCH(I386) + unsigned type() const + { + return ELF32_ST_TYPE(m_sym.st_info); + } unsigned bind() const { return ELF32_ST_BIND(m_sym.st_info); } +#else + unsigned type() const + { + return ELF64_ST_TYPE(m_sym.st_info); + } + unsigned bind() const { return ELF64_ST_BIND(m_sym.st_info); } +#endif - bool is_undefined() const { return section_index() == 0; } + bool is_undefined() const + { + return section_index() == 0; + } VirtualAddress address() const { @@ -146,9 +160,23 @@ public: unsigned offset_in_section() const { return m_offset_in_section; } unsigned offset() const { return m_rel.r_offset; } - unsigned type() const { return ELF32_R_TYPE(m_rel.r_info); } +#if ARCH(I386) + unsigned type() const + { + return ELF32_R_TYPE(m_rel.r_info); + } unsigned symbol_index() const { return ELF32_R_SYM(m_rel.r_info); } - Symbol symbol() const { return m_dynamic.symbol(symbol_index()); } +#else + unsigned type() const + { + return ELF64_R_TYPE(m_rel.r_info); + } + unsigned symbol_index() const { return ELF64_R_SYM(m_rel.r_info); } +#endif + Symbol symbol() const + { + return m_dynamic.symbol(symbol_index()); + } VirtualAddress address() const { if (m_dynamic.elf_is_dynamic()) diff --git a/Userland/Libraries/LibELF/Image.h b/Userland/Libraries/LibELF/Image.h index 70ec1a76fd..e3ae009ec4 100644 --- a/Userland/Libraries/LibELF/Image.h +++ b/Userland/Libraries/LibELF/Image.h @@ -54,9 +54,23 @@ public: unsigned value() const { return m_sym.st_value; } unsigned size() const { return m_sym.st_size; } unsigned index() const { return m_index; } - unsigned type() const { return ELF32_ST_TYPE(m_sym.st_info); } +#if ARCH(I386) + unsigned type() const + { + return ELF32_ST_TYPE(m_sym.st_info); + } unsigned bind() const { return ELF32_ST_BIND(m_sym.st_info); } - Section section() const { return m_image.section(section_index()); } +#else + unsigned type() const + { + return ELF64_ST_TYPE(m_sym.st_info); + } + unsigned bind() const { return ELF64_ST_BIND(m_sym.st_info); } +#endif + Section section() const + { + return m_image.section(section_index()); + } bool is_undefined() const { return section_index() == 0; } StringView raw_data() const; @@ -151,9 +165,23 @@ public: ~Relocation() { } unsigned offset() const { return m_rel.r_offset; } - unsigned type() const { return ELF32_R_TYPE(m_rel.r_info); } +#if ARCH(I386) + unsigned type() const + { + return ELF32_R_TYPE(m_rel.r_info); + } unsigned symbol_index() const { return ELF32_R_SYM(m_rel.r_info); } - Symbol symbol() const { return m_image.symbol(symbol_index()); } +#else + unsigned type() const + { + return ELF64_R_TYPE(m_rel.r_info); + } + unsigned symbol_index() const { return ELF64_R_SYM(m_rel.r_info); } +#endif + Symbol symbol() const + { + return m_image.symbol(symbol_index()); + } private: const Image& m_image; |