diff options
Diffstat (limited to 'subx')
-rw-r--r-- | subx/012elf.cc | 16 | ||||
-rw-r--r-- | subx/020syscalls.cc | 5 |
2 files changed, 9 insertions, 12 deletions
diff --git a/subx/012elf.cc b/subx/012elf.cc index 0ae0b108..da70adec 100644 --- a/subx/012elf.cc +++ b/subx/012elf.cc @@ -138,15 +138,13 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index, :(before "End Includes") // Very primitive/fixed/insecure ELF segments for now. -// code: 0x09000000 -> 0x09ffffff (specified in ELF binary) -// data: 0x0a000000 -> 0x0affffff (specified in ELF binary) -// --- heap gets mmap'd somewhere here --- -// stack: 0xbdffffff -> 0xbd000000 (downward; not in ELF binary) -// argv hack: 0xbf000000 -> 0xbfffffff (not in ELF binary) -// -// Addresses above 0xc0000000 are reserved for the Linux kernel. -const uint32_t CODE_SEGMENT = 0x09000000; -const uint32_t DATA_SEGMENT = 0x0a000000; +// --- inaccessible: 0x00000000 -> 0x08047fff +// code: 0x09000000 -> 0x09ffffff (specified in ELF binary) +// data: 0x0a000000 -> 0x0affffff (specified in ELF binary) +// --- heap gets mmap'd somewhere here --- +// stack: 0xbdffffff -> 0xbd000000 (downward; not in ELF binary) +// argv hack: 0xbf000000 -> 0xbfffffff (not in ELF binary) +// --- reserved for kernel: 0xc0000000 -> ... const uint32_t START_HEAP = 0x0b000000; const uint32_t END_HEAP = 0xbd000000; const uint32_t STACK_SEGMENT = 0xbd000000; diff --git a/subx/020syscalls.cc b/subx/020syscalls.cc index eb8ebcce..eb72f85d 100644 --- a/subx/020syscalls.cc +++ b/subx/020syscalls.cc @@ -112,15 +112,14 @@ void check_mode(int reg) { :(before "End Globals") // Very primitive/fixed/insecure mmap segments for now. uint32_t Segments_allocated_above = END_HEAP; -const uint32_t SPACE_FOR_SEGMENT = 0x01000000; :(code) // always allocate multiples of the segment size uint32_t new_segment(uint32_t length) { assert(length > 0); - uint32_t result = (Segments_allocated_above - length) & 0xff000000; + uint32_t result = (Segments_allocated_above - length) & 0xff000000; // same number of zeroes as SEGMENT_ALIGNMENT if (result <= START_HEAP) { raise << "Allocated too many segments; the VM ran out of memory. " - << "Maybe SPACE_FOR_SEGMENT can be smaller?\n" << end(); + << "Maybe SEGMENT_ALIGNMENT can be smaller?\n" << end(); exit(1); } Mem.push_back(vma(result, result+length)); |