This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[patch libffi]: Make sure code is position-independent for x64 targets
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: libffi-discuss at sourceware dot org, Andrew Haley <aph at redhat dot com>
- Date: Fri, 22 Mar 2013 08:42:30 +0100
- Subject: [patch libffi]: Make sure code is position-independent for x64 targets
Hi,
this patch fixes the Win64-code so that we use only pc-relative
addressing. This
is of importance if code gets linked to an pe-image with an image-base
above 2GB.
ChangeLog
2013-03-22 Kai Tietz <ktietz@redhat.com>
* src/x86/win64.S: Make use of ffi_closure_win64_inner
symbol pc-relative.
Tested for x86_64-w64-mingw32, and for upcoming x86_64-pc-cygwin
target. Ok for apply?
Regards,
Kai
Index: src/x86/win64.S
===================================================================
--- src/x86/win64.S (Revision 196898)
+++ src/x86/win64.S (Arbeitskopie)
@@ -295,7 +295,7 @@
mov %rax, %rcx # context is first parameter
mov %rsp, %rdx # stack is second parameter
add $48, %rdx # point to start of arguments
- mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax
+ leaq SYMBOL_NAME(ffi_closure_win64_inner)(%rip), %rax
callq *%rax # call the real closure function
add $40, %rsp
movq %rax, %xmm0 # If the closure returned a float,