------- Comment #4 from jakub at gcc dot gnu dot org  2010-09-15 17:07 -------
That patch looks wrong.  The padding for alignment must be done before the
arguments, not after them.
Say if bytes is 24 at the start of one iteration, cif->arg_types[i]->alignment
is 32 and cif->arg_types[i]->size is 40, currently it would correctly
first pad bytes to 32 and then increase it 72, while with your patch
it will be 64.
What we need is to make sure < 8 byte arguments have the whole word assigned
for them.  As alignment is always set to at least 8, it is enough to add this
final padding just at the end, so I think the right fix is:
--- libffi/src/x86/ffi64.c 2010-08-11 21:08:14.000000000 +0200
+++ libffi/src/x86/ffi64.c 2010-09-15 19:05:16.573717651 +0200
@@ -390,7 +390,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
   if (ssecount)
     flags |= 1 << 11;
   cif->flags = flags;
-  cif->bytes = bytes;
+  cif->bytes = ALIGN (bytes, 8);

   return FFI_OK;
 }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45677

Reply via email to