diff options
Diffstat (limited to 'subx/020elf.cc')
-rw-r--r-- | subx/020elf.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/subx/020elf.cc b/subx/020elf.cc index d5f1e109..807010ea 100644 --- a/subx/020elf.cc +++ b/subx/020elf.cc @@ -6,6 +6,7 @@ if (is_equal(argv[1], "run")) { assert(argc > 2); reset(); cerr << std::hex; + initialize_mem(); load_elf(argv[2]); while (EIP < End_of_program) // weak final-gasp termination check run_one_instruction(); @@ -90,6 +91,15 @@ void load_segment_from_program_header(uint8_t* elf_contents, size_t size, uint32 End_of_program = p_vaddr+p_memsz; } +void initialize_mem() { + // Very primitive/fixed/insecure ELF segments for now. + // code: 0x08048000 -> 0x08048fff + // data: 0x08049000 -> 0x08049fff + // heap: 0x0804a000 -> 0x0804afff + // stack: 0x0804bfff -> 0x0804b000 (downward) + Mem.resize(0x0804c000 - 0x08048000); +} + inline uint32_t u32_in(uint8_t* p) { return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; } |