|
dca52b55
|
2018-03-11T08:50:01
|
|
Merge pull request #406 from trofi/master
ia64: fix variadic function closures with FP arguments
|
|
b58caef7
|
2018-02-17T19:00:40
|
|
ia64: fix small struct return
This change fixes libffi.call/struct10.c failure on ia64:
FAIL: libffi.call/struct10.c -W -Wall -Wno-psabi -O0 execution test
.Lst_small_struct handles returns for structs less than 32 bytes
(following ia64 return value ABI [1]). Subroutine does roughly the
following:
```
mov [sp+0] = r8
mov [sp+8] = r9
mov [sp+16] = r10
mov [sp+24] = r11
memcpy(destination, source=sp, 12);
```
The problem: ia64 ABI guarantees that top 16 bytes of stack are
scratch space for callee function. Thus it can clobber it. [1]
says (7.1 Procedure Frames):
"""
* Scratch area. This 16-byte region is provided as scratch storage
for procedures that are called by the current procedure. Leaf
procedures do not need to allocate this region. A procedure may
use the 16 bytes at the top of its own frame as scratch memory,
but the contents of this area are not preserved by a procedure call.
"""
In our case 16 top bytes are clobbered by a PLT resolver when memcpy()
is called for the first time. As a result memcpy implementation reads
already clobbered data frop top of stack.
The fix is simple: allocate 16 bytes of scrats space prior to memcpy()
call.
[1]: https://www.intel.com/content/dam/www/public/us/en/documents/guides/itanium-software-runtime-architecture-guide.pdf
Bug: https://bugs.gentoo.org/634190
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
|
11de69dd
|
2018-02-11T11:29:39
|
|
ia64: fix variadic function closures with FP arguments
libffi test framework already flagged failures as:
```
FAIL: libffi.call/cls_double_va.c -W -Wall -Wno-psabi -O0 output pattern test, is 7.0
res: 4
0.0
res: 4
? should match 7.0
?es: 4
?.0
res: 4
```
Failure happens here at
```c
// testsuite/libffi.call/cls_double_va.c
...
char* format = "%.1f\n";
double doubleArg = 7;
...
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL,
code) == FFI_OK);
res = ((int(*)(char*, ...))(code))(format, doubleArg);
```
libffi expects 'doubleArg' to be located in 'f9' (second FP argument) but
gcc placed it to 'r33' (second GR).
ia64 software [1] manual described argument passing ABI in
"8.5.2 Register Parameters" as:
"""
If an actual parameter is known to correspond to a floating-point
formal parameter, the following rules apply:
a) The actual parameter is passed in the next available floating-point
parameter register, if one is available. Floating-point parameter
registers are allocated as needed from the range f8-f15, starting
with f8.
b) If all available floating-point parameter registers have been used,
the actual parameter is passed in the appropriate general register(s).
(This case can occur only as a result of homogeneous floating-point
aggregates, described below.)
If a floating-point actual parameter is known to correspond to
a variable-argument specification in the formal parameter list,
the following rule applies:
c) The actual parameter is passed in the appropriate general
register(s).
If the compiler cannot determine, at the point of call,
whether the corresponding formal parameter is a varargs parameter,
it must generate code that satisfies both of the above conditions.
(The compiler’s determination may be based on prototype declarations,
language standard assumptions, analysis, or other user options or
information.)
"""
We have [c] case here and gcc uses only GR for parameter passing.
The change binds known variadic arguments ro GRs instead of FPs as those
are always expected to be initialized for all variadic call types.
This fixes all 10 failures on ia64-unknown-linux-gnu:
```
=== libffi Summary ===
-# of expected passes 1945
-# of unexpected failures 10
+
+# of expected passes 1955
```
[1]: https://www.intel.com/content/dam/www/public/us/en/documents/guides/itanium-software-runtime-architecture-guide.pdf
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
|
ed7488c0
|
2017-10-17T13:00:51
|
|
src/ia64/unix.S: unbreak small struct handling
commit 6e8a4460833594d5af1b4539178025da0077df19
added FFI_TYPE_COMPLEX value type (comes after FFI_TYPE_POINTER)
ia64 ffi_closure_unix reiles on the ordering of
FFI_ enums as ia64 has ia64-specific FFI types:
small struct and FPU extesions.
As a result all tests handling small structs broke.
The change fixes dispatch table by adding (no-op)
FFI_TYPE_COMPLEX entry
This has positive effect of unbreaking most tests
on ia64:
=== libffi Summary ===
-# of expected passes 1595
-# of unexpected failures 295
+# of expected passes 1930
+# of unexpected failures 10
# of unsupported tests 30
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
|
128cd1d2
|
2013-10-08T06:45:51
|
|
Fix spelling errors
|
|
8360bf1c
|
2012-02-23T07:01:13
|
|
Ensure that users don't include ffitarget.h directly
|
|
c365ee75
|
2012-01-23T11:13:18
|
|
Refresh
|
|
1fbf9dc4
|
2011-02-13T08:06:39
|
|
Fix bad_abi test. rc5.
|
|
2db72615
|
2010-11-21T10:50:56
|
|
Rebase
|
|
d14178be
|
2010-07-23T09:14:00
|
|
FFI_LAST_ABI fix
|
|
3f5b1375
|
2010-07-12T14:39:18
|
|
rebase
|
|
63097415
|
2010-05-05T20:14:56
|
|
Micharl Kohler's spelling fixes
|
|
9dc9a293
|
2010-04-13T10:33:52
|
|
Rebase to latest GCC sources
|
|
7b7a42f2
|
2010-01-12T09:14:14
|
|
Rebase from GCC
|
|
c3042afa
|
2010-01-01T08:08:02
|
|
Reset quilt patches post 3.0.9 merge with GCC
|
|
0cfe60e9
|
2009-12-29T10:06:04
|
|
3.0.9rc12
|
|
9458d88f
|
2009-12-26T07:02:27
|
|
Rebase from GCC
|
|
da11bece
|
2009-12-24T05:34:46
|
|
Release 3.0.9rc5
|
|
115ab36f
|
2009-12-24T00:22:00
|
|
Update missing changes for 3.0.9r4.
|
|
c6dddbd0
|
2009-10-04T08:11:33
|
|
Initial commit
|