1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:17:35 +00:00

LibELF: Simplify DynamicObject::Symbol class a bit

We no longer need the create_undefined() helper function.
Also we don't need a member field for is_undefined().
This commit is contained in:
Andreas Kling 2021-02-20 23:48:26 +01:00
parent 1997d5de1a
commit c5d93e55d0

View file

@ -72,27 +72,8 @@ public:
, m_sym(sym) , m_sym(sym)
, m_index(index) , m_index(index)
{ {
if (section_index() == 0)
m_is_undefined = true;
} }
Symbol(const Symbol& other)
: m_dynamic(other.m_dynamic)
, m_sym(other.m_sym)
, m_index(other.m_index)
, m_is_undefined(other.m_is_undefined)
{
}
static Symbol create_undefined(const DynamicObject& dynamic)
{
auto s = Symbol(dynamic, 0, {});
s.m_is_undefined = true;
return s;
}
~Symbol() { }
StringView name() const { return m_dynamic.symbol_string_table_string(m_sym.st_name); } StringView name() const { return m_dynamic.symbol_string_table_string(m_sym.st_name); }
unsigned section_index() const { return m_sym.st_shndx; } unsigned section_index() const { return m_sym.st_shndx; }
unsigned value() const { return m_sym.st_value; } unsigned value() const { return m_sym.st_value; }
@ -101,10 +82,8 @@ public:
unsigned type() const { return ELF32_ST_TYPE(m_sym.st_info); } 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); }
bool is_undefined() const bool is_undefined() const { return section_index() == 0; }
{
return m_is_undefined;
}
VirtualAddress address() const VirtualAddress address() const
{ {
if (m_dynamic.elf_is_dynamic()) if (m_dynamic.elf_is_dynamic())
@ -117,7 +96,6 @@ public:
const DynamicObject& m_dynamic; const DynamicObject& m_dynamic;
const Elf32_Sym& m_sym; const Elf32_Sym& m_sym;
const unsigned m_index; const unsigned m_index;
bool m_is_undefined { false };
}; };
class Section { class Section {