Merge pull request #106 from joshtriplett/darwin-award [3.1 blocker] Update OS X build system to include win32.S on 32-bit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
diff --git a/Makefile.am b/Makefile.am
index e2011e7..7ab945f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,6 +138,9 @@ nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
endif
if X86_DARWIN
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
+if X86_DARWIN32
+nodist_libffi_la_SOURCES += src/x86/win32.S
+endif
endif
if SPARC
nodist_libffi_la_SOURCES += src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
diff --git a/configure.ac b/configure.ac
index 3169c43..00b4317 100644
--- a/configure.ac
+++ b/configure.ac
@@ -300,6 +300,8 @@ AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
+AM_CONDITIONAL(X86_DARWIN32, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 4)
+AM_CONDITIONAL(X86_DARWIN64, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 8)
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
@@ -439,11 +441,9 @@ AC_ARG_ENABLE(pax_emutramp,
[Define this if you want to enable pax emulated trampolines])
fi)
-if test x$TARGET = xX86_WIN64; then
- LT_SYS_SYMBOL_USCORE
- if test "x$sys_symbol_underscore" = xyes; then
- AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
- fi
+LT_SYS_SYMBOL_USCORE
+if test "x$sys_symbol_underscore" = xyes; then
+ AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
fi
FFI_EXEC_TRAMPOLINE_TABLE=0
diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py
index 05b7128..964e861 100644
--- a/generate-darwin-source-and-headers.py
+++ b/generate-darwin-source-and-headers.py
@@ -19,7 +19,7 @@ class simulator_platform(Platform):
prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif"
src_dir = 'x86'
- src_files = ['darwin.S', 'ffi.c']
+ src_files = ['darwin.S', 'win32.S', 'ffi.c']
class simulator64_platform(Platform):
@@ -68,7 +68,7 @@ class desktop32_platform(Platform):
triple = 'i386-apple-darwin10'
version_min = '-mmacosx-version-min=10.6'
src_dir = 'x86'
- src_files = ['darwin.S', 'ffi.c']
+ src_files = ['darwin.S', 'win32.S', 'ffi.c']
prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif"
diff --git a/src/x86/win32.S b/src/x86/win32.S
index b455982..d71c8b8 100644
--- a/src/x86/win32.S
+++ b/src/x86/win32.S
@@ -473,7 +473,7 @@ END
#else
-#if defined(X86_WIN32)
+#if defined(SYMBOL_UNDERSCORE)
#define USCORE_SYMBOL(x) _##x
#else
#define USCORE_SYMBOL(x) x
@@ -691,6 +691,8 @@ USCORE_SYMBOL(ffi_closure_SYSV):
movl %edx, (%esp) /* &resp */
#if defined(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) || !defined(__PIC__)
call USCORE_SYMBOL(ffi_closure_SYSV_inner)
+#elif defined(X86_DARWIN)
+ calll L_ffi_closure_SYSV_inner$stub
#else
movl %ebx, 8(%esp)
call 1f
@@ -970,6 +972,8 @@ USCORE_SYMBOL(ffi_closure_STDCALL):
movl %edx, (%esp) /* &resp */
#if defined(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) || !defined(__PIC__)
call USCORE_SYMBOL(ffi_closure_SYSV_inner)
+#elif defined(X86_DARWIN)
+ calll L_ffi_closure_SYSV_inner$stub
#else
movl %ebx, 8(%esp)
call 1f
@@ -1070,6 +1074,13 @@ USCORE_SYMBOL(ffi_closure_STDCALL):
.ffi_closure_STDCALL_end:
.LFE5:
+#if defined(X86_DARWIN)
+.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
+L_ffi_closure_SYSV_inner$stub:
+ .indirect_symbol _ffi_closure_SYSV_inner
+ hlt ; hlt ; hlt ; hlt ; hlt
+#endif
+
#if defined(X86_WIN32) && !defined(__OS2__)
.section .eh_frame,"w"
#endif