ffi 1.16.3 → 1.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +59 -0
- data/Gemfile +11 -2
- data/README.md +1 -1
- data/Rakefile +19 -7
- data/ext/ffi_c/AbstractMemory.c +39 -38
- data/ext/ffi_c/ArrayType.c +2 -2
- data/ext/ffi_c/Buffer.c +4 -4
- data/ext/ffi_c/Call.c +12 -6
- data/ext/ffi_c/Call.h +3 -2
- data/ext/ffi_c/DynamicLibrary.c +2 -2
- data/ext/ffi_c/Function.c +52 -34
- data/ext/ffi_c/FunctionInfo.c +1 -1
- data/ext/ffi_c/LastError.c +4 -4
- data/ext/ffi_c/MemoryPointer.c +2 -2
- data/ext/ffi_c/Pointer.c +14 -11
- data/ext/ffi_c/Struct.c +11 -4
- data/ext/ffi_c/StructLayout.c +13 -13
- data/ext/ffi_c/Type.c +17 -16
- data/ext/ffi_c/Types.c +7 -1
- data/ext/ffi_c/Types.h +0 -1
- data/ext/ffi_c/Variadic.c +6 -3
- data/ext/ffi_c/libffi/.allow-ai-service +0 -0
- data/ext/ffi_c/libffi/.github/workflows/build.yml +34 -15
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +50 -61
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +4 -3
- data/ext/ffi_c/libffi/Makefile.in +5 -25
- data/ext/ffi_c/libffi/README.md +28 -6
- data/ext/ffi_c/libffi/acinclude.m4 +6 -0
- data/ext/ffi_c/libffi/config.guess +80 -22
- data/ext/ffi_c/libffi/config.sub +161 -80
- data/ext/ffi_c/libffi/configure +46 -30
- data/ext/ffi_c/libffi/configure.ac +10 -9
- data/ext/ffi_c/libffi/configure.host +1 -6
- data/ext/ffi_c/libffi/doc/Makefile.in +1 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +4 -4
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +3 -3
- data/ext/ffi_c/libffi/include/Makefile.in +1 -0
- data/ext/ffi_c/libffi/include/ffi.h.in +2 -11
- data/ext/ffi_c/libffi/include/ffi_cfi.h +2 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +21 -2
- data/ext/ffi_c/libffi/libffi.map.in +5 -0
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/ltmain.sh +8 -20
- data/ext/ffi_c/libffi/man/Makefile.in +1 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +33 -17
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +2 -2
- data/ext/ffi_c/libffi/src/aarch64/internal.h +63 -17
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +213 -57
- data/ext/ffi_c/libffi/src/arc/arcompact.S +2 -2
- data/ext/ffi_c/libffi/src/arc/ffi.c +6 -2
- data/ext/ffi_c/libffi/src/closures.c +6 -6
- data/ext/ffi_c/libffi/src/debug.c +2 -2
- data/ext/ffi_c/libffi/src/dlmalloc.c +2 -1
- data/ext/ffi_c/libffi/src/loongarch64/ffi.c +3 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +12 -4
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +2 -4
- data/ext/ffi_c/libffi/src/mips/n32.S +69 -14
- data/ext/ffi_c/libffi/src/mips/o32.S +4 -0
- data/ext/ffi_c/libffi/src/or1k/ffi.c +2 -2
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +13 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +36 -24
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +26 -19
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +26 -16
- data/ext/ffi_c/libffi/src/powerpc/internal.h +10 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +47 -0
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +24 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +1 -4
- data/ext/ffi_c/libffi/src/s390/ffi.c +28 -1
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +38 -0
- data/ext/ffi_c/libffi/src/sparc/ffi.c +16 -0
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +7 -1
- data/ext/ffi_c/libffi/src/tramp.c +1 -1
- data/ext/ffi_c/libffi/src/types.c +4 -6
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +23 -262
- data/ext/ffi_c/libffi/src/x86/ffi.c +4 -1
- data/ext/ffi_c/libffi/src/x86/ffi64.c +4 -1
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +1 -1
- data/ext/ffi_c/libffi/testsuite/Makefile.am +80 -127
- data/ext/ffi_c/libffi/testsuite/Makefile.in +81 -127
- data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +4 -24
- data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +8 -25
- data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +6 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +3 -28
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/overread.c +54 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_int_float.c +88 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/x32.c +31 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +1 -1
- data/ext/ffi_c/libffi.darwin.mk +2 -2
- data/lib/ffi/autopointer.rb +1 -9
- data/lib/ffi/dynamic_library.rb +34 -5
- data/lib/ffi/enum.rb +0 -1
- data/lib/ffi/ffi.rb +59 -0
- data/lib/ffi/function.rb +1 -1
- data/lib/ffi/io.rb +2 -2
- data/lib/ffi/library.rb +23 -23
- data/lib/ffi/platform/aarch64-linux/types.conf +74 -3
- data/lib/ffi/pointer.rb +6 -6
- data/lib/ffi/struct.rb +4 -4
- data/lib/ffi/struct_layout.rb +2 -2
- data/lib/ffi/struct_layout_builder.rb +8 -8
- data/lib/ffi/types.rb +51 -49
- data/lib/ffi/version.rb +1 -1
- data/sig/ffi/abstract_memory.rbs +165 -0
- data/sig/ffi/auto_pointer.rbs +26 -0
- data/sig/ffi/buffer.rbs +18 -0
- data/sig/ffi/data_converter.rbs +10 -0
- data/sig/ffi/dynamic_library.rbs +9 -0
- data/sig/ffi/enum.rbs +38 -0
- data/sig/ffi/function.rbs +39 -0
- data/sig/ffi/library.rbs +42 -0
- data/sig/ffi/native_type.rbs +86 -0
- data/sig/ffi/pointer.rbs +42 -0
- data/sig/ffi/struct.rbs +76 -0
- data/sig/ffi/struct_by_reference.rbs +11 -0
- data/sig/ffi/struct_by_value.rbs +7 -0
- data/sig/ffi/struct_layout.rbs +9 -0
- data/sig/ffi/struct_layout_builder.rbs +5 -0
- data/sig/ffi/type.rbs +39 -0
- data/sig/ffi.rbs +26 -0
- data.tar.gz.sig +0 -0
- metadata +41 -22
- metadata.gz.sig +0 -0
- data/ext/ffi_c/libffi/.circleci/config.yml +0 -156
- data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
- data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
- data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
|
@@ -192,9 +192,10 @@ static void unmarshal_atom(call_builder *cb, int type, void *data) {
|
|
|
192
192
|
/* for arguments passed by reference returns the pointer, otherwise the arg is copied (up to MAXCOPYARG bytes) */
|
|
193
193
|
static void *unmarshal(call_builder *cb, ffi_type *type, int var, void *data) {
|
|
194
194
|
size_t realign[2];
|
|
195
|
-
void *pointer;
|
|
196
195
|
|
|
197
196
|
#if defined(__ARC64_ARCH64__)
|
|
197
|
+
void *pointer;
|
|
198
|
+
|
|
198
199
|
if (type->size > 2 * __SIZEOF_POINTER__) {
|
|
199
200
|
/* pass by reference */
|
|
200
201
|
unmarshal_atom(cb, FFI_TYPE_POINTER, (char*)&pointer);
|
|
@@ -348,7 +349,10 @@ ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif,
|
|
|
348
349
|
void *user_data, void *codeloc)
|
|
349
350
|
{
|
|
350
351
|
uint32_t *tramp = (uint32_t *) & (closure->tramp[0]);
|
|
352
|
+
|
|
353
|
+
#if defined(__ARC64_ARCH64__)
|
|
351
354
|
size_t address_ffi_closure = (size_t) ffi_closure_asm;
|
|
355
|
+
#endif
|
|
352
356
|
|
|
353
357
|
switch (cif->abi)
|
|
354
358
|
{
|
|
@@ -367,7 +371,7 @@ ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif,
|
|
|
367
371
|
FFI_ASSERT (tramp == codeloc);
|
|
368
372
|
tramp[0] = CODE_ENDIAN (0x200a1fc0); /* mov r8, pcl */
|
|
369
373
|
tramp[1] = CODE_ENDIAN (0x20200f80); /* j [long imm] */
|
|
370
|
-
tramp[2] = CODE_ENDIAN (ffi_closure_asm);
|
|
374
|
+
tramp[2] = CODE_ENDIAN ((uint32_t) ffi_closure_asm);
|
|
371
375
|
break;
|
|
372
376
|
#endif
|
|
373
377
|
|
|
@@ -164,7 +164,7 @@ ffi_tramp_is_present (__attribute__((unused)) void *ptr)
|
|
|
164
164
|
|
|
165
165
|
#include <mach/mach.h>
|
|
166
166
|
#include <pthread.h>
|
|
167
|
-
#ifdef
|
|
167
|
+
#ifdef HAVE_ARM64E_PTRAUTH
|
|
168
168
|
#include <ptrauth.h>
|
|
169
169
|
#endif
|
|
170
170
|
#include <stdio.h>
|
|
@@ -223,7 +223,7 @@ ffi_trampoline_table_alloc (void)
|
|
|
223
223
|
/* Remap the trampoline table on top of the placeholder page */
|
|
224
224
|
trampoline_page = config_page + PAGE_MAX_SIZE;
|
|
225
225
|
|
|
226
|
-
#ifdef
|
|
226
|
+
#ifdef HAVE_ARM64E_PTRAUTH
|
|
227
227
|
trampoline_page_template = (vm_address_t)(uintptr_t)ptrauth_auth_data((void *)&ffi_closure_trampoline_table_page, ptrauth_key_function_pointer, 0);
|
|
228
228
|
#else
|
|
229
229
|
trampoline_page_template = (vm_address_t)&ffi_closure_trampoline_table_page;
|
|
@@ -268,7 +268,7 @@ ffi_trampoline_table_alloc (void)
|
|
|
268
268
|
ffi_trampoline_table_entry *entry = &table->free_list_pool[i];
|
|
269
269
|
entry->trampoline =
|
|
270
270
|
(void *) (trampoline_page + (i * FFI_TRAMPOLINE_SIZE));
|
|
271
|
-
#ifdef
|
|
271
|
+
#ifdef HAVE_ARM64E_PTRAUTH
|
|
272
272
|
entry->trampoline = ptrauth_sign_unauthenticated(entry->trampoline, ptrauth_key_function_pointer, 0);
|
|
273
273
|
#endif
|
|
274
274
|
|
|
@@ -599,7 +599,7 @@ open_temp_exec_file_memfd (const char *name)
|
|
|
599
599
|
|
|
600
600
|
/* Open a temporary file name, and immediately unlink it. */
|
|
601
601
|
static int
|
|
602
|
-
open_temp_exec_file_name (char *name, int flags)
|
|
602
|
+
open_temp_exec_file_name (char *name, int flags MAYBE_UNUSED)
|
|
603
603
|
{
|
|
604
604
|
int fd;
|
|
605
605
|
|
|
@@ -795,7 +795,7 @@ open_temp_exec_file (void)
|
|
|
795
795
|
Failure to allocate the space will cause SIGBUS to be thrown when
|
|
796
796
|
the mapping is subsequently written to. */
|
|
797
797
|
static int
|
|
798
|
-
allocate_space (int fd, off_t
|
|
798
|
+
allocate_space (int fd, off_t len)
|
|
799
799
|
{
|
|
800
800
|
static long page_size;
|
|
801
801
|
|
|
@@ -838,7 +838,7 @@ dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
|
|
|
838
838
|
|
|
839
839
|
offset = execsize;
|
|
840
840
|
|
|
841
|
-
if (allocate_space (execfd,
|
|
841
|
+
if (allocate_space (execfd, length))
|
|
842
842
|
return MFAIL;
|
|
843
843
|
|
|
844
844
|
flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
|
|
@@ -38,7 +38,7 @@ void ffi_stop_here(void)
|
|
|
38
38
|
|
|
39
39
|
/* This function should only be called via the FFI_ASSERT() macro */
|
|
40
40
|
|
|
41
|
-
void ffi_assert(char *expr, char *file, int line)
|
|
41
|
+
NORETURN void ffi_assert(const char *expr, const char *file, int line)
|
|
42
42
|
{
|
|
43
43
|
fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
|
|
44
44
|
ffi_stop_here();
|
|
@@ -47,7 +47,7 @@ void ffi_assert(char *expr, char *file, int line)
|
|
|
47
47
|
|
|
48
48
|
/* Perform a sanity check on an ffi_type structure */
|
|
49
49
|
|
|
50
|
-
void ffi_type_test(ffi_type *a, char *file, int line)
|
|
50
|
+
void ffi_type_test(ffi_type *a, const char *file, int line)
|
|
51
51
|
{
|
|
52
52
|
FFI_ASSERT_AT(a != NULL, file, line);
|
|
53
53
|
|
|
@@ -3388,6 +3388,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
|
|
|
3388
3388
|
mchunkptr tnext = chunk_plus_offset(sp, ssize);
|
|
3389
3389
|
mchunkptr p = tnext;
|
|
3390
3390
|
int nfences = 0;
|
|
3391
|
+
(void)nfences; // Suppress unused variable warning
|
|
3391
3392
|
|
|
3392
3393
|
/* reset top to new space */
|
|
3393
3394
|
init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
|
|
@@ -4452,7 +4453,7 @@ struct mallinfo dlmallinfo(void) {
|
|
|
4452
4453
|
}
|
|
4453
4454
|
#endif /* NO_MALLINFO */
|
|
4454
4455
|
|
|
4455
|
-
void dlmalloc_stats() {
|
|
4456
|
+
void dlmalloc_stats(void) {
|
|
4456
4457
|
internal_malloc_stats(gm);
|
|
4457
4458
|
}
|
|
4458
4459
|
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
#include <ffi.h>
|
|
30
30
|
#include <ffi_common.h>
|
|
31
|
+
#include <tramp.h>
|
|
31
32
|
|
|
32
33
|
#include <stdlib.h>
|
|
33
34
|
#include <stdint.h>
|
|
@@ -58,7 +59,9 @@
|
|
|
58
59
|
*/
|
|
59
60
|
typedef struct call_context
|
|
60
61
|
{
|
|
62
|
+
#if !defined(__loongarch_soft_float)
|
|
61
63
|
ABI_FLOAT fa[8];
|
|
64
|
+
#endif
|
|
62
65
|
size_t a[10];
|
|
63
66
|
} call_context;
|
|
64
67
|
|
|
@@ -647,9 +647,9 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
|
647
647
|
|
|
648
648
|
case FFI_TYPE_POINTER:
|
|
649
649
|
if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
|
|
650
|
-
cif->flags +=
|
|
650
|
+
cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
|
|
651
651
|
else
|
|
652
|
-
cif->flags +=
|
|
652
|
+
cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
|
|
653
653
|
break;
|
|
654
654
|
|
|
655
655
|
case FFI_TYPE_FLOAT:
|
|
@@ -661,7 +661,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
|
661
661
|
/* else fall through */
|
|
662
662
|
case FFI_TYPE_DOUBLE:
|
|
663
663
|
if (soft_float)
|
|
664
|
-
cif->flags +=
|
|
664
|
+
cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
|
|
665
665
|
else
|
|
666
666
|
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
|
|
667
667
|
break;
|
|
@@ -715,8 +715,16 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
|
715
715
|
}
|
|
716
716
|
break;
|
|
717
717
|
}
|
|
718
|
+
case FFI_TYPE_UINT32:
|
|
719
|
+
/* In the N32 or N64 ABI unsigned 32-bit integer should be
|
|
720
|
+
*sign*-extended. */
|
|
721
|
+
cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
|
|
722
|
+
break;
|
|
723
|
+
case FFI_TYPE_SINT64:
|
|
724
|
+
cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
|
|
725
|
+
break;
|
|
718
726
|
default:
|
|
719
|
-
cif->flags +=
|
|
727
|
+
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
|
|
720
728
|
break;
|
|
721
729
|
}
|
|
722
730
|
}
|
|
@@ -32,16 +32,14 @@
|
|
|
32
32
|
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
|
|
33
33
|
#endif
|
|
34
34
|
|
|
35
|
-
#ifdef
|
|
36
|
-
# include <asm/sgidefs.h>
|
|
37
|
-
#elif defined(__rtems__)
|
|
35
|
+
#ifdef __rtems__
|
|
38
36
|
/*
|
|
39
37
|
* Subprogram calling convention - copied from sgidefs.h
|
|
40
38
|
*/
|
|
41
39
|
#define _MIPS_SIM_ABI32 1
|
|
42
40
|
#define _MIPS_SIM_NABI32 2
|
|
43
41
|
#define _MIPS_SIM_ABI64 3
|
|
44
|
-
#elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
|
|
42
|
+
#elif !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__linux__)
|
|
45
43
|
# include <sgidefs.h>
|
|
46
44
|
#endif
|
|
47
45
|
|
|
@@ -236,19 +236,54 @@ callit:
|
|
|
236
236
|
# Shift the return type flag over
|
|
237
237
|
SRL t6, 8*FFI_FLAG_BITS
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
bne t6, FFI_TYPE_UINT64, retsint32
|
|
240
|
+
|
|
241
|
+
retuint64:
|
|
242
242
|
jal t9
|
|
243
243
|
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
|
|
244
|
-
|
|
244
|
+
sd v0, 0(t4)
|
|
245
245
|
b epilogue
|
|
246
246
|
|
|
247
|
-
|
|
248
|
-
bne
|
|
247
|
+
retsint32:
|
|
248
|
+
bne t6, FFI_TYPE_SINT32, retuint16
|
|
249
249
|
jal t9
|
|
250
250
|
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
|
|
251
|
-
|
|
251
|
+
sll v0, v0, 0
|
|
252
|
+
sd v0, 0(t4)
|
|
253
|
+
b epilogue
|
|
254
|
+
|
|
255
|
+
retuint16:
|
|
256
|
+
bne t6, FFI_TYPE_UINT16, retsint16
|
|
257
|
+
jal t9
|
|
258
|
+
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
|
|
259
|
+
andi v0, v0, 0xffff
|
|
260
|
+
sd v0, 0(t4)
|
|
261
|
+
b epilogue
|
|
262
|
+
|
|
263
|
+
retsint16:
|
|
264
|
+
bne t6, FFI_TYPE_SINT16, retuint8
|
|
265
|
+
jal t9
|
|
266
|
+
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
|
|
267
|
+
dsll v0, v0, 48
|
|
268
|
+
dsra v0, v0, 48
|
|
269
|
+
sd v0, 0(t4)
|
|
270
|
+
b epilogue
|
|
271
|
+
|
|
272
|
+
retuint8:
|
|
273
|
+
bne t6, FFI_TYPE_UINT8, retsint8
|
|
274
|
+
jal t9
|
|
275
|
+
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
|
|
276
|
+
andi v0, v0, 0xff
|
|
277
|
+
sd v0, 0(t4)
|
|
278
|
+
b epilogue
|
|
279
|
+
|
|
280
|
+
retsint8:
|
|
281
|
+
bne t6, FFI_TYPE_SINT8, retfloat
|
|
282
|
+
jal t9
|
|
283
|
+
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
|
|
284
|
+
sd v0, 0(t4)
|
|
285
|
+
dsll v0, v0, 56
|
|
286
|
+
dsra v0, v0, 56
|
|
252
287
|
b epilogue
|
|
253
288
|
|
|
254
289
|
retfloat:
|
|
@@ -585,19 +620,35 @@ $do_closure:
|
|
|
585
620
|
|
|
586
621
|
jalr t9
|
|
587
622
|
|
|
623
|
+
cls_retuint64:
|
|
588
624
|
# Return flags are in v0
|
|
589
|
-
bne v0,
|
|
625
|
+
bne v0, FFI_TYPE_UINT64, cls_retsint32
|
|
626
|
+
ld v0, V0_OFF2($sp)
|
|
627
|
+
b cls_epilogue
|
|
628
|
+
|
|
629
|
+
cls_retsint32:
|
|
630
|
+
bne v0, FFI_TYPE_SINT32, cls_retsint16
|
|
590
631
|
lw v0, V0_OFF2($sp)
|
|
591
632
|
b cls_epilogue
|
|
592
633
|
|
|
593
|
-
|
|
594
|
-
bne v0,
|
|
595
|
-
|
|
634
|
+
cls_retsint16:
|
|
635
|
+
bne v0, FFI_TYPE_SINT16, cls_retuint16
|
|
636
|
+
lh v0, V0_OFF2($sp)
|
|
596
637
|
b cls_epilogue
|
|
597
638
|
|
|
598
|
-
|
|
599
|
-
bne v0,
|
|
600
|
-
|
|
639
|
+
cls_retuint16:
|
|
640
|
+
bne v0, FFI_TYPE_UINT16, cls_retsint8
|
|
641
|
+
lhu v0, V0_OFF2($sp)
|
|
642
|
+
b cls_epilogue
|
|
643
|
+
|
|
644
|
+
cls_retsint8:
|
|
645
|
+
bne v0, FFI_TYPE_SINT8, cls_retuint8
|
|
646
|
+
lb v0, V0_OFF2($sp)
|
|
647
|
+
b cls_epilogue
|
|
648
|
+
|
|
649
|
+
cls_retuint8:
|
|
650
|
+
bne v0, FFI_TYPE_UINT8, cls_retfloat
|
|
651
|
+
lbu v0, V0_OFF2($sp)
|
|
601
652
|
b cls_epilogue
|
|
602
653
|
|
|
603
654
|
cls_retfloat:
|
|
@@ -770,3 +821,7 @@ cls_epilogue:
|
|
|
770
821
|
#endif /* __GNUC__ */
|
|
771
822
|
|
|
772
823
|
#endif
|
|
824
|
+
|
|
825
|
+
#if defined __ELF__ && defined __linux__
|
|
826
|
+
.section .note.GNU-stack,"",%progbits
|
|
827
|
+
#endif
|
|
@@ -110,7 +110,7 @@ void* ffi_prep_args(char *stack, extended_cif *ecif)
|
|
|
110
110
|
|
|
111
111
|
extern void ffi_call_SYSV(unsigned,
|
|
112
112
|
extended_cif *,
|
|
113
|
-
void *(*)(
|
|
113
|
+
void *(*)(char *, extended_cif *),
|
|
114
114
|
unsigned *,
|
|
115
115
|
void (*fn)(void),
|
|
116
116
|
unsigned);
|
|
@@ -180,7 +180,7 @@ void ffi_closure_SYSV(unsigned long r3, unsigned long r4, unsigned long r5,
|
|
|
180
180
|
register int *r13 __asm__ ("r13");
|
|
181
181
|
|
|
182
182
|
ffi_closure* closure = (ffi_closure*) r13;
|
|
183
|
-
char *stack_args = sp;
|
|
183
|
+
char *stack_args = (char*) sp;
|
|
184
184
|
|
|
185
185
|
/* Lay the register arguments down in a continuous chunk of memory. */
|
|
186
186
|
unsigned register_args[6] =
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
#include "ffi.h"
|
|
32
32
|
#include "ffi_common.h"
|
|
33
33
|
#include "ffi_powerpc.h"
|
|
34
|
+
#include "internal.h"
|
|
35
|
+
#include <tramp.h>
|
|
34
36
|
|
|
35
37
|
#if HAVE_LONG_DOUBLE_VARIANT
|
|
36
38
|
/* Adjust ffi_type_longdouble. */
|
|
@@ -173,3 +175,14 @@ ffi_prep_go_closure (ffi_go_closure *closure,
|
|
|
173
175
|
closure->fun = fun;
|
|
174
176
|
return FFI_OK;
|
|
175
177
|
}
|
|
178
|
+
|
|
179
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
180
|
+
void *
|
|
181
|
+
ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
|
|
182
|
+
{
|
|
183
|
+
extern void *trampoline_code_table;
|
|
184
|
+
*tramp_size = PPC_TRAMP_SIZE;
|
|
185
|
+
*map_size = PPC_TRAMP_MAP_SIZE;
|
|
186
|
+
return &trampoline_code_table;
|
|
187
|
+
}
|
|
188
|
+
#endif
|
|
@@ -623,38 +623,50 @@ darwin_adjust_aggregate_sizes (ffi_type *s)
|
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
/* Adjust the size of S to be correct for AIX.
|
|
626
|
-
Word-align double unless it is the first member of a structure.
|
|
626
|
+
Word-align double unless it is the first member of a structure recursively.
|
|
627
|
+
Return non-zero if we found a recursive first member aggregate of interest. */
|
|
627
628
|
|
|
628
|
-
static
|
|
629
|
-
aix_adjust_aggregate_sizes (ffi_type *s)
|
|
629
|
+
static int
|
|
630
|
+
aix_adjust_aggregate_sizes (ffi_type *s, int outer_most_type_or_first_member)
|
|
630
631
|
{
|
|
631
|
-
int i;
|
|
632
|
+
int i, nested_first_member=0, final_align, rc=0;
|
|
632
633
|
|
|
633
634
|
if (s->type != FFI_TYPE_STRUCT)
|
|
634
|
-
return;
|
|
635
|
+
return 0;
|
|
635
636
|
|
|
636
637
|
s->size = 0;
|
|
637
638
|
for (i = 0; s->elements[i] != NULL; i++)
|
|
638
639
|
{
|
|
639
|
-
ffi_type
|
|
640
|
+
ffi_type p;
|
|
640
641
|
int align;
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
642
|
+
|
|
643
|
+
/* nested aggregates layout differently on AIX, so take a copy of the type */
|
|
644
|
+
p = *(s->elements[i]);
|
|
645
|
+
if (i == 0)
|
|
646
|
+
nested_first_member = aix_adjust_aggregate_sizes(&p, outer_most_type_or_first_member);
|
|
647
|
+
else
|
|
648
|
+
aix_adjust_aggregate_sizes(&p, 0);
|
|
649
|
+
align = p.alignment;
|
|
650
|
+
if (i != 0 && p.type == FFI_TYPE_DOUBLE)
|
|
651
|
+
align = 4;
|
|
652
|
+
s->size = FFI_ALIGN(s->size, align) + p.size;
|
|
648
653
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
654
|
+
|
|
655
|
+
final_align=s->alignment;
|
|
656
|
+
if ((s->elements[0]->type == FFI_TYPE_UINT64
|
|
657
|
+
|| s->elements[0]->type == FFI_TYPE_SINT64
|
|
658
|
+
|| s->elements[0]->type == FFI_TYPE_DOUBLE
|
|
659
|
+
|| s->elements[0]->alignment == 8 || nested_first_member)) {
|
|
660
|
+
final_align = s->alignment > 8 ? s->alignment : 8;
|
|
661
|
+
rc=1;
|
|
662
|
+
/* still use the adjusted alignment to calculate tail padding, but don't adjust the types alignment if
|
|
663
|
+
we aren't in the recursive first position */
|
|
664
|
+
if (outer_most_type_or_first_member)
|
|
665
|
+
s->alignment=final_align;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
s->size = FFI_ALIGN(s->size, final_align);
|
|
669
|
+
return rc;
|
|
658
670
|
}
|
|
659
671
|
|
|
660
672
|
/* Perform machine dependent cif processing. */
|
|
@@ -682,9 +694,9 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
|
682
694
|
|
|
683
695
|
if (cif->abi == FFI_AIX)
|
|
684
696
|
{
|
|
685
|
-
aix_adjust_aggregate_sizes (cif->rtype);
|
|
697
|
+
aix_adjust_aggregate_sizes (cif->rtype, 1);
|
|
686
698
|
for (i = 0; i < cif->nargs; i++)
|
|
687
|
-
aix_adjust_aggregate_sizes (cif->arg_types[i]);
|
|
699
|
+
aix_adjust_aggregate_sizes (cif->arg_types[i], 1);
|
|
688
700
|
}
|
|
689
701
|
|
|
690
702
|
/* Space for the frame pointer, callee's LR, CR, etc, and for
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
----------------------------------------------------------------------- */
|
|
30
30
|
|
|
31
31
|
#include "ffi.h"
|
|
32
|
+
#include <tramp.h>
|
|
32
33
|
|
|
33
34
|
#ifdef POWERPC64
|
|
34
35
|
#include "ffi_common.h"
|
|
@@ -820,32 +821,38 @@ ffi_prep_closure_loc_linux64 (ffi_closure *closure,
|
|
|
820
821
|
void *user_data,
|
|
821
822
|
void *codeloc)
|
|
822
823
|
{
|
|
823
|
-
#if _CALL_ELF == 2
|
|
824
|
-
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
|
|
825
|
-
|
|
826
824
|
if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
|
|
827
825
|
return FFI_BAD_ABI;
|
|
828
826
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
827
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
828
|
+
if (ffi_tramp_is_present(closure))
|
|
829
|
+
{
|
|
830
|
+
/* Initialize the static trampoline's parameters. */
|
|
831
|
+
void (*dest)(void) = ffi_closure_LINUX64;
|
|
832
|
+
ffi_tramp_set_parms (closure->ftramp, dest, closure);
|
|
833
|
+
}
|
|
834
|
+
else
|
|
835
|
+
#endif
|
|
836
|
+
{
|
|
837
|
+
#if _CALL_ELF == 2
|
|
838
|
+
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
|
|
839
|
+
tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */
|
|
840
|
+
tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */
|
|
841
|
+
tramp[2] = 0x7d8903a6; /* mtctr 12 */
|
|
842
|
+
tramp[3] = 0x4e800420; /* bctr */
|
|
833
843
|
/* 1: .quad function_addr */
|
|
834
844
|
/* 2: .quad context */
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
845
|
+
*(void **) &tramp[4] = (void *) ffi_closure_LINUX64;
|
|
846
|
+
*(void **) &tramp[6] = codeloc;
|
|
847
|
+
flush_icache ((char *) tramp, (char *) codeloc, 4 * 4);
|
|
838
848
|
#else
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
/* Copy function address and TOC from ffi_closure_LINUX64 OPD. */
|
|
845
|
-
memcpy (&tramp[0], (void **) ffi_closure_LINUX64, sizeof (void *));
|
|
846
|
-
tramp[1] = codeloc;
|
|
847
|
-
memcpy (&tramp[2], (void **) ffi_closure_LINUX64 + 1, sizeof (void *));
|
|
849
|
+
/* Copy function address and TOC from ffi_closure_LINUX64 OPD. */
|
|
850
|
+
void **tramp = (void **) &closure->tramp[0];
|
|
851
|
+
memcpy (&tramp[0], (void **) ffi_closure_LINUX64, sizeof (void *));
|
|
852
|
+
tramp[1] = codeloc;
|
|
853
|
+
memcpy (&tramp[2], (void **) ffi_closure_LINUX64 + 1, sizeof (void *));
|
|
848
854
|
#endif
|
|
855
|
+
}
|
|
849
856
|
|
|
850
857
|
closure->cif = cif;
|
|
851
858
|
closure->fun = fun;
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
----------------------------------------------------------------------- */
|
|
30
30
|
|
|
31
31
|
#include "ffi.h"
|
|
32
|
+
#include <tramp.h>
|
|
32
33
|
|
|
33
34
|
#ifndef POWERPC64
|
|
34
35
|
#include "ffi_common.h"
|
|
@@ -636,25 +637,34 @@ ffi_prep_closure_loc_sysv (ffi_closure *closure,
|
|
|
636
637
|
void *user_data,
|
|
637
638
|
void *codeloc)
|
|
638
639
|
{
|
|
639
|
-
unsigned int *tramp;
|
|
640
|
-
|
|
641
640
|
if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI)
|
|
642
641
|
return FFI_BAD_ABI;
|
|
643
642
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
/*
|
|
657
|
-
|
|
643
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
644
|
+
if (ffi_tramp_is_present(closure))
|
|
645
|
+
{
|
|
646
|
+
/* Initialize the static trampoline's parameters. */
|
|
647
|
+
void (*dest)(void) = ffi_closure_SYSV;
|
|
648
|
+
ffi_tramp_set_parms (closure->ftramp, dest, closure);
|
|
649
|
+
}
|
|
650
|
+
else
|
|
651
|
+
#endif
|
|
652
|
+
{
|
|
653
|
+
unsigned int *tramp = (unsigned int *) &closure->tramp[0];
|
|
654
|
+
tramp[0] = 0x7c0802a6; /* mflr r0 */
|
|
655
|
+
tramp[1] = 0x429f0005; /* bcl 20,31,.+4 */
|
|
656
|
+
tramp[2] = 0x7d6802a6; /* mflr r11 */
|
|
657
|
+
tramp[3] = 0x7c0803a6; /* mtlr r0 */
|
|
658
|
+
tramp[4] = 0x800b0018; /* lwz r0,24(r11) */
|
|
659
|
+
tramp[5] = 0x816b001c; /* lwz r11,28(r11) */
|
|
660
|
+
tramp[6] = 0x7c0903a6; /* mtctr r0 */
|
|
661
|
+
tramp[7] = 0x4e800420; /* bctr */
|
|
662
|
+
*(void **) &tramp[8] = (void *) ffi_closure_SYSV; /* function */
|
|
663
|
+
*(void **) &tramp[9] = codeloc; /* context */
|
|
664
|
+
|
|
665
|
+
/* Flush the icache. */
|
|
666
|
+
flush_icache ((char *)tramp, (char *)codeloc, 8 * 4);
|
|
667
|
+
}
|
|
658
668
|
|
|
659
669
|
closure->cif = cif;
|
|
660
670
|
closure->fun = fun;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
2
|
+
/* For the trampoline code table mapping, a mapping size of 64K is chosen. */
|
|
3
|
+
#define PPC_TRAMP_MAP_SHIFT 16
|
|
4
|
+
#define PPC_TRAMP_MAP_SIZE (1 << PPC_TRAMP_MAP_SHIFT)
|
|
5
|
+
# ifdef __PCREL__
|
|
6
|
+
# define PPC_TRAMP_SIZE 24
|
|
7
|
+
# else
|
|
8
|
+
# define PPC_TRAMP_SIZE 40
|
|
9
|
+
# endif /* __PCREL__ */
|
|
10
|
+
#endif /* FFI_EXEC_STATIC_TRAMP */
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
#define LIBFFI_ASM
|
|
28
28
|
#include <fficonfig.h>
|
|
29
29
|
#include <ffi.h>
|
|
30
|
+
#include "internal.h"
|
|
30
31
|
|
|
31
32
|
.file "linux64_closure.S"
|
|
32
33
|
|
|
@@ -559,7 +560,53 @@ ffi_go_closure_linux64:
|
|
|
559
560
|
.size .ffi_go_closure_linux64,.-.ffi_go_closure_linux64
|
|
560
561
|
# endif
|
|
561
562
|
# endif
|
|
563
|
+
|
|
564
|
+
#ifdef FFI_EXEC_STATIC_TRAMP
|
|
565
|
+
.text
|
|
566
|
+
.align PPC_TRAMP_MAP_SHIFT
|
|
567
|
+
FFI_HIDDEN (trampoline_code_table)
|
|
568
|
+
.globl trampoline_code_table
|
|
569
|
+
# if _CALL_ELF == 2
|
|
570
|
+
.type trampoline_code_table,@function
|
|
571
|
+
trampoline_code_table:
|
|
572
|
+
.localentry trampoline_code_table,.-trampoline_code_table
|
|
573
|
+
# else
|
|
574
|
+
.section ".opd","aw"
|
|
575
|
+
.align 3
|
|
576
|
+
trampoline_code_table:
|
|
577
|
+
.quad .L.trampoline_code_table,.TOC.@tocbase,0
|
|
578
|
+
.type trampoline_code_table,@function
|
|
579
|
+
.text
|
|
580
|
+
.L.trampoline_code_table:
|
|
581
|
+
# endif
|
|
582
|
+
.rept PPC_TRAMP_MAP_SIZE / PPC_TRAMP_SIZE
|
|
583
|
+
#ifdef __PCREL__
|
|
584
|
+
pla %r2,PPC_TRAMP_MAP_SIZE
|
|
585
|
+
ld %r11,0(%r2)
|
|
586
|
+
ld %r12,8(%r2)
|
|
587
|
+
mtctr %r12
|
|
588
|
+
bctr
|
|
589
|
+
#else
|
|
590
|
+
mflr %r0
|
|
591
|
+
bcl 20,31,$+4
|
|
592
|
+
mflr %r11
|
|
593
|
+
addis %r11,%r11,PPC_TRAMP_MAP_SIZE@ha
|
|
594
|
+
mtlr %r0
|
|
595
|
+
ld %r12,(PPC_TRAMP_MAP_SIZE+0)@l(%r11)
|
|
596
|
+
mtctr %r12
|
|
597
|
+
ld %r11,(PPC_TRAMP_MAP_SIZE-8)@l(%r11)
|
|
598
|
+
bctr
|
|
599
|
+
nop
|
|
600
|
+
#endif
|
|
601
|
+
.endr
|
|
602
|
+
.align PPC_TRAMP_MAP_SHIFT
|
|
603
|
+
#if _CALL_ELF == 2
|
|
604
|
+
.size trampoline_code_table,.-trampoline_code_table
|
|
605
|
+
#else
|
|
606
|
+
.size trampoline_code_table,.-.L.trampoline_code_table
|
|
562
607
|
#endif
|
|
608
|
+
#endif /* FFI_EXEC_STATIC_TRAMP */
|
|
609
|
+
#endif /* POWERPC64 */
|
|
563
610
|
|
|
564
611
|
#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
|
|
565
612
|
.section .note.GNU-stack,"",@progbits
|