This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libffi patch: x86_64 stack args incorrectly aligned


Thanks to Gary Benson and Tom tromey for finding this.  On the x86_64,
we weren't 8-aligning args on the stack that weren't register
allocated.  I'm not really surprised we never noticed this before,
because it requires a lot of method arguments to show the problem.

I committed this, and an accompanying test case.

Andrew.



2004-08-10  Andrew Haley  <aph@redhat.com>

	* src/x86/ffi64.c (ffi_prep_args ): 8-align all stack arguments.

Index: ffi64.c
===================================================================
RCS file: /cvs/gcc/gcc/libffi/src/x86/ffi64.c,v
retrieving revision 1.6
diff -u -r1.6 ffi64.c
--- ffi64.c	21 Jan 2004 06:11:08 -0000	1.6
+++ ffi64.c	10 Aug 2004 13:32:32 -0000
@@ -341,6 +341,8 @@
 	{
 	  /* Pass this argument in memory.  */
 	  argp = (void *)ALIGN(argp, (*p_arg)->alignment);
+	  /* Stack arguments are *always* at least 8 byte aligned.  */
+	  argp = (void *)ALIGN(argp, 8);
 	  memcpy (argp, *p_argv, (*p_arg)->size);
 	  argp += (*p_arg)->size;
 	}

2004-08-10  Andrew Haley  <aph@redhat.com>

	* testsuite/libjava.lang/err14.java: New file.
	* testsuite/libjava.lang/err14.out: New file.

Index: libjava.lang/err14.java
===================================================================
RCS file: libjava.lang/err14.java
diff -N libjava.lang/err14.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libjava.lang/err14.java     10 Aug 2004 14:18:27 -0000
@@ -0,0 +1,20 @@
+/* Check for incorrectly aligned byte args.  */
+
+public class err14
+{
+  protected final String getClearToolCommand(Object a, Object b,
+                                             Object c, Object d, 
+                                             int e, int f, boolean x) 
+  {
+    return x ? "hi" : "byte";
+  }
+  
+  
+  public static void main(String[] args)
+  {
+    System.out.println(new err14().getClearToolCommand(null, null,
+                                                       null, null, 0, 0, false));
+    System.out.println(new err14().getClearToolCommand(null, null,
+                                                       null, null, 0, 0, true));
+  }
+}
Index: libjava.lang/err14.out
===================================================================
RCS file: libjava.lang/err14.out
diff -N libjava.lang/err14.out
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libjava.lang/err14.out      10 Aug 2004 14:18:27 -0000
@@ -0,0 +1,2 @@
+byte
+hi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]