re PR go/72814 (reflect FAILs on 32-bit Solaris/SPARC: SIGILL)
PR go/72814 runtime: treat zero-sized result value as void Change the FFI interface to treat a call to a function that returns a zero-sized result as a call to a function that returns void. This is part of the fix for https://gcc.gnu.org/PR72814. On 32-bit SPARC systems, a call to a function that returns a non-zero-sized struct is followed by an unimp instruction that describes the size of the struct. The function returns to the address after the unimp instruction. The libffi library can not represent a zero-sized struct, so we wind up treating it as a 1-byte struct. Thus in that case libffi calls the function with an unimp instruction, but the function does not adjust the return address. The result is that the program attempts to execute the unimp instruction, causing a crash. This is part of a change that fixes the crash by treating all functions that return zero bytes as functions that return void. Reviewed-on: https://go-review.googlesource.com/25585 * go-gcc.cc (Gcc_backend::function_type): If the return type is zero bytes, treat the function as returning void. (return_statement): If the return type is zero bytes, don't actually return any values. From-SVN: r239252
This commit is contained in:
parent
5c93439607
commit
f432d1282d
4 changed files with 49 additions and 1 deletions
|
@ -288,6 +288,17 @@ go_func_return_ffi (const struct __go_func_type *func)
|
|||
|
||||
types = (const struct __go_type_descriptor **) func->__out.__values;
|
||||
|
||||
// We compile a function that returns a zero-sized value as though
|
||||
// it returns void. This works around a problem in libffi: it can't
|
||||
// represent a zero-sized value.
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
if (types[i]->__size > 0)
|
||||
break;
|
||||
}
|
||||
if (i == count)
|
||||
return &ffi_type_void;
|
||||
|
||||
if (count == 1)
|
||||
return go_type_to_ffi (types[0]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue