aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/darwin/execmem.c7
-rw-r--r--lib/darwin/manual-syscall.h7
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/darwin/execmem.c b/lib/darwin/execmem.c
index 666fa8a..0155b1f 100644
--- a/lib/darwin/execmem.c
+++ b/lib/darwin/execmem.c
@@ -402,9 +402,10 @@ int execmem_foreign_write_with_pc_patch(struct execmem_foreign_write *writes,
* hook one of them. (This includes the mmap, since there's an epilog
* after the actual syscall instruction.)
* This includes the signal handler! */
- if (manual_mmap((void *) page_start, len, PROT_NONE,
- MAP_ANON | MAP_SHARED | MAP_FIXED, -1, 0)
- == MAP_FAILED) {
+ void *mmret = manual_mmap((void *) page_start, len, PROT_NONE,
+ MAP_ANON | MAP_SHARED | MAP_FIXED, -1, 0);
+ /* MAP_FAILED is a userspace construct */
+ if ((uintptr_t) mmret & 0xfff) {
ret = SUBSTITUTE_ERR_VM;
goto fail_unmap;
}
diff --git a/lib/darwin/manual-syscall.h b/lib/darwin/manual-syscall.h
index b1bac7e..88ac179 100644
--- a/lib/darwin/manual-syscall.h
+++ b/lib/darwin/manual-syscall.h
@@ -23,9 +23,12 @@
#elif defined(__i386__)
#define GEN_SYSCALL_INNER() \
"mov $num, %eax\n" \
- "pop %edx\n" \
+ "call 0f\n" \
+ "0: pop %edx\n" \
+ "add $(1f-0b), %edx\n" \
"mov %esp, %ecx\n" \
- "sysenter\n"
+ "sysenter\n" \
+ "1: ret\n"
#elif defined(__arm__)
#define GEN_SYSCALL_INNER() \
"mov r12, #num\n" \