about summary refs log tree commit diff stats
path: root/subx/012elf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'subx/012elf.cc')
-rw-r--r--subx/012elf.cc22
1 files changed, 10 insertions, 12 deletions
diff --git a/subx/012elf.cc b/subx/012elf.cc
index 85eb406a..2e10246e 100644
--- a/subx/012elf.cc
+++ b/subx/012elf.cc
@@ -80,7 +80,7 @@ void load_elf_contents(uint8_t* elf_contents, size_t size, int argc, char* argv[
       assert(overlap.find(argv_data) == overlap.end());  // don't bother comparing ARGV and STACK
       write_mem_u8(argv_data, argv[i][j]);
       argv_data += sizeof(char);
-      assert(argv_data < ARGV_DATA_SEGMENT + SEGMENT_SIZE);
+      assert(argv_data < ARGV_DATA_SEGMENT + INITIAL_SEGMENT_SIZE);
     }
   }
   push(argc-/*skip 'subx_bin' and 'run'*/2);
@@ -111,7 +111,7 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index,
 
   if (p_offset + p_filesz > size)
     raise << "Invalid binary; segment at offset " << offset << " is too large: wants to end at " << p_offset+p_filesz << " but the file ends at " << size << '\n' << die();
-  if (p_memsz > INITIAL_SEGMENT_SIZE) {
+  if (p_memsz >= INITIAL_SEGMENT_SIZE) {
     raise << "Code segment too small for SubX; for now please manually increase INITIAL_SEGMENT_SIZE.\n" << end();
     return;
   }
@@ -129,16 +129,14 @@ 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: 0x08048000 -> 0x08048fff
-//   data/heap: 0x08050000 -> 0x08050fff
-//   stack: 0x08060fff -> 0x08060000 (downward)
-const int SEGMENT_SIZE = 0x1000;
-const int CODE_START = 0x08048000;
-const int DATA_SEGMENT = 0x08050000;
-const int HEAP_SEGMENT = DATA_SEGMENT;
-const int STACK_SEGMENT = 0x08060000;
-const int AFTER_STACK = 0x08060ffc;  // forget final word because of the off-by-one with INITIAL_SEGMENT_SIZE;
-const int ARGV_DATA_SEGMENT = 0x08070000;
+//   code: 0x09000000 -> 0x09ffffff
+//   data/heap: 0x0a000000 -> 0x0affffff
+//   stack: 0x0b000ffc -> 0x0b000000 (downward)
+const int CODE_SEGMENT = 0x09000000;
+const int DATA_SEGMENT = 0x0a000000;
+const int STACK_SEGMENT = 0x0b000000;
+const int AFTER_STACK = 0x0b000ffc;  // forget final word because of the off-by-one with INITIAL_SEGMENT_SIZE;
+const int ARGV_DATA_SEGMENT = 0x0c000000;
 :(code)
 inline uint32_t u32_in(uint8_t* p) {
   return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
ef='#n196'>196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269