From 672e0a7e5fe7ab7b5f1e454dbc61c1617867a7a9 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 30 Jun 2018 21:19:02 -0700 Subject: 4291 - stop copying the ELF header into memory No need for it once the program's loaded. And we keep programs from running the header as code. This also simplifies the header computation in the translator. --- subx/021translate.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'subx/021translate.cc') diff --git a/subx/021translate.cc b/subx/021translate.cc index ae110c21..94553ae9 100644 --- a/subx/021translate.cc +++ b/subx/021translate.cc @@ -41,7 +41,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 = START; emit(e_entry); // e_phoff -- immediately after ELF header int e_phoff = 52; @@ -73,14 +73,14 @@ void dump_elf_header(ostream& out) { uint32_t p_type = 0x1; emit(p_type); // p_offset - uint32_t p_offset = 0; + uint32_t p_offset = /*size of ehdr*/52 + /*size of phdr*/32; emit(p_offset); // p_vaddr emit(START); // p_paddr emit(START); // p_filesz - uint32_t size = (End_of_program-/*we're not using location 0*/1) + /*size of ehdr*/52 + /*size of phdr*/32; + uint32_t size = End_of_program - /*we're not using location 0*/1; emit(size); // p_memsz emit(size); -- cgit 1.4.1-2-gfad0