Patchwork Fix array sizes created by Java FE (PR libgcj/57074)

login
register
mail settings
Submitter Alan Modra
Date May 4, 2013, 12:03 a.m.
Message ID <20130504000334.GQ5221@bubble.grove.modra.org>
Download mbox | patch
Permalink /patch/241413/
State New
Headers show

Comments

Alan Modra - May 4, 2013, 12:03 a.m.
On Fri, May 03, 2013 at 07:10:15PM +0200, Jakub Jelinek wrote:
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, but
> not tested on powerpc32 where it actually caused runtime issues, can
> somebody please try it there?  Ok for trunk/4.8?

/home/amodra/build/gcc-current/./gcc/gcj -B/home/amodra/build/gcc-current/powerpc-linux/64/libjava/ -B/home/amodra/build/gcc-current/powerpc-linux/64/libjava/ -B/home/amodra/build/gcc-current/./gcc/ -B/home/amodra/gnu/powerpc-linux/bin/ -B/home/amodra/gnu/powerpc-linux/lib/ -isystem /home/amodra/gnu/powerpc-linux/include -isystem /home/amodra/gnu/powerpc-linux/sys-include -m64 -fclasspath= -fbootclasspath=/home/amodra/src/gcc-current/libjava/classpath/lib --encoding=UTF-8 -Wno-deprecated -fbootstrap-classes -g -O2 -m64 -fsource-filename=/home/amodra/build/gcc-current/powerpc-linux/64/libjava/classpath/lib/classes -fjni -findirect-dispatch -fno-indirect-classes -c @gnu-CORBA.list  -fPIC -o .libs/gnu-CORBA.o -v -save-temps

Looks like this is not the only problem.  Using the attached patch to
verify section anchor block layout leads me to

        .org .LANCB76+23560
        .type   _atable_syms_gnu_CORBA_NamingService_NameValidator, @object
        .size   _atable_syms_gnu_CORBA_NamingService_NameValidator, 96
_atable_syms_gnu_CORBA_NamingService_NameValidator:
        .quad   _Utf42
        .quad   _Utf34
        .quad   _Utf35
        .quad   _Utf3318.82185
        .quad   _Utf34
        .quad   _Utf170
        .quad   _Utf293
        .quad   _Utf34
        .quad   _Utf170
        .quad   0
        .quad   0
        .quad   0
        .org .LANCB76+23608

The difference between .org's is 48, but the actual size 96.  The next
_atable in this file shows 48/72.

Patch

	PR libcgj/57074
	* varasm.c (output_object_block): Use .org for each item in
	section anchor block rather than padding.

Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 198274)
+++ gcc/varasm.c	(working copy)
@@ -7095,6 +7105,10 @@ 
   HOST_WIDE_INT offset;
   tree decl;
   rtx symbol;
+#if HAVE_GNU_AS
+  static int labelno;
+  char buf[30];
+#endif
 
   if (!block->objects)
     return;
@@ -7104,6 +7118,12 @@ 
   switch_to_section (block->sect);
   assemble_align (block->alignment);
 
+#if HAVE_GNU_AS
+  ASM_GENERATE_INTERNAL_LABEL (buf, "LANCB", labelno);
+  ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, buf);
+  ++labelno;
+#endif
+
   /* Define the values of all anchors relative to the current section
      position.  */
   FOR_EACH_VEC_SAFE_ELT (block->anchors, i, symbol)
@@ -7114,7 +7134,14 @@ 
   FOR_EACH_VEC_ELT (*block->objects, i, symbol)
     {
       /* Move to the object's offset, padding with zeros if necessary.  */
+#if HAVE_GNU_AS
+      fprintf (asm_out_file, "\t.org ");
+      assemble_name_raw (asm_out_file, buf);
+      fprintf (asm_out_file, "+" HOST_WIDE_INT_PRINT_DEC "\n",
+	       SYMBOL_REF_BLOCK_OFFSET (symbol));
+#else
       assemble_zeros (SYMBOL_REF_BLOCK_OFFSET (symbol) - offset);
+#endif
       offset = SYMBOL_REF_BLOCK_OFFSET (symbol);
       if (CONSTANT_POOL_ADDRESS_P (symbol))
 	{
@@ -7154,6 +7181,7 @@ 
 	    }
 	}
     }
+  gcc_checking_assert (offset == block->size);
 }
 
 /* A htab_traverse callback used to call output_object_block for