X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fplat.c;h=06c315e830212e7b394344c649aab84cc534e176;hb=26ea18173c1228dd5ce39e2a88ffe1ae10fcb365;hp=660a095ae9df3e31098cd5e89a23211a82aa016a;hpb=af7e50060fc05a2200ea7221f5658e204270c7aa;p=libpicofe.git diff --git a/linux/plat.c b/linux/plat.c index 660a095..06c315e 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -178,8 +178,10 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) req = (void *)addr; if (need_exec) prot |= PROT_EXEC; + /* avoid MAP_FIXED, it overrides existing mappings.. if (is_fixed) flags |= MAP_FIXED; + */ if (size >= HUGETLB_THRESHOLD) flags |= MAP_HUGETLB; @@ -197,9 +199,14 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) if (ret == MAP_FAILED) return NULL; - if (req != NULL && ret != req) - fprintf(stderr, - "warning: mmaped to %p, requested %p\n", ret, req); + if (req != NULL && ret != req) { + fprintf(stderr, "%s: mmaped to %p, requested %p\n", + is_fixed ? "error" : "warning", ret, req); + if (is_fixed) { + munmap(ret, size); + return NULL; + } + } return ret; }