Commit Graph

142 Commits

Author SHA1 Message Date
Jeremy Huddleston Sequoia
65da63abc8 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>
2018-06-25 07:38:58 -04:00
Shoaib Meenai
2309b58448 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_
2018-06-17 20:04:24 -04:00
Jeremy Huddleston Sequoia
1d704051b2 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>
2018-06-17 20:01:50 -04:00
Anthony Green
b55baf0b50 Handle FFI_GNUW64 on non-Windows systems (EFI) 2018-05-09 13:21:02 -04:00
Anthony Green
b5ee395710 Revert "Remove some symbol exports and cleanup newline warnings (#433)"
This reverts commit a5a0f3cf36.
2018-05-05 07:41:53 -04:00
Jeremy Huddleston Sequoia
a5a0f3cf36 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>
2018-05-05 06:44:33 -04:00
hjl-tools
d3c54cf3a2 Re-enable msabi testing (#436)
* Revert "disable msabi testing for now"

This reverts commit 7b7638eb0e.

* 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.
2018-05-02 09:19:58 -04:00
Tom Tromey
4c2206ace0 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.
2018-04-28 06:46:10 -04:00
Anthony Green
369ef49f71 Add missing FFI_GNUW64 enum 2018-03-18 12:53:42 -04:00
Anthony Green
43980dd10e Add FFI_GNUW64 ABI for GNU 80-bit long double support 2018-03-18 12:33:38 -04:00
Ole André Vadla Ravnås
28d3b61bdd 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.
2018-01-21 01:27:22 +01:00
jon
d15581c696 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)' 2017-12-01 00:34:30 -08:00
Anthony Green
dc2ff5baab Merge pull request #323 from compnerd/x86-alloca-alignment
x86: align alloca to 16-byte boundary
2017-10-25 13:11:40 -04:00
Anthony Green
927da71662 Merge pull request #379 from jlj/master
Xcode build improvements
2017-10-25 13:05:53 -04:00
H.J. Lu
9d9d92b47f Skip WIN64/EFI64 support for x32
Since x32 doesn't support WIN64/EFI64, skip it if __ILP32__ is defined.
2017-10-25 05:37:30 -07:00
Jean-Luc Jumpertz
181fc4cc9c 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
2017-10-23 15:02:29 +02:00
Saleem Abdulrasool
79d1509cb0 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.
2017-10-22 14:09:51 -07:00
Jean-Luc Jumpertz
a78da73956 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.
2017-09-04 15:55:34 +02:00
Francis Ricci
9c12209d2e Fix misaligned memory access in ffi_call_int 2017-08-03 10:46:28 -07:00
Gregory Pakosz
bd72848c7a Prefix ALIGN macros with FFI_ 2017-04-27 13:22:28 +02:00
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