From 279eeb199a20812068d4091be0652c8ba85fcba5 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 5 May 2021 21:54:27 +0200 Subject: 04: dynld, map initial SO region with MAP_NONE --- 04_dynld_nostd/dynld.c | 2 +- lib/include/syscalls.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/04_dynld_nostd/dynld.c b/04_dynld_nostd/dynld.c index 5193761..4de9ed5 100644 --- a/04_dynld_nostd/dynld.c +++ b/04_dynld_nostd/dynld.c @@ -324,7 +324,7 @@ static Dso map_dependency(const char* dependency) { addr_end = (addr_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); // Reserve region big enough to map all `PT_LOAD` sections of `dependency`. - uint8_t* map = mmap(0 /* addr */, addr_end - addr_start /* len */, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, + uint8_t* map = mmap(0 /* addr */, addr_end - addr_start /* len */, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1 /* fd */, 0 /* file offset */); ERROR_ON(map == MAP_FAILED, "Failed to mmap address space for dependency '%s'\n", dependency); diff --git a/lib/include/syscalls.h b/lib/include/syscalls.h index 7808e98..20362d6 100644 --- a/lib/include/syscalls.h +++ b/lib/include/syscalls.h @@ -25,6 +25,7 @@ ssize_t read(int fd, void* buf, size_t count); ssize_t pread(int fd, void* buf, size_t count, off_t offset); // mmap - prot: +#define PROT_NONE 0x0 #define PROT_READ 0x1 #define PROT_WRITE 0x2 #define PROT_EXEC 0x4 -- cgit v1.2.3