about summary refs log tree commit diff stats
path: root/subx/012elf.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-05-10 16:45:22 -0700
committerKartik Agaram <vc@akkartik.com>2019-05-10 16:45:22 -0700
commitc88b9e31259d433c7e63fcb19d430daf9b1c723c (patch)
tree12de1a20312a788d07ef6564084b7ca81aa15ba1 /subx/012elf.cc
parentcdfb2dbfcf18cd2f23bf74199082392c3692a599 (diff)
downloadmu-c88b9e31259d433c7e63fcb19d430daf9b1c723c.tar.gz
5151 - use mmap everywhere we need a heap
All tests passing now. Things are very explicit; before a program can `allocate`
memory, it has to first obtain a segment from the OS using `new-segment`.
Diffstat (limited to 'subx/012elf.cc')
-rw-r--r--subx/012elf.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/subx/012elf.cc b/subx/012elf.cc
index 11e0e4bc..d0a3fbd2 100644
--- a/subx/012elf.cc
+++ b/subx/012elf.cc
@@ -134,13 +134,20 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index,
 //   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 -> 0xc0000000 (not in ELF binary)
+//   stack: 0x7dffffff -> 0x7d000000 (downward; not in ELF binary)
+//   argv hack: 0x7f000000 -> 0x7fffffff (not in ELF binary)
+//
+// For now we avoid addresses with the most significant bit set; SubX doesn't
+// support unsigned comparison yet (https://github.com/akkartik/mu/issues/30)
+// Once we do, we can go up to 0xc0000000; higher addresses are reserved for
+// the Linux kernel.
 const int CODE_SEGMENT      = 0x09000000;
 const int DATA_SEGMENT =      0x0a000000;
-const int STACK_SEGMENT     = 0xbd000000;
-const int AFTER_STACK       = 0xbe000000;
-const int ARGV_DATA_SEGMENT = 0xbf000000;
+const int STACK_SEGMENT     = 0x7d000000;
+const int AFTER_STACK       = 0x7e000000;
+const int ARGV_DATA_SEGMENT = 0x7f000000;
+// When updating the above memory map, don't forget to update `mmap`'s
+// implementation in the 'syscalls' layer.
 :(before "End Dump Info for Instruction")
 //? dump_stack();  // slow
 :(code)