nooc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/nooc
Log | Files | Refs | LICENSE

commit 60bd5daa03ca455e1ad8ea3f37124a95463935f6
parent 4b9ba4cbd1a6e420012c76319c7facfce89ed612
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Fri,  3 Dec 2021 20:16:53 -0600

push starting virtual address to 0x10000

On Linux, virtual memory can only be mapped higher than the
address in /proc/sys/vm/mmap_min_addr. My personal machine with
the highest value has the value 0x10000

Diffstat:
Melf.c | 8++++----
Mnooc.h | 3++-
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/elf.c b/elf.c @@ -24,7 +24,7 @@ elf(char *text, size_t len, char* data, size_t dlen, FILE *f) ehdr.e_machine = EM_X86_64; ehdr.e_version = EV_CURRENT; - ehdr.e_entry = 0x1000; + ehdr.e_entry = TEXT_OFFSET; ehdr.e_phoff = sizeof(ehdr); ehdr.e_phentsize = sizeof(phdr_text); ehdr.e_phnum = 2; @@ -35,15 +35,15 @@ elf(char *text, size_t len, char* data, size_t dlen, FILE *f) phdr_text.p_type = PT_LOAD; phdr_text.p_offset = 0x1000; - phdr_text.p_vaddr = 0x1000; - phdr_text.p_paddr = 0x1000; + phdr_text.p_vaddr = TEXT_OFFSET; + phdr_text.p_paddr = TEXT_OFFSET; phdr_text.p_filesz = len; phdr_text.p_memsz = len; phdr_text.p_flags = PF_R | PF_X; phdr_text.p_align = 0x1000; phdr_data.p_type = PT_LOAD; - phdr_data.p_offset = DATA_OFFSET; + phdr_data.p_offset = 0x2000; phdr_data.p_vaddr = DATA_OFFSET; phdr_data.p_paddr = DATA_OFFSET; phdr_data.p_filesz = dlen; diff --git a/nooc.h b/nooc.h @@ -1,4 +1,5 @@ -#define DATA_OFFSET 0x2000 +#define TEXT_OFFSET 0x101000 +#define DATA_OFFSET 0x102000 enum tokentype { TOK_NONE = 0,