notaz.gp2x.de
/
libpicofe.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9fec8a9
)
plat: avoid MAP_FIXED
author
notaz
<notasas@gmail.com>
Tue, 24 Mar 2015 22:38:13 +0000
(
00:38
+0200)
committer
notaz
<notasas@gmail.com>
Tue, 24 Mar 2015 22:38:13 +0000
(
00:38
+0200)
linux/plat.c
patch
|
blob
|
blame
|
history
diff --git
a/linux/plat.c
b/linux/plat.c
index
660a095
..
06c315e
100644
(file)
--- 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;
req = (void *)addr;
if (need_exec)
prot |= PROT_EXEC;
+ /* avoid MAP_FIXED, it overrides existing mappings..
if (is_fixed)
flags |= MAP_FIXED;
if (is_fixed)
flags |= MAP_FIXED;
+ */
if (size >= HUGETLB_THRESHOLD)
flags |= MAP_HUGETLB;
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 (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;
}
return ret;
}