1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00

UserspaceEmulator: Add ways to check if a Region is stack/mmap

This commit is contained in:
Andreas Kling 2020-07-16 17:04:04 +02:00
parent 9f1221c785
commit 7e13244238
Notes: sideshowbarker 2024-07-19 04:45:46 +09:00
3 changed files with 8 additions and 0 deletions

View file

@ -75,6 +75,7 @@ Emulator::Emulator(const Vector<String>& arguments, NonnullRefPtr<ELF::Loader> e
void Emulator::setup_stack(const Vector<String>& arguments)
{
auto stack_region = make<SimpleRegion>(stack_location, stack_size);
stack_region->set_stack(true);
m_mmu.add_region(move(stack_region));
m_cpu.set_esp(stack_location + stack_size);

View file

@ -55,6 +55,7 @@ public:
private:
MmapRegion(u32 base, u32 size, int prot);
virtual bool is_mmap() const override { return true; }
u8* m_data { nullptr };
int m_prot { 0 };

View file

@ -58,6 +58,10 @@ public:
virtual u8* cacheable_ptr([[maybe_unused]] u32 offset) { return nullptr; }
virtual bool is_shared_buffer() const { return false; }
virtual bool is_mmap() const { return false; }
bool is_stack() const { return m_stack; }
void set_stack(bool b) { m_stack = b; }
protected:
Region(u32 base, u32 size)
@ -69,6 +73,8 @@ public:
private:
u32 m_base { 0 };
u32 m_size { 0 };
bool m_stack { false };
};
u8 read8(X86::LogicalAddress);