mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibELF: Use correct accessor macros on x86_64 for some ELF fields
This commit is contained in:
parent
c81d959afb
commit
2eb025b2ea
2 changed files with 64 additions and 8 deletions
|
@ -63,10 +63,24 @@ public:
|
||||||
unsigned value() const { return m_sym.st_value; }
|
unsigned value() const { return m_sym.st_value; }
|
||||||
unsigned size() const { return m_sym.st_size; }
|
unsigned size() const { return m_sym.st_size; }
|
||||||
unsigned index() const { return m_index; }
|
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); }
|
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
|
VirtualAddress address() const
|
||||||
{
|
{
|
||||||
|
@ -146,9 +160,23 @@ public:
|
||||||
|
|
||||||
unsigned offset_in_section() const { return m_offset_in_section; }
|
unsigned offset_in_section() const { return m_offset_in_section; }
|
||||||
unsigned offset() const { return m_rel.r_offset; }
|
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); }
|
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
|
VirtualAddress address() const
|
||||||
{
|
{
|
||||||
if (m_dynamic.elf_is_dynamic())
|
if (m_dynamic.elf_is_dynamic())
|
||||||
|
|
|
@ -54,9 +54,23 @@ public:
|
||||||
unsigned value() const { return m_sym.st_value; }
|
unsigned value() const { return m_sym.st_value; }
|
||||||
unsigned size() const { return m_sym.st_size; }
|
unsigned size() const { return m_sym.st_size; }
|
||||||
unsigned index() const { return m_index; }
|
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); }
|
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; }
|
bool is_undefined() const { return section_index() == 0; }
|
||||||
StringView raw_data() const;
|
StringView raw_data() const;
|
||||||
|
|
||||||
|
@ -151,9 +165,23 @@ public:
|
||||||
~Relocation() { }
|
~Relocation() { }
|
||||||
|
|
||||||
unsigned offset() const { return m_rel.r_offset; }
|
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); }
|
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:
|
private:
|
||||||
const Image& m_image;
|
const Image& m_image;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue