From 985c01116bf6266001130bef144d2ccf1910c73f Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Mon, 28 Sep 2015 15:37:31 +0200 Subject: [PATCH] nova: PIC compatible syscall_5 Addressing must be PC-relative, so adapt the approach from the other nova_x86_32 syscall bindings (description by @ssumpf): Use call to push the current IP on the stack and add the distance of label 0 and label 1 in order to determine the return address, which NOVA requires in edx. The bug only showed up with "-O0" in libc.lib.so in form of a unwanted text relocation. Fixes #1721 --- repos/base-nova/include/spec/32bit/nova/syscalls.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/repos/base-nova/include/spec/32bit/nova/syscalls.h b/repos/base-nova/include/spec/32bit/nova/syscalls.h index abb012fc5..d345f9ad9 100644 --- a/repos/base-nova/include/spec/32bit/nova/syscalls.h +++ b/repos/base-nova/include/spec/32bit/nova/syscalls.h @@ -166,9 +166,12 @@ namespace Nova { asm volatile (" push %%ebx;" " mov %%ecx, %%ebx;" - " movl %%esp, %%ecx;" - " movl $1f, %%edx;" + " mov %%esp, %%ecx;" + " call 0f;" + "0:" + " addl $(1f-0b), (%%esp);" + " mov (%%esp), %%edx;" "sysenter;" "1:"