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]

PR java/25535: gcj broken on 64-bit big-endian systems


BC-compiled code doesn't work on a big-endian 64-bit box because of a
silly mistake initializing entries in the constant pool.  In all cases
the initializer must appear as the first 32-bit integer of a machine
word stored in memory.

Here's a testcase:

public class Test {
     public static void main(String[] args) {
         System.out.println(javax.rmi.CORBA.Stub.class);
     }
}

This fails with a SEGV on PPC 64.

Andrew.


2005-12-22  Andrew Haley  <aph@redhat.com>

	PR java/25535
	* constants.c (build_constants_constructor): move initializer into
	first halfword on a 6-bit big-endian machine.

Index: constants.c
===================================================================
--- constants.c	(revision 108907)
+++ constants.c	(working copy)
@@ -481,7 +481,12 @@
       case CONSTANT_Fieldref:
       case CONSTANT_NameAndType:
 	{
-	  jword temp = outgoing_cpool->data[i].w;
+	  unsigned HOST_WIDE_INT temp = outgoing_cpool->data[i].w;
+
+	  /* Make sure that on a 64-bit big-endian machine this 32-bit
+	     jint appears in the first word.  */
+	  if (BYTES_BIG_ENDIAN && BITS_PER_WORD > 32)
+	    temp <<= BITS_PER_WORD - 32;
 
 	  tags_list
 	    = tree_cons (NULL_TREE, 


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