Implement loading of linked ELF executables.

This took me a couple hours. :^)

The ELF loading code now allocates a single region for the entire
file and creates virtual memory mappings for the sections as needed.

Very nice!
This commit is contained in:
Andreas Kling 2018-10-27 14:56:52 +02:00
commit 9a71c7759a
Notes: sideshowbarker 2024-07-19 18:37:37 +09:00
16 changed files with 258 additions and 57 deletions

View file

@ -112,7 +112,7 @@ public:
static void taskDidCrash(Task*);
size_t regionCount() const { return m_regions.size(); }
const Vector<OwnPtr<Region>>& regions() const { return m_regions; }
const Vector<RetainPtr<Region>>& regions() const { return m_regions; }
void dumpRegions();
void didSchedule() { ++m_timesScheduled; }
@ -166,7 +166,7 @@ private:
RetainPtr<VirtualFileSystem::Node> m_cwd;
struct Region {
struct Region : public Retainable<Region> {
Region(LinearAddress, size_t, RetainPtr<Zone>&&, String&&);
~Region();
LinearAddress linearAddress;
@ -174,12 +174,26 @@ private:
RetainPtr<Zone> zone;
String name;
};
struct Subregion {
Subregion(Region&, dword offset, size_t, LinearAddress, String&& name);
~Subregion();
RetainPtr<Region> region;
dword offset;
size_t size { 0 };
LinearAddress linearAddress;
String name;
};
Region* allocateRegion(size_t, String&& name);
Region* allocateRegion(size_t, String&& name, LinearAddress);
bool deallocateRegion(Region& region);
Region* regionFromRange(LinearAddress, size_t);
Vector<OwnPtr<Region>> m_regions;
Vector<RetainPtr<Region>> m_regions;
Vector<OwnPtr<Subregion>> m_subregions;
// FIXME: Implement some kind of ASLR?
LinearAddress m_nextRegion;