1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:27:34 +00:00

LibELF: Fix various clang-tidy warnings

Remove a bunch of unused code, unnecessary const, and make some
non-object-specific member functions static.
This commit is contained in:
Andreas Kling 2021-02-20 19:26:27 +01:00
parent 0c0127dc3f
commit 01f1e480e5
8 changed files with 60 additions and 84 deletions

View file

@ -77,7 +77,7 @@ public:
unsigned index() const { return m_index; }
unsigned type() const { return ELF32_ST_TYPE(m_sym.st_info); }
unsigned bind() const { return ELF32_ST_BIND(m_sym.st_info); }
const Section section() const { return m_image.section(section_index()); }
Section section() const { return m_image.section(section_index()); }
bool is_undefined() const { return section_index() == 0; }
StringView raw_data() const;
@ -137,7 +137,7 @@ public:
const char* raw_data() const { return m_image.raw_data(m_section_header.sh_offset); }
ReadonlyBytes bytes() const { return { raw_data(), size() }; }
bool is_undefined() const { return m_section_index == SHN_UNDEF; }
const RelocationSection relocations() const;
RelocationSection relocations() const;
u32 flags() const { return m_section_header.sh_flags; }
bool is_writable() const { return flags() & SHF_WRITE; }
bool is_executable() const { return flags() & PF_X; }
@ -151,12 +151,12 @@ public:
class RelocationSection : public Section {
public:
RelocationSection(const Section& section)
explicit RelocationSection(const Section& section)
: Section(section.m_image, section.m_section_index)
{
}
unsigned relocation_count() const { return entry_count(); }
const Relocation relocation(unsigned index) const;
Relocation relocation(unsigned index) const;
template<typename F>
void for_each_relocation(F) const;
};
@ -174,7 +174,7 @@ public:
unsigned offset() const { return m_rel.r_offset; }
unsigned type() const { return ELF32_R_TYPE(m_rel.r_info); }
unsigned symbol_index() const { return ELF32_R_SYM(m_rel.r_info); }
const Symbol symbol() const { return m_image.symbol(symbol_index()); }
Symbol symbol() const { return m_image.symbol(symbol_index()); }
private:
const Image& m_image;
@ -185,9 +185,9 @@ public:
unsigned section_count() const;
unsigned program_header_count() const;
const Symbol symbol(unsigned) const;
const Section section(unsigned) const;
const ProgramHeader program_header(unsigned const) const;
Symbol symbol(unsigned) const;
Section section(unsigned) const;
ProgramHeader program_header(unsigned) const;
FlatPtr program_header_table_offset() const;
template<typename F>
@ -201,7 +201,7 @@ public:
// NOTE: Returns section(0) if section with name is not found.
// FIXME: I don't love this API.
const Section lookup_section(const String& name) const;
Section lookup_section(const String& name) const;
bool is_executable() const { return header().e_type == ET_EXEC; }
bool is_relocatable() const { return header().e_type == ET_REL; }
@ -258,7 +258,7 @@ inline void Image::for_each_section_of_type(unsigned type, F func) const
{
auto section_count = this->section_count();
for (unsigned i = 0; i < section_count; ++i) {
auto& section = this->section(i);
auto section = this->section(i);
if (section.type() == type) {
if (func(section) == IterationDecision::Break)
break;