about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--subx/020elf.cc18
-rw-r--r--subx/021translate.cc5
2 files changed, 13 insertions, 10 deletions
diff --git a/subx/020elf.cc b/subx/020elf.cc
index 18b52634..21d0d6bf 100644
--- a/subx/020elf.cc
+++ b/subx/020elf.cc
@@ -92,13 +92,19 @@ void load_segment_from_program_header(uint8_t* elf_contents, size_t size, uint32
     End_of_program = p_vaddr+p_memsz;
 }
 
+:(before "End Includes")
+// Very primitive/fixed/insecure ELF segments for now.
+//   code: 0x08048000 -> 0x08048fff
+//   data: 0x08049000 -> 0x08049fff
+//   heap: 0x0804a000 -> 0x0804afff
+//   stack: 0x0804bfff -> 0x0804b000 (downward)
+const int CODE_START = 0x08048000;
+const int SEGMENT_SIZE = 0x1000;
+const int DATA_START = 0x08049000;
+const int AFTER_STACK = 0x0804c000;
+:(code)
 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);
+  Mem.resize(AFTER_STACK - CODE_START);
 }
 
 inline uint32_t u32_in(uint8_t* p) {
diff --git a/subx/021translate.cc b/subx/021translate.cc
index 9ab33026..6d0fb899 100644
--- a/subx/021translate.cc
+++ b/subx/021translate.cc
@@ -12,9 +12,6 @@ typedef void (*transform_fn)(const string& input, string& output);
 :(before "End Globals")
 vector<transform_fn> Transform;
 
-:(before "End Includes")
-const int CODE_START = 0x08048000;
-const int CODE_SIZE = 0x1000;
 :(before "End Main")
 if (is_equal(argv[1], "translate")) {
   assert(argc > 3);
@@ -109,7 +106,7 @@ void dump_elf_header(ostream& out) {
   emit(e_entry);
   // p_filesz
   uint32_t size = End_of_program - /*we're not using location 0*/1;
-  assert(size < CODE_SIZE);
+  assert(size < SEGMENT_SIZE);
   emit(size);
   // p_memsz
   emit(size);