From: Grazvydas Ignotas Date: Thu, 27 Jun 2013 22:41:09 +0000 (+0300) Subject: add plat_mem_set_exec() X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6282e17ef5f37915df1a77b5d7138c666e94d0fb;p=libpicofe.git add plat_mem_set_exec() --- diff --git a/linux/plat.c b/linux/plat.c index 04ebd12..c34beea 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -200,6 +200,16 @@ void plat_munmap(void *ptr, size_t size) } } +int plat_mem_set_exec(void *ptr, size_t size) +{ + int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC); + if (ret != 0) + fprintf(stderr, "mprotect(%p, %zd) failed: %d\n", + ptr, size, errno); + + return ret; +} + /* lprintf */ void lprintf(const char *fmt, ...) { diff --git a/plat.h b/plat.h index ab9b3e7..54436cd 100644 --- a/plat.h +++ b/plat.h @@ -102,6 +102,7 @@ void plat_sleep_ms(int ms); void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed); void *plat_mremap(void *ptr, size_t oldsize, size_t newsize); void plat_munmap(void *ptr, size_t size); +int plat_mem_set_exec(void *ptr, size_t size); /* timers, to be used for time diff and must refer to the same clock */ unsigned int plat_get_ticks_ms(void);