diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-11-23 00:21:41 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-11-23 00:22:24 -0800 |
commit | 4a99a6e0dd3000d8e595ec7b4b04f637e66ded6d (patch) | |
tree | b6d0b7f2145e4370c22fd0142950e648b406b524 /subx/012elf.cc | |
parent | 6ee77ba7bb47bc4b17df67d2683bdbb84f326e8e (diff) | |
download | mu-4a99a6e0dd3000d8e595ec7b4b04f637e66ded6d.tar.gz |
4761
Bugfix: I forgot about ELF segment offsets when implementing VMAs. Eventually segments grew large enough that I started seeing overlaps.
Diffstat (limited to 'subx/012elf.cc')
-rw-r--r-- | subx/012elf.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/subx/012elf.cc b/subx/012elf.cc index 3f8187ba..2ab469e0 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 + INITIAL_SEGMENT_SIZE); + assert(argv_data < ARGV_DATA_SEGMENT + SEGMENT_ALIGNMENT); } } push(argc-/*skip 'subx_bin' and 'run'*/2); @@ -111,8 +111,8 @@ 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) { - raise << "Code segment too small for SubX; for now please manually increase INITIAL_SEGMENT_SIZE.\n" << end(); + if (p_memsz >= SEGMENT_ALIGNMENT) { + raise << "Code segment too small for SubX; for now please manually increase SEGMENT_ALIGNMENT.\n" << end(); return; } trace(90, "load") << "blitting file offsets (" << p_offset << ", " << (p_offset+p_filesz) << ") to addresses (" << p_vaddr << ", " << (p_vaddr+p_memsz) << ')' << end(); @@ -135,7 +135,7 @@ void load_segment_from_program_header(uint8_t* elf_contents, int segment_index, 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 AFTER_STACK = 0x0b000ffc; // forget final word because of the off-by-one with SEGMENT_ALIGNMENT; const int ARGV_DATA_SEGMENT = 0x0c000000; :(code) void dump_stack() { |