Commit 2087dcf736274286f76c69d3988fb6d7cc4fd0f5

Josh Triplett 2014-03-21T10:57:06

win32.S: Make calls to ffi_closure_SYSV_inner position-independent Now that non-Windows platforms include win32.S, it needs to support building as position-independent code. This fixes one source of build failures on target platforms that do not allow text relocations.

diff --git a/src/x86/win32.S b/src/x86/win32.S
index 700cb61..7cbae2a 100644
--- a/src/x86/win32.S
+++ b/src/x86/win32.S
@@ -688,7 +688,16 @@ USCORE_SYMBOL(ffi_closure_SYSV):
 	movl	%edx, 4(%esp)	/* args = __builtin_dwarf_cfa () */
 	leal	-12(%ebp), %edx
 	movl	%edx, (%esp)	/* &resp */
+#if defined(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) || !defined(__PIC__)
 	call	USCORE_SYMBOL(ffi_closure_SYSV_inner)
+#else
+	movl	%ebx, 8(%esp)
+	call	1f
+1:	popl	%ebx
+	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+	call	ffi_closure_SYSV_inner@PLT
+	movl	8(%esp), %ebx
+#endif
 	movl	-12(%ebp), %ecx
 
 0:
@@ -956,7 +965,16 @@ USCORE_SYMBOL(ffi_closure_STDCALL):
 	movl	%edx, 4(%esp)	/* args */
 	leal	-12(%ebp), %edx
 	movl	%edx, (%esp)	/* &resp */
+#if defined(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) || !defined(__PIC__)
 	call	USCORE_SYMBOL(ffi_closure_SYSV_inner)
+#else
+	movl	%ebx, 8(%esp)
+	call	1f
+1:	popl	%ebx
+	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+	call	ffi_closure_SYSV_inner@PLT
+	movl	8(%esp), %ebx
+#endif
 	movl	-12(%ebp), %ecx
 0:
 	call	1f