LibELF: Use correct accessor macros on x86_64 for some ELF fields

This commit is contained in:
Gunnar Beutner 2021-06-29 00:41:57 +02:00 committed by Andreas Kling
parent c81d959afb
commit 2eb025b2ea
Notes: sideshowbarker 2024-07-18 11:20:31 +09:00
2 changed files with 64 additions and 8 deletions

View file

@ -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())

View file

@ -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;