1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

Kernel: Simplify ELF loading a bit.

Instead of iterating over the sections and memcpy()ing per-section,
do all the copying based on program headers instead.
This commit is contained in:
Andreas Kling 2019-02-26 15:52:06 +01:00
parent c80182f81f
commit 2e5b9d318f
2 changed files with 5 additions and 41 deletions

View file

@ -47,7 +47,8 @@ public:
class ProgramHeader {
public:
ProgramHeader(const ELFImage& image, unsigned program_header_index)
: m_program_header(image.program_header_internal(program_header_index))
: m_image(image)
, m_program_header(image.program_header_internal(program_header_index))
, m_program_header_index(program_header_index)
{
}
@ -64,7 +65,9 @@ public:
bool is_readable() const { return flags() & PF_R; }
bool is_writable() const { return flags() & PF_W; }
bool is_executable() const { return flags() & PF_X; }
const char* raw_data() const { return m_image.raw_data(m_program_header.p_offset); }
private:
const ELFImage& m_image;
const Elf32_Phdr& m_program_header;
unsigned m_program_header_index { 0 };
};