|
cb01c208
|
2023-12-11T12:15:19
|
|
x86 c99
|
|
04688867
|
2023-08-04T19:59:39
|
|
tramp
|
|
f1d10cab
|
2023-08-04T13:56:10
|
|
ffi64.c
|
|
c43eae24
|
2023-03-06T16:08:49
|
|
fix compatibility with C99
|
|
e70dd1aa
|
2023-02-02T11:44:13
|
|
libffi: Fix X86 32b Darwin build and EH frames. (#757)
This addresses a number of issues in the X86 Darwin 32b port for libffi.
1. The pic symbol stubs are weak definitions; the correct section placement
for these depends on the linker version in use. We do not have access
to that information, but we can use the target OS version (assumes that
the user has installed the latest version of xcode available).
When a coalesced section is in use (OS versions earlier than Darwin12 /
OSX 10.8), its name must differ from __TEXT,__text since otherwise that
would correspond to altering the attributes of the .text section (which
produces a diagnostic from the assembler).
Here we use __TEXT, __textcoal_nt for this which is what GCC emits for
these stubs.
For later versions than Darwin 12 (OS X 10.8) we can place the stubs in
the .text section (if we do not we get a diagnostic from clang -cc1as
saying that the use of coalesced sections for this is deprecated).
2. The EH frame is specified manually, since there is no support for .cfi_
directives in 'cctools' assemblers. The implementation needs to provide
offsets for CFA advance, code size and to the CIE as signed values
rather than relocations. However the cctools assembler will produce a
relocation for expressions like ' .long Lxx-Lyy' which then leads to a
link-time error. We correct this by forming the offset values using
' .set' directives and then assigning the results of them.
3. The register numbering used by m32 X86 Darwin EH frames is not the same
as the DWARF debug numbering (the Frame and Stack pointer numbers are
swapped).
4. The FDE address encoding used by the system tools is '0x10' (PCrel + abs)
where the value provided was PCrel + sdata4.
5. GCC does not use compact unwind at present, and it was not implemented
until Darwin10 / OSX 10.6. There were some issues with function location
in 10.6 so that the solution here suppresses emitting the compact unwind
section until Darwin11 / OSX 10.7.
|
|
963c4a96
|
2022-09-27T22:05:42
|
|
Remove nested comments
|
|
4c2984c4
|
2022-09-18T15:06:57
|
|
Handle win32 ABIs for struct return
|
|
b05dc51b
|
2022-09-18T13:03:10
|
|
Debug x86
|
|
cafdb837
|
2022-09-18T12:05:12
|
|
Revert
|
|
735e7be4
|
2022-09-18T08:21:34
|
|
X86 is never defined.
|
|
ee22ecbd
|
2022-09-18T01:56:25
|
|
Add MSYS configuration files (#728)
* Add MSYS configuration files
MSYS behaves very similiar to Cygwin, e.g. also __CYGWIN__ is defined.
Now 'make check' passes on MSYS without extra patches.
* Fix warning extra tokens at end of #endif in closures.c
Extra tokens converted into a comment. Also nearby indentations corrected.
* Fix missing prototype warning mkostemp() on Cygwin
Cygwin requires also _GNU_SOURCE to be defined to enable mkostemp() prototype.
* Fix warning label ‘out’ defined but not used in ffi functions
Define same preprocessor conditions for goto and label visibility.
* Fix warning label ‘out’ defined but not used and related indentations.
Define same preprocessor conditions for goto and label visibility. Correct also
related indentations.
Co-authored-by: Hannes Müller <>
|
|
05785caf
|
2022-09-15T15:18:09
|
|
Fix arg alignment for STDCALL
|
|
0eb91425
|
2022-08-31T20:46:24
|
|
Change comment style
|
|
c528d5b4
|
2022-05-29T11:22:38
|
|
Fix windows arg passing
|
|
aa2c4141
|
2022-05-29T10:28:10
|
|
64-bit cygwin: fix struct args. Document change.
|
|
769b7366
|
2022-05-28T19:59:35
|
|
Fix for MS x64 ABI
|
|
e409225b
|
2022-05-28T09:42:13
|
|
Pass large structs by value for Linux x86_64 and Aarch64.
Aarch patch by Andreas Schwab. https://github.com/libffi/libffi/commit/482b37f00467325e3389bab322525099860dd9aa
|
|
3ac265d5
|
2022-05-15T18:43:56
|
|
x86-64: Always double jump table slot size for CET (#710) (#711)
When CET is enabled, double jump table slot size to add 4 bytes of ENDBR64
for CET. Since CET enabled clang doesn't have the LLVM assembler bug:
https://bugs.llvm.org/show_bug.cgi?id=21501
fixed by
commit 04d39260d64e08b8bfb3844109ad43d4055b2e8d
Author: Rafael Espindola <rafael.espindola@gmail.com>
Date: Wed Nov 4 23:50:29 2015 +0000
Simplify .org processing and make it a bit more powerful.
we can use .org to allocate jump table slot size to 16 bytes.
|
|
b60d4fc7
|
2021-12-23T14:32:46
|
|
src/x86/win64.S: Use #define instead of .macro (#665) (#669)
The Solaris/x86 assembler doesn't support .macro/.endm, so use #define since
win64.S is passed through cpp anyway.
|
|
07f826fd
|
2021-07-25T02:39:37
|
|
Fix trampoline_code_table for x32. (#657)
x32's struct tramp_parm has 32-bit pointers. This change adjusts the
loads and offsets accordingly.
|
|
5651bea2
|
2021-06-15T15:19:26
|
|
2021-06-15 Jakub Jelinek <jakub@redhat.com>
* src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words
to number of words needed for type->size + byte_offset bytes rather
than just type->size bytes. Compute pos before the loop and check
total size of the structure.
* testsuite/libffi.call/nested_struct12.c: New test.
|
|
1aeb2671
|
2021-03-24T12:16:12
|
|
x86: Fix thiscall and fastcall stack cleanup behavior (#611)
These are meant to use callee clean-up.
|
|
f88add14
|
2021-03-24T12:04:51
|
|
x86: Fix MSVC runtime checks interop (#612)
MSVC can add runtime code that checks if a stack frame is mismanaged,
however our custom assembly deliberately accesses and modifies the parent
stack frame. Fortunately we can disable that specific check for the
function call so do that.
Co-authored-by: Matthew Waters <matthew@centricular.com>
|
|
9ba55921
|
2021-03-05T10:07:30
|
|
Static tramp v5 (#624)
* Static Trampolines
Closure Trampoline Security Issue
=================================
Currently, the trampoline code used in libffi is not statically defined in
a source file (except for MACH). The trampoline is either pre-defined
machine code in a data buffer. Or, it is generated at runtime. In order to
execute a trampoline, it needs to be placed in a page with executable
permissions.
Executable data pages are attack surfaces for attackers who may try to
inject their own code into the page and contrive to have it executed. The
security settings in a system may prevent various tricks used in user land
to write code into a page and to have it executed somehow. On such systems,
libffi trampolines would not be able to run.
Static Trampoline
=================
To solve this problem, the trampoline code needs to be defined statically
in a source file, compiled and placed in the text segment so it can be
mapped and executed naturally without any tricks. However, the trampoline
needs to be able to access the closure pointer at runtime.
PC-relative data referencing
============================
The solution implemented in this patch set uses PC-relative data references.
The trampoline is mapped in a code page. Adjacent to the code page, a data
page is mapped that contains the parameters of the trampoline:
- the closure pointer
- pointer to the ABI handler to jump to
The trampoline code uses an offset relative to its current PC to access its
data.
Some architectures support PC-relative data references in the ISA itself.
E.g., X64 supports RIP-relative references. For others, the PC has to
somehow be loaded into a general purpose register to do PC-relative data
referencing. To do this, we need to define a get_pc() kind of function and
call it to load the PC in a desired register.
There are two cases:
1. The call instruction pushes the return address on the stack.
In this case, get_pc() will extract the return address from the stack
and load it in the desired register and return.
2. The call instruction stores the return address in a designated register.
In this case, get_pc() will copy the return address to the desired
register and return.
Either way, the PC next to the call instruction is obtained.
Scratch register
================
In order to do its job, the trampoline code would need to use a scratch
register. Depending on the ABI, there may not be a register available for
scratch. This problem needs to be solved so that all ABIs will work.
The trampoline will save two values on the stack:
- the closure pointer
- the original value of the scratch register
This is what the stack will look like:
sp before trampoline ------> --------------------
| closure pointer |
--------------------
| scratch register |
sp after trampoline -------> --------------------
The ABI handler can do the following as needed by the ABI:
- the closure pointer can be loaded in a desired register
- the scratch register can be restored to its original value
- the stack pointer can be restored to its original value
(the value when the trampoline was invoked)
To do this, I have defined prolog code for each ABI handler. The legacy
trampoline jumps to the ABI handler directly. But the static trampoline
defined in this patch jumps tp the prolog code which performs the above
actions before jumping to the ABI handler.
Trampoline Table
================
In order to reduce the trampoline memory footprint, the trampoline code
would be defined as a code array in the text segment. This array would be
mapped into the address space of the caller. The mapping would, therefore,
contain a trampoline table.
Adjacent to the trampoline table mapping, there will be a data mapping that
contains a parameter table, one parameter block for each trampoline. The
parameter block will contain:
- a pointer to the closure
- a pointer to the ABI handler
The static trampoline code would finally look like this:
- Make space on the stack for the closure and the scratch register
by moving the stack pointer down
- Store the original value of the scratch register on the stack
- Using PC-relative reference, get the closure pointer
- Store the closure pointer on the stack
- Using PC-relative reference, get the ABI handler pointer
- Jump to the ABI handler
Mapping size
============
The size of the code mapping that contains the trampoline table needs to be
determined on a per architecture basis. If a particular architecture
supports multiple base page sizes, then the largest supported base page size
needs to be chosen. E.g., we choose 16K for ARM64.
Trampoline allocation and free
==============================
Static trampolines are allocated in ffi_closure_alloc() and freed in
ffi_closure_free().
Normally, applications use these functions. But there are some cases out
there where the user of libffi allocates and manages its own closure
memory. In such cases, static trampolines cannot be used. These will
fall back to using legacy trampolines. The user has to make sure that
the memory is executable.
ffi_closure structure
=====================
I did not want to make any changes to the size of the closure structure for
this feature to guarantee compatibility. But the opaque static trampoline
handle needs to be stored in the closure. I have defined it as follows:
- char tramp[FFI_TRAMPOLINE_SIZE];
+ union {
+ char tramp[FFI_TRAMPOLINE_SIZE];
+ void *ftramp;
+ };
If static trampolines are used, then tramp[] is not needed to store a
dynamic trampoline. That space can be reused to store the handle. Hence,
the union.
Architecture Support
====================
Support has been added for x64, i386, aarch64 and arm. Support for other
architectures can be added very easily in the future.
OS Support
==========
Support has been added for Linux. Support for other OSes can be added very
easily.
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
* x86: Support for Static Trampolines
- Define the arch-specific initialization function ffi_tramp_arch ()
that returns trampoline size information to common code.
- Define the trampoline code mapping and data mapping sizes.
- Define the trampoline code table statically. Define two tables,
actually, one with CET and one without.
- Introduce a tiny prolog for each ABI handling function. The ABI
handlers addressed are:
- ffi_closure_unix64
- ffi_closure_unix64_sse
- ffi_closure_win64
The prolog functions are called:
- ffi_closure_unix64_alt
- ffi_closure_unix64_sse_alt
- ffi_closure_win64_alt
The legacy trampoline jumps to the ABI handler. The static
trampoline jumps to the prolog function. The prolog function uses
the information provided by the static trampoline, sets things up
for the ABI handler and then jumps to the ABI handler.
- Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to
initialize static trampoline parameters.
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
* i386: Support for Static Trampolines
- Define the arch-specific initialization function ffi_tramp_arch ()
that returns trampoline size information to common code.
- Define the trampoline code table statically. Define two tables,
actually, one with CET and one without.
- Define the trampoline code table statically.
- Introduce a tiny prolog for each ABI handling function. The ABI
handlers addressed are:
- ffi_closure_i386
- ffi_closure_STDCALL
- ffi_closure_REGISTER
The prolog functions are called:
- ffi_closure_i386_alt
- ffi_closure_STDCALL_alt
- ffi_closure_REGISTER_alt
The legacy trampoline jumps to the ABI handler. The static
trampoline jumps to the prolog function. The prolog function uses
the information provided by the static trampoline, sets things up
for the ABI handler and then jumps to the ABI handler.
- Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to
initialize static trampoline parameters.
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
* arm64: Support for Static Trampolines
- Define the arch-specific initialization function ffi_tramp_arch ()
that returns trampoline size information to common code.
- Define the trampoline code mapping and data mapping sizes.
- Define the trampoline code table statically.
- Introduce a tiny prolog for each ABI handling function. The ABI
handlers addressed are:
- ffi_closure_SYSV
- ffi_closure_SYSV_V
The prolog functions are called:
- ffi_closure_SYSV_alt
- ffi_closure_SYSV_V_alt
The legacy trampoline jumps to the ABI handler. The static
trampoline jumps to the prolog function. The prolog function uses
the information provided by the static trampoline, sets things up
for the ABI handler and then jumps to the ABI handler.
- Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to
initialize static trampoline parameters.
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
* arm: Support for Static Trampolines
- Define the arch-specific initialization function ffi_tramp_arch ()
that returns trampoline size information to common code.
- Define the trampoline code mapping and data mapping sizes.
- Define the trampoline code table statically.
- Introduce a tiny prolog for each ABI handling function. The ABI
handlers addressed are:
- ffi_closure_SYSV
- ffi_closure_VFP
The prolog functions are called:
- ffi_closure_SYSV_alt
- ffi_closure_VFP_alt
The legacy trampoline jumps to the ABI handler. The static
trampoline jumps to the prolog function. The prolog function uses
the information provided by the static trampoline, sets things up
for the ABI handler and then jumps to the ABI handler.
- Call ffi_tramp_set_parms () in ffi_prep_closure_loc () to
initialize static trampoline parameters.
Signed-off-by: Madhavan T. Venkataraman <madvenka@linux.microsoft.com>
|
|
8cc8f446
|
2020-11-10T20:41:33
|
|
Allow to build with mingw-clang (#579)
For some reason, compiling sysv.S with mingw-clang fails with:
```
error: invalid variant 'ffi_closure_inner@8'
```
This can be fixed (worked around?) by quoting the symbol. This works
fine with mingw-gcc too.
|
|
d817d0da
|
2020-11-10T20:39:25
|
|
Don't use FFI_TYPE_LONGDOUBLE in the jump table in win64*.S (#580)
It may have the same value as FFI_TYPE_DOUBLE per ffi.h, which
possibly can make things go wrong with .org/ORG.
For instance, GCC complains about "Error: attempt to move .org
backwards"
|
|
032b3cd6
|
2020-10-27T07:06:21
|
|
Support building x86 and arm64 without FFI_GO_CLOSURES (#586)
* x86: Support building without FFI_GO_CLOSURES
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
* arm: Support building without FFI_GO_CLOSURES
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
|
|
c78fcf88
|
2020-10-27T07:02:36
|
|
Removing unnecessary instruction from ffi_call_unix64 (#588)
unix64.S's `ffi_call_unix64` looks like it used to take six parameters,
where the sixth said the number of SSE register arguments. However,
currently the function only takes five parameters, and the number of SSE
register arguments is encoded in the `struct register_args *` passed as
the first parameter to `ffi_call_unix64`. This change removes an
instruction that tries to use this missing sixth parameter as the number
of SSE arguments.
This fix should not change any behavior, nor fix any bugs, because a few
instructions later the value moved from %r9d into %eax is overwritten by
the correct value anyway. This change merely makes the code a tad less
confusing, because currently the assembly moves from a register (r9)
whose value is never set.
|
|
407394c0
|
2020-10-11T15:07:40
|
|
docs: fix simple typo, paramters -> parameters (#589)
There is a small typo in src/x86/ffi.c.
Should read `parameters` rather than `paramters`.
|
|
d9abffea
|
2020-02-22T06:32:22
|
|
x86: Fix ffi_prep_closure_loc (#542)
Since FFI_TRAMPOLINE_SIZE is increased by 4 bytes to add ENDBR32, adjust
jump displacement by 4 bytes.
|
|
78556561
|
2020-02-21T19:08:06
|
|
x86: Add indirect branch tracking support (#540)
Intel Control-flow Enforcement Technology (CET):
https://software.intel.com/en-us/articles/intel-sdm
contains shadow stack (SHSTK) and indirect branch tracking (IBT). When
CET is enabled, ELF object files must be marked with .note.gnu.property
section. When Intel CET is enabled, include <cet.h> in assembly codes
to mark Intel CET support.
Also when IBT is enabled, all indirect branch targets must start with
ENDBR instruction and notrack prefix can be used to disable IBT on
indirect branch. <cet.h> defines _CET_ENDBR which can be used in
assembly codes for ENDBR instruction. If <cet.h> isn't included,
define _CET_ENDBR as empty so that _CET_ENDBR can be used in assembly
codes.
Trampoline must be enlarged to add ENDBR instruction unconditionally,
which is NOP on non-CET processors. This is required regardless if
libffi is enabled with CET since libffi.so will be marked in legacy
bitmap, but trampoline won't. Update library version for larger
FFI_TRAMPOLINE_SIZE.
This fixed:
https://github.com/libffi/libffi/issues/474
Tested with
$ CC="gcc -Wl,-z,cet-report=error -fcf-protection" CXX="g++ -Wl,-z,cet-report=error -fcf-protection" .../configure
on Linux CET machines in i686, x32 and x86-64 modes.
|
|
a8efc2f7
|
2019-10-26T14:57:05
|
|
Fix FFI_STDCALL ABI (#514)
Even for a stdcall function, the stack alignment is still the
responsibility of the caller. Remember the original, not stack-aligned
argument size, but align when setting up a stack frame. In
ffi_closure_inner, return the true argument size, so that
ffi_[go_]closure_STDCALL doesn't adjust too much.
|
|
c4f61240
|
2019-10-09T18:59:32
|
|
Add long double test (#492)
Required to fix build error on macos with gcc-9
|
|
06bf1a9d
|
2019-04-28T03:21:44
|
|
fix x86/x64 MSVC build (#487)
|
|
05a17964
|
2019-02-19T04:11:28
|
|
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>
|
|
e1118af5
|
2019-02-19T03:58:25
|
|
changes for win32 on windows (#468)
|
|
ba73a671
|
2018-07-20T09:37:43
|
|
Update FFI_HIDDEN() to use .private_extern on Apple platforms and use the macro where appropriate
Fix issue #439
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
|
|
65da63ab
|
2018-06-25T04:38:58
|
|
Add compact unwind for darwin/i386 (#440)
* x86: Add implementation of compact unwind for ffi_call_i386, et al.
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
* x86: Use __text as the section name to avoid deprecated section name warnings.
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
* darwin: Add missing regular,debug attributes for compact unwind sections
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
|
|
2309b584
|
2018-06-17T17:04:24
|
|
Mark sysv.S as SafeSEH compatible (#438)
It contains no exception handler, so we can just emit the special
@feat.00 symbol to indicate that it's trivially SafeSEH compatible.
SafeSEH only applies to x86 and not x86-64, hence its inclusion in the
x86-specific block. See [1] for details.
[1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx#the_.sxdata_section_
|
|
1d704051
|
2018-06-17T17:01:50
|
|
i386: Fix missing break; in case statement leading to incorrectly returned FFI_BAD_ABI (#437)
* i386: Add missing break triggering dead store static analyzer checks.
Register calling sequence is being reported as bad ABI instead of working as intended.
Found-by: Clang Static Analysis
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
* Mark ffi arm sysv entry points as private_extern.
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
* x86_64: Add implementation of compact unwind for ffi_call_unix64.
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
|
|
b55baf0b
|
2018-05-09T13:21:02
|
|
Handle FFI_GNUW64 on non-Windows systems (EFI)
|
|
b5ee3957
|
2018-05-05T07:41:53
|
|
Revert "Remove some symbol exports and cleanup newline warnings (#433)"
This reverts commit a5a0f3cf36dfb4d64316414a872288c3170e6c1d.
|
|
a5a0f3cf
|
2018-05-05T03:44:33
|
|
Remove some symbol exports and cleanup newline warnings (#433)
* build: Ensure darwin generated sources end with a new line
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
* build: Use .private_extern where missing to prevent exporting symbols that are not API
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@macports.org>
|
|
d3c54cf3
|
2018-05-02T06:19:58
|
|
Re-enable msabi testing (#436)
* Revert "disable msabi testing for now"
This reverts commit 7b7638eb0eac2adfa72f7ec9f254ba287c9947e2.
* x86: Correct testing for 64-bit x86-64
Since passing -m32 to x86-64 compiler will generate i386 code, we
need to check both __ILP32__ and __i386__ for 64-bit x86-64.
* x86: Check __i386__ instead of i?86-*-* targets
Since passing -m32 to x86-64 compiler will generate i386 code, we need
to check __i386__ instead of i?86-*-* targets for i386 targets.
* i386: Properly passing integer parameters in registers
For thiscall and fastcall, if the paramter passed as 64-bit integer or
struct, all following integer paramters will be passed on stack.
* test: Add ABI_ATTR to callback_code
Add ABI_ATTR to callback_code to properly test different ABIs.
|
|
4c2206ac
|
2018-04-28T04:46:10
|
|
Fix two "return" issues in x86/ffi64.c (#431)
Issue #70 pointed out that at least one compiler didn't like:
return ffi_call_efi64(cif, fn, rvalue, avalue);
... where the return type is "void". This patch splits the statement
into two.
I also noticed that ffi_call_go here seems to do a double call. I
suspect a "return" is missing here, so this patch adds it as well.
|
|
369ef49f
|
2018-03-18T12:53:42
|
|
Add missing FFI_GNUW64 enum
|
|
43980dd1
|
2018-03-18T12:32:10
|
|
Add FFI_GNUW64 ABI for GNU 80-bit long double support
|
|
9bc40d87
|
2018-03-18T12:32:10
|
|
Add FFI_GWIN64 ABI for GNU 80-bit long double support
|
|
28d3b61b
|
2018-01-20T23:56:17
|
|
Fix x86 SysV closure in PIC mode
The assembly single-line comments swallowed up the remaining assembly
code of the macros due to lack of line-endings.
This is a regression introduced in b7f6d7a.
|
|
d15581c6
|
2017-12-01T00:34:30
|
|
Updating calls to ffi_closure_unix64_inner and ffi_closure_win64_inner to use PLT. Without this fix, statically linking libffi causes the linker error i.e. 'requires dynamic R_X86_64_PC32 reloc against ffi_closure_unix64_inner which may overflow at runtime; recompile with -fPIC)'
|
|
dc2ff5ba
|
2017-10-25T13:11:40
|
|
Merge pull request #323 from compnerd/x86-alloca-alignment
x86: align alloca to 16-byte boundary
|
|
927da716
|
2017-10-25T13:05:53
|
|
Merge pull request #379 from jlj/master
Xcode build improvements
|
|
9d9d92b4
|
2017-10-25T04:59:31
|
|
Skip WIN64/EFI64 support for x32
Since x32 doesn't support WIN64/EFI64, skip it if __ILP32__ is defined.
|
|
181fc4cc
|
2017-10-23T15:02:29
|
|
Merge branch 'master' based on ksjogo/libffi
Added a tvOS target in Xcode project. Misc Xcode project cleanup.
Fix macOS build target in Xcode project.
# Conflicts:
# src/aarch64/ffi.c
# src/x86/ffi64.c
|
|
79d1509c
|
2017-10-10T11:39:45
|
|
x86: align alloca to 16-byte boundary
Align the stack allocation to a 16-byte boundary. This ensures that the
stack parameters are 16-byte aligned which is needed for some
instructions.
|
|
a78da739
|
2017-09-04T15:55:34
|
|
Fix macOS build target in Xcode project.
- Add missing files for desktop platforms in generate-darwin-source-and-headers.py, and in the Xcode project.
- Add a static library target for macOS.
- Fix "implicit conversion loses integer precision" warnings for iOS mad macOS targets.
|
|
9c12209d
|
2017-08-03T10:46:28
|
|
Fix misaligned memory access in ffi_call_int
|
|
bd72848c
|
2017-04-27T13:20:36
|
|
Prefix ALIGN macros with FFI_
|
|
a94c999b
|
2017-03-19T07:36:07
|
|
Handle fastcall declaration differently for some Microsoft compilers
|
|
1e0d107b
|
2017-01-08T20:12:59
|
|
Modify configure.host to detect compilation with Microsoft Visual C++ and use assembly with Intel syntax in that case
|
|
794a54d4
|
2016-06-05T14:57:00
|
|
Mark win64.S with GNU-stack note
|
|
92810b4b
|
2016-05-26T08:56:51
|
|
[Darwin-x86, build] Fix up label prefixes, remove .purgem
Darwin uses a label prefix of _.
cctools assembler will not accept .purgem as a directive.
|
|
4a677a42
|
2016-03-05T09:58:38
|
|
Fix -Wsign-compare warnings in x86/ffi64.c
This was originally reported on the Python tracker:
httpa://bugs.python.org/issue23958
The original patch was written by Steve R. Hastings.
I've updated it to current master of libffi.
|
|
e5843a3a
|
2016-04-15T16:10:08
|
|
x86: Fix calling convention for ffi_closure_win64_inner
Also enable testing for the cross-abi calls.
|
|
d0675197
|
2016-03-07T12:14:22
|
|
x86: Copy fix for clang .org from unix64.S
Clang doesn't understand .org with symbolic operands.
|
|
1f6b5a91
|
2015-07-26T16:27:34
|
|
Support the WIN64/EFI64 calling convention on all X86_64 platforms
Add a new calling convention FFI_EFI64, alias FFI_WIN64, on all X86_64
platforms. This allows libffi compiled on a 64-bit x86 platform to call
EFI functions.
Compile in ffiw64.c and win64.S on all X86_64 platforms. When compiled
for a platform other than X86_WIN64, ffiw64.c suffixes its functions
with _efi64, to avoid conflict with the platform's actual
implementations of those functions.
|
|
6de51f3e
|
2015-07-26T16:23:55
|
|
src/x86/ffiw64.c: Don't assign a "char *" to an "unsigned char *"
Declare a local variable to match the type of the struct field assigned
to it, rather than adding unsigned to the type. Fixes a -Wpointer-sign
warning.
|
|
eaa59755
|
2015-07-26T17:17:16
|
|
src/x86/win64.S: Handle name mangling and PIC
Move the macros from unix64.S into a shared header asmnames.h and use
them in win64.S too.
|
|
c8e82d9f
|
2015-07-26T16:18:57
|
|
src/x86/win64.S: Support compiling on non-WIN64 platforms
Non-WIN64 versions of the GNU assembler don't support the .seh_*
directives for structured exception handling, so wrap them in a macro
that compiles to nothing.
Handle the registers used for the non-Windows x86-64 calling convention
when on a non-Windows platform. Distinguish between cases that should
refer to the native argument registers (defined as arg0, arg1, arg2, and
arg3) and cases that should always refer to the Windows argument
registers.
|
|
3ac1610a
|
2015-01-19T20:48:40
|
|
x86: Fix cygwin32 build
The section syntax is just that little bit different.
|
|
f1560b7b
|
2015-01-16T11:31:37
|
|
x86: Solaris fixes
* Solaris/x86 /bin/as doesn't support .org, so I've just disabled the
uses in src/x86/{sysv, unix64}.S, as on Darwin.
* Solaris/x86 needs to use EH_FRAME_FLAGS so manually and compiler
generated .eh_frame sections match, otherwise libffi.so fails to link:
* Solaris/x86 /bin/as has different COMDAT syntax; I've disabled it for
the moment.
|
|
f27c4e46
|
2015-01-13T07:22:07
|
|
x86: Fix thinko in ffi_raw_call
Missed structure initialization for raw path.
Apparently there are no tests for this outside gcc.
|
|
1c61e73a
|
2015-01-10T09:23:30
|
|
Merge pull request #165 from rth7680/pcc
Support PCC as producer and consumer
|
|
dd0b59a5
|
2015-01-10T09:22:55
|
|
Merge pull request #164 from rth7680/darwin
Fix build on darwin
|
|
9131039c
|
2015-01-10T09:22:42
|
|
Merge pull request #160 from nobu/msvc-no-complex
x86: MSVC does not support Complex type
|
|
3fa5d70c
|
2015-01-05T13:03:06
|
|
x86: Avoid fastcall when building with pcc
Apparently, PCC doesn't support the fastcall calling convention.
Nor does it issue a warning or error for the attribute that it
does not understand.
|
|
a03d2310
|
2014-12-24T16:03:34
|
|
x86: Load structure return address into eax
|
|
b7f6d7aa
|
2014-12-10T13:37:36
|
|
x86: Reinstate hand-written unwind info for sysv.S
|
|
6cedf81c
|
2014-12-10T09:43:58
|
|
x86: Expand FFI_GO_CLOSURE
If we're going to have to hand-write unwind info for darwin,
these macros make the job harder.
|
|
ae842a51
|
2014-11-25T11:43:40
|
|
x86: More Darwin unwind fixups
EHFrame{N} IIRC is a special cue to ld64 that it should treat the unwind
in the object as "special/legacy" .. [these days everything is .cfi_xxxx
(except, cctools-as, as you noted)] .. without that much confusion arises
with ld64's atom-isation of the eh_frame section.
xxxx.eh labels are not needed for darwin ld64 >= 85.2.1 (i.e. darwin9,
xcode 3.1.4) to all intents and purposes, that's all that matters now,
since I think that anyone trying to build on 10.4/darwin8/xcode2.5 would
have to use a later ld64 (from odcctools) for other reasons.
|
|
0172bc02
|
2014-11-24T10:42:02
|
|
x86: Disable .org for Darwin
|
|
8fa3c9f2
|
2014-11-25T09:27:54
|
|
x86: Reinstate hand-written unwind info for unix64.S
One more try to get default Darwin to work.
|
|
5f35e0ff
|
2014-11-24T16:26:50
|
|
x86: Avoid using gas local labels
Which are unsupported by Darwin cctools as.
Thankfully this doesn't uglify the source too much.
|
|
ed1ca277
|
2014-11-24T13:02:03
|
|
x86: Remove use of .cfi_escape
The unwind info isn't 100% correct at all points during the epilogue,
and not annotating is just as incorrect as the annotation. This works
better on systems that do not support DW_OP_call_frame_cfa.
|
|
1b12593d
|
2014-11-24T12:55:43
|
|
x86: Honor alignment of arguments
Darwin aligns long-double to 16, and thus all of the long double
tests were failing due to not honoring that. We ought to be able
to devise a test case for GCC using __attribute__((aligned)) that
would have failed too.
|
|
042b8daf
|
2014-11-24T11:24:02
|
|
x86: Use .balign not .align
The Apple assembler defaults to power of two alignment, rather than
byte alignment like everyone else. Force byte alignment by using
the proper directive.
|
|
9f112619
|
2014-11-22T20:02:43
|
|
x86: Best guess at update for Darwin
|
|
7282d328
|
2014-12-22T17:14:40
|
|
x86: MSVC does not support Complex type
|
|
5f8881a5
|
2014-12-22T17:08:08
|
|
x86: Fix void pointer arithmetic
|
|
2f652469
|
2014-12-11T14:16:00
|
|
x86: Handle void arguments as if an empty structure
Since libffi currently doesn't allow empty structures, libgo
currently maps them to ffi_type_void. Given that we'll abort
on this case, handle it gracefully.
|
|
097ccfd6
|
2014-12-10T13:25:14
|
|
x86: Fix some unwind errors
|
|
dea49e20
|
2014-11-14T13:05:14
|
|
x86: Fix typo in ffi_prep_go_closure
Used the wrong register for THISCALL and FASTCALL.
|
|
0e303c06
|
2014-11-12T03:58:58
|
|
x86: Work around clang bugs
http://llvm.org/bugs/show_bug.cgi?21500
http://llvm.org/bugs/show_bug.cgi?21501
http://llvm.org/bugs/show_bug.cgi?21515
|
|
198f469e
|
2014-11-05T16:34:41
|
|
x86: Add support for Complex
|
|
2650f47f
|
2014-11-06T10:57:04
|
|
x86: Use win32 name mangling for fastcall functions
|
|
f8c64e24
|
2014-11-05T17:04:29
|
|
x86: Add support for Go closures
|
|
b21ec1ce
|
2014-11-05T10:15:25
|
|
x86: Rewrite closures
Move everything into sysv.S, removing win32.S and freebsd.S.
Handle all abis with a single ffi_closure_inner function.
Move complexity of the raw THISCALL trampoline into assembly
instead of the trampoline itself.
Only push the context for the REGISTER abi; let the rest
receive it in a register.
|
|
ebd82769
|
2014-10-23T23:57:06
|
|
win64: Remove support from ffi.c
|
|
e7b0056d
|
2014-10-30T13:57:39
|
|
x86: Force FFI_TYPE_LONGDOUBLE different from FFI_TYPE_DOUBLE
There are few abis that set double = long double. Eliminate the
conditional compilation and let this code simply be unused there.
|
|
b9ac94f3
|
2014-11-01T15:10:34
|
|
x86: Rewrite ffi_call
Decouple the assembly from FFI_TYPE_*. Merge prep_args with ffi_call,
passing the frame and the stack to the assembly.
Note that this patch isn't really standalone, as this breaks closures.
|