Cleanup symbol exports on darwin and add architecture preprocessor checks to assist in building fat binaries (eg: i386+x86_64 on macOS or arm+aarch64 on iOS) (#450) * x86: Ensure _efi64 suffixed symbols are not exported * x86: Ensure we do not export ffi_prep_cif_machdep Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * x86: Ensure we don't export ffi_call_win64, ffi_closure_win64, or ffi_go_closure_win64 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * closures: Silence a semantic warning libffi/src/closures.c:175:23: This function declaration is not a prototype Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch64: Ensure we don't export ffi_prep_cif_machdep Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * arm: Ensure we don't export ffi_prep_cif_machdep Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch64, arm, x86: Add architecture preprocessor checks to support easier fat builds (eg: iOS) Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * x86: Silence some static analysis warnings libffi/src/x86/ffi64.c:286:21: The left operand of '!=' is a garbage value due to array index out of bounds libffi/src/x86/ffi64.c:297:22: The left operand of '!=' is a garbage value due to array index out of bounds Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch: Use FFI_HIDDEN rather than .hidden Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * ffi.h: Don't advertise ffi_java_rvalue_to_raw, ffi_prep_java_raw_closure, and ffi_prep_java_raw_closure_loc when FFI_NATIVE_RAW_API is 0 Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
diff --git a/include/ffi.h.in b/include/ffi.h.in
index 39cde46..f6b4024 100644
--- a/include/ffi.h.in
+++ b/include/ffi.h.in
@@ -283,11 +283,13 @@ FFI_API size_t ffi_raw_size (ffi_cif *cif);
packing, even on 64-bit machines. I.e. on 64-bit machines longs
and doubles are followed by an empty 64-bit word. */
+#if !FFI_NATIVE_RAW_API
FFI_API
void ffi_java_raw_call (ffi_cif *cif,
void (*fn)(void),
void *rvalue,
ffi_java_raw *avalue);
+#endif
FFI_API
void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);
@@ -414,6 +416,7 @@ ffi_prep_raw_closure_loc (ffi_raw_closure*,
void *user_data,
void *codeloc);
+#if !FFI_NATIVE_RAW_API
FFI_API ffi_status
ffi_prep_java_raw_closure (ffi_java_raw_closure*,
ffi_cif *cif,
@@ -426,6 +429,7 @@ ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data,
void *codeloc);
+#endif
#endif /* FFI_CLOSURES */
diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index 188acf2..f5aae17 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -19,6 +19,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#ifdef __arm64__
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -454,7 +455,7 @@ allocate_int_to_reg_or_stack (struct call_context *context,
return allocate_to_stack (state, stack, size, size);
}
-ffi_status
+ffi_status FFI_HIDDEN
ffi_prep_cif_machdep (ffi_cif *cif)
{
ffi_type *rtype = cif->rtype;
@@ -539,9 +540,9 @@ ffi_prep_cif_machdep (ffi_cif *cif)
#if defined (__APPLE__)
/* Perform Apple-specific cif processing for variadic calls */
-ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
- unsigned int nfixedargs,
- unsigned int ntotalargs)
+ffi_status FFI_HIDDEN
+ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
+ unsigned int ntotalargs)
{
ffi_status status = ffi_prep_cif_machdep (cif);
cif->aarch64_nfixedargs = nfixedargs;
@@ -943,3 +944,5 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
return flags;
}
+
+#endif /* __arm64__ */
diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S
index d12bf27..5662414 100644
--- a/src/aarch64/sysv.S
+++ b/src/aarch64/sysv.S
@@ -19,6 +19,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+#ifdef __arm64__
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
@@ -198,9 +199,9 @@ CNAME(ffi_call_SYSV):
cfi_endproc
.globl CNAME(ffi_call_SYSV)
+ FFI_HIDDEN(CNAME(ffi_call_SYSV))
#ifdef __ELF__
.type CNAME(ffi_call_SYSV), #function
- .hidden CNAME(ffi_call_SYSV)
.size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
#endif
@@ -237,9 +238,9 @@ CNAME(ffi_closure_SYSV_V):
cfi_endproc
.globl CNAME(ffi_closure_SYSV_V)
+ FFI_HIDDEN(CNAME(ffi_closure_SYSV_V))
#ifdef __ELF__
.type CNAME(ffi_closure_SYSV_V), #function
- .hidden CNAME(ffi_closure_SYSV_V)
.size CNAME(ffi_closure_SYSV_V), . - CNAME(ffi_closure_SYSV_V)
#endif
@@ -349,9 +350,9 @@ CNAME(ffi_closure_SYSV):
cfi_endproc
.globl CNAME(ffi_closure_SYSV)
+ FFI_HIDDEN(CNAME(ffi_closure_SYSV))
#ifdef __ELF__
.type CNAME(ffi_closure_SYSV), #function
- .hidden CNAME(ffi_closure_SYSV)
.size CNAME(ffi_closure_SYSV), . - CNAME(ffi_closure_SYSV)
#endif
@@ -369,9 +370,9 @@ CNAME(ffi_closure_trampoline_table_page):
.endr
.globl CNAME(ffi_closure_trampoline_table_page)
+ FFI_HIDDEN(CNAME(ffi_closure_trampoline_table_page))
#ifdef __ELF__
.type CNAME(ffi_closure_trampoline_table_page), #function
- .hidden CNAME(ffi_closure_trampoline_table_page)
.size CNAME(ffi_closure_trampoline_table_page), . - CNAME(ffi_closure_trampoline_table_page)
#endif
#endif
@@ -396,9 +397,9 @@ CNAME(ffi_go_closure_SYSV_V):
cfi_endproc
.globl CNAME(ffi_go_closure_SYSV_V)
+ FFI_HIDDEN(CNAME(ffi_go_closure_SYSV_V))
#ifdef __ELF__
.type CNAME(ffi_go_closure_SYSV_V), #function
- .hidden CNAME(ffi_go_closure_SYSV_V)
.size CNAME(ffi_go_closure_SYSV_V), . - CNAME(ffi_go_closure_SYSV_V)
#endif
@@ -425,12 +426,13 @@ CNAME(ffi_go_closure_SYSV):
cfi_endproc
.globl CNAME(ffi_go_closure_SYSV)
+ FFI_HIDDEN(CNAME(ffi_go_closure_SYSV))
#ifdef __ELF__
.type CNAME(ffi_go_closure_SYSV), #function
- .hidden CNAME(ffi_go_closure_SYSV)
.size CNAME(ffi_go_closure_SYSV), . - CNAME(ffi_go_closure_SYSV)
#endif
#endif /* FFI_GO_CLOSURES */
+#endif /* __arm64__ */
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",%progbits
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index d838271..66a67bd 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -28,6 +28,7 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
+#ifdef __arm__
#include <fficonfig.h>
#include <ffi.h>
#include <ffi_common.h>
@@ -210,7 +211,7 @@ ffi_prep_args_VFP (ffi_cif *cif, int flags, void *rvalue,
}
/* Perform machine dependent cif processing */
-ffi_status
+ffi_status FFI_HIDDEN
ffi_prep_cif_machdep (ffi_cif *cif)
{
int flags = 0, cabi = cif->abi;
@@ -301,7 +302,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
}
/* Perform machine dependent cif processing for variadic calls */
-ffi_status
+ffi_status FFI_HIDDEN
ffi_prep_cif_machdep_var (ffi_cif * cif,
unsigned int nfixedargs, unsigned int ntotalargs)
{
@@ -817,3 +818,5 @@ layout_vfp_args (ffi_cif * cif)
break;
}
}
+
+#endif /* __arm__ */
diff --git a/src/arm/sysv.S b/src/arm/sysv.S
index 7bda640..63180a4 100644
--- a/src/arm/sysv.S
+++ b/src/arm/sysv.S
@@ -25,6 +25,7 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
+#ifdef __arm__
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
@@ -377,6 +378,7 @@ ARM_FUNC_START(ffi_arm_trampoline)
ARM_FUNC_END(ffi_arm_trampoline)
#endif /* FFI_EXEC_TRAMPOLINE_TABLE */
+#endif /* __arm__ */
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",%progbits
diff --git a/src/closures.c b/src/closures.c
index e9e058e..4d7f945 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -172,7 +172,7 @@ struct ffi_trampoline_table
struct ffi_trampoline_table_entry
{
- void *(*trampoline) ();
+ void *(*trampoline) (void);
ffi_trampoline_table_entry *next;
};
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index fc21c4b..c6c7d2b 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -29,7 +29,7 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
-#ifndef __x86_64__
+#ifdef __i386__
#include <ffi.h>
#include <ffi_common.h>
#include <stdint.h>
@@ -756,4 +756,4 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
ffi_call_i386 (frame, stack);
}
#endif /* !FFI_NO_RAW_API */
-#endif /* !__x86_64__ */
+#endif /* __i386__ */
diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c
index 41d6acd..4d53b53 100644
--- a/src/x86/ffi64.c
+++ b/src/x86/ffi64.c
@@ -282,7 +282,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
/* The X86_64_SSEUP_CLASS should be always preceded by
X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
- if (classes[i] == X86_64_SSEUP_CLASS
+ if (i > 1 && classes[i] == X86_64_SSEUP_CLASS
&& classes[i - 1] != X86_64_SSE_CLASS
&& classes[i - 1] != X86_64_SSEUP_CLASS)
{
@@ -293,7 +293,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
/* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
everything should be passed in memory. */
- if (classes[i] == X86_64_X87UP_CLASS
+ if (i > 1 && classes[i] == X86_64_X87UP_CLASS
&& (classes[i - 1] != X86_64_X87_CLASS))
{
/* The first one should never be X86_64_X87UP_CLASS. */
@@ -394,7 +394,7 @@ extern ffi_status
ffi_prep_cif_machdep_efi64(ffi_cif *cif);
#endif
-ffi_status
+ffi_status FFI_HIDDEN
ffi_prep_cif_machdep (ffi_cif *cif)
{
int gprcount, ssecount, i, avn, ngpr, nsse;
diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c
index f787525..ca4d3ca 100644
--- a/src/x86/ffiw64.c
+++ b/src/x86/ffiw64.c
@@ -25,6 +25,7 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
+#ifdef __x86_64__
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
@@ -33,7 +34,7 @@
#ifdef X86_WIN64
#define EFI64(name) name
#else
-#define EFI64(name) name##_efi64
+#define EFI64(name) FFI_HIDDEN name##_efi64
#endif
struct win64_call_frame
@@ -48,7 +49,7 @@ struct win64_call_frame
extern void ffi_call_win64 (void *stack, struct win64_call_frame *,
void *closure) FFI_HIDDEN;
-ffi_status
+ffi_status FFI_HIDDEN
EFI64(ffi_prep_cif_machdep)(ffi_cif *cif)
{
int flags, n;
@@ -306,3 +307,5 @@ ffi_closure_win64_inner(ffi_cif *cif,
fun (cif, rvalue, avalue, user_data);
return flags;
}
+
+#endif /* __x86_64__ */
diff --git a/src/x86/sysv.S b/src/x86/sysv.S
index 3e462c1..7c9598c 100644
--- a/src/x86/sysv.S
+++ b/src/x86/sysv.S
@@ -26,7 +26,7 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
-#ifndef __x86_64__
+#ifdef __i386__
#ifndef _MSC_VER
#define LIBFFI_ASM
@@ -1122,7 +1122,7 @@ L(EFDE9):
#endif /* __APPLE__ */
#endif /* ifndef _MSC_VER */
-#endif /* ifndef __x86_64__ */
+#endif /* ifdef __i386__ */
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
diff --git a/src/x86/win64.S b/src/x86/win64.S
index 10991b4..2c334c8 100644
--- a/src/x86/win64.S
+++ b/src/x86/win64.S
@@ -1,3 +1,4 @@
+#ifdef __x86_64__
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
@@ -42,6 +43,7 @@
.align 8
.globl C(ffi_call_win64)
+ FFI_HIDDEN(C(ffi_call_win64))
SEH(.seh_proc ffi_call_win64)
C(ffi_call_win64):
@@ -169,6 +171,7 @@ E(0b, FFI_TYPE_SMALL_STRUCT_4B)
.align 8
.globl C(ffi_go_closure_win64)
+ FFI_HIDDEN(C(ffi_go_closure_win64))
SEH(.seh_proc ffi_go_closure_win64)
C(ffi_go_closure_win64):
@@ -188,6 +191,7 @@ C(ffi_go_closure_win64):
.align 8
.globl C(ffi_closure_win64)
+ FFI_HIDDEN(C(ffi_closure_win64))
SEH(.seh_proc ffi_closure_win64)
C(ffi_closure_win64):
@@ -226,6 +230,7 @@ C(ffi_closure_win64):
cfi_endproc
SEH(.seh_endproc)
+#endif /* __x86_64__ */
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits