Commit Graph

122 Commits

Author SHA1 Message Date
Anthony Green
a94c999ba0 Handle fastcall declaration differently for some Microsoft compilers 2017-03-19 07:36:07 -04:00
Ramón García Fernández
1e0d107b4b Modify configure.host to detect compilation with Microsoft Visual C++ and use assembly with Intel syntax in that case 2017-01-08 20:34:44 +01:00
Richard Henderson
794a54d4a6 Mark win64.S with GNU-stack note 2016-06-05 14:57:00 -07:00
Iain Sandoe
92810b4bc1 [Darwin-x86, build] Fix up label prefixes, remove .purgem
Darwin uses a label prefix of _.
cctools assembler will not accept .purgem as a directive.
2016-05-26 09:06:35 +01:00
Berker Peksag
4a677a425c 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.
2016-05-18 10:35:20 +03:00
Richard Henderson
e5843a3a09 x86: Fix calling convention for ffi_closure_win64_inner
Also enable testing for the cross-abi calls.
2016-04-29 14:17:36 -07:00
Richard Henderson
d06751979b x86: Copy fix for clang .org from unix64.S
Clang doesn't understand .org with symbolic operands.
2016-04-15 16:10:28 -07:00
Josh Triplett
1f6b5a91f4 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.
2015-07-26 17:18:16 -07:00
Josh Triplett
6de51f3e04 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.
2015-07-26 17:18:16 -07:00
Josh Triplett
eaa59755fc 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.
2015-07-26 17:18:16 -07:00
Josh Triplett
c8e82d9fbf 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.
2015-07-26 16:18:57 -07:00
Richard Henderson
3ac1610aa3 x86: Fix cygwin32 build
The section syntax is just that little bit different.
2015-01-19 20:48:40 +01:00
Rainer Orth
f1560b7bbe 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.
2015-01-16 11:32:11 -08:00
Richard Henderson
f27c4e4673 x86: Fix thinko in ffi_raw_call
Missed structure initialization for raw path.
Apparently there are no tests for this outside gcc.
2015-01-13 07:22:07 -08:00
Anthony Green
1c61e73ad8 Merge pull request #165 from rth7680/pcc
Support PCC as producer and consumer
2015-01-10 09:23:30 -05:00
Anthony Green
dd0b59a5cf Merge pull request #164 from rth7680/darwin
Fix build on darwin
2015-01-10 09:22:55 -05:00
Anthony Green
9131039c93 Merge pull request #160 from nobu/msvc-no-complex
x86: MSVC does not support Complex type
2015-01-10 09:22:42 -05:00
Richard Henderson
3fa5d70cbb 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.
2015-01-05 13:03:06 -08:00
Richard Henderson
a03d2310ed x86: Load structure return address into eax 2015-01-05 12:24:51 -08:00
Richard Henderson
b7f6d7aa9b x86: Reinstate hand-written unwind info for sysv.S 2015-01-05 10:01:38 -08:00
Richard Henderson
6cedf81ca7 x86: Expand FFI_GO_CLOSURE
If we're going to have to hand-write unwind info for darwin,
these macros make the job harder.
2015-01-05 10:01:38 -08:00
Iain Sandoe
ae842a515b 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.
2015-01-05 10:01:38 -08:00
Richard Henderson
8fa3c9f24b x86: Reinstate hand-written unwind info for unix64.S
One more try to get default Darwin to work.
2015-01-05 10:01:37 -08:00
Richard Henderson
5f35e0ffcc x86: Avoid using gas local labels
Which are unsupported by Darwin cctools as.
Thankfully this doesn't uglify the source too much.
2015-01-05 10:01:37 -08:00
Richard Henderson
ed1ca2777c 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.
2015-01-05 10:01:37 -08:00
Richard Henderson
1b12593d7e 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.
2015-01-05 10:01:37 -08:00
Richard Henderson
042b8dafee 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.
2015-01-05 10:01:37 -08:00
Richard Henderson
0172bc029c x86: Disable .org for Darwin 2015-01-05 10:01:37 -08:00
Richard Henderson
9f112619c1 x86: Best guess at update for Darwin 2015-01-05 10:01:37 -08:00
Nobuyoshi Nakada
7282d3289c x86: MSVC does not support Complex type 2014-12-22 17:14:40 +09:00
Nobuyoshi Nakada
5f8881a591 x86: Fix void pointer arithmetic 2014-12-22 17:08:08 +09:00
Richard Henderson
2f65246968 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.
2014-12-11 14:16:00 -08:00
Richard Henderson
097ccfd6a6 x86: Fix some unwind errors 2014-12-11 14:11:44 -08:00
Richard Henderson
dea49e2020 x86: Fix typo in ffi_prep_go_closure
Used the wrong register for THISCALL and FASTCALL.
2014-11-14 13:07:47 +01:00
Richard Henderson
0e303c0657 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
2014-11-12 03:58:58 -08:00
Richard Henderson
2650f47fe8 x86: Use win32 name mangling for fastcall functions 2014-11-12 09:16:02 +01:00
Richard Henderson
f8c64e2486 x86: Add support for Go closures 2014-11-12 09:16:02 +01:00
Richard Henderson
198f469e91 x86: Add support for Complex 2014-11-12 09:16:02 +01:00
Richard Henderson
b21ec1ce78 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.
2014-11-12 09:15:54 +01:00
Richard Henderson
b9ac94f3af 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.
2014-11-12 09:15:35 +01:00
Richard Henderson
159d3788eb x86: Convert to gas generated unwind info 2014-11-12 09:15:35 +01:00
Richard Henderson
e7b0056d60 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.
2014-11-12 09:15:35 +01:00
Richard Henderson
4b2fad8fd5 x86: Remove some conditional compilation
Removal of ifdefs made possible to due to ffi_abi unification.
2014-11-12 09:15:35 +01:00
Richard Henderson
ef76205647 x86: Tidy ffi_abi
The x86_64 unix port only handles one ABI; don't define all of the
other symbols.  The UNIX64 symbol retains the same value.

The i386 ports ought to have the same symbols, even if we can't yet
unify the values without incrementing the libffi soname.
2014-11-12 09:15:35 +01:00
Richard Henderson
610c90bf71 x86_64: Add support for complex types 2014-11-12 09:15:35 +01:00
Richard Henderson
32c5683163 x86_64: Decouple return types from FFI_TYPE constants
We can better support structure returns, and as prep for
complex types.
2014-11-12 09:15:35 +01:00
Richard Henderson
2e9dc16556 x86_64: Fixups for x32 2014-11-12 09:15:35 +01:00
Richard Henderson
ebd82769de win64: Remove support from ffi.c 2014-11-12 09:15:35 +01:00
Richard Henderson
99db4d42ac win64: Rewrite
It's way too different from the 32-bit ABIs with which it is
currently associated. As seen from all of the existing XFAILs.
2014-11-12 09:15:35 +01:00
Richard Henderson
6b62fb4a26 x86-64: Support go closures
Dumps all of the hand-coded unwind info for gas generated.  Move jump
table data into .rodata.  Adjust ffi_call_unix64 to load the static
chain.  Split out sse portions of ffi_closure_unix64 to
ffi_closure_unix64_sse rather than test cif->flags at runtime.
2014-11-12 09:15:35 +01:00