diff options
-rw-r--r-- | subx/020elf.cc | 1 | ||||
-rw-r--r-- | subx/021translate.cc | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/subx/020elf.cc b/subx/020elf.cc index 807010ea..18b52634 100644 --- a/subx/020elf.cc +++ b/subx/020elf.cc @@ -7,6 +7,7 @@ if (is_equal(argv[1], "run")) { reset(); cerr << std::hex; initialize_mem(); + Mem_offset = CODE_START; load_elf(argv[2]); while (EIP < End_of_program) // weak final-gasp termination check run_one_instruction(); diff --git a/subx/021translate.cc b/subx/021translate.cc index c32b8fef..9ab33026 100644 --- a/subx/021translate.cc +++ b/subx/021translate.cc @@ -13,7 +13,8 @@ typedef void (*transform_fn)(const string& input, string& output); vector<transform_fn> Transform; :(before "End Includes") -const int START = 0x08048000; +const int CODE_START = 0x08048000; +const int CODE_SIZE = 0x1000; :(before "End Main") if (is_equal(argv[1], "translate")) { assert(argc > 3); @@ -68,7 +69,7 @@ void dump_elf_header(ostream& out) { // e_version O(0x01); O(0x00); O(0x00); O(0x00); // e_entry - int e_entry = START + /*size of ehdr*/52 + /*size of phdr*/32; + int e_entry = CODE_START + /*size of ehdr*/52 + /*size of phdr*/32; emit(e_entry); // e_phoff -- immediately after ELF header int e_phoff = 52; @@ -108,6 +109,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); emit(size); // p_memsz emit(size); |