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

LibELF: Remove sketchy use of "undefined" ELF::Image::Section

We were using ELF::Image::section(0) to indicate the "undefined"
section, when what we really wanted was just Optional<Section>.

So let's use Optional instead. :^)
This commit is contained in:
Andreas Kling 2021-05-15 00:13:44 +02:00
parent f70d0f03de
commit 16221305ad
6 changed files with 18 additions and 19 deletions

View file

@ -114,8 +114,7 @@ public:
u32 address() const { return m_section_header.sh_addr; }
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; }
RelocationSection relocations() const;
Optional<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; }
@ -177,9 +176,7 @@ public:
template<typename F>
void for_each_program_header(F) const;
// NOTE: Returns section(0) if section with name is not found.
// FIXME: I don't love this API.
Section lookup_section(const String& name) const;
Optional<Section> lookup_section(String const& name) const;
bool is_executable() const { return header().e_type == ET_EXEC; }
bool is_relocatable() const { return header().e_type == ET_REL; }