This is the mail archive of the java-discuss@sources.redhat.com 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]

Re: Java broken after i386 PIC change


Richard Henderson wrote:

> I don't see how -- there are no regressions in make check for
> either libjava or libstdc++.  And both excercise their respective
> shared libraries.

So, are you saying that Java is working for you on x86, with the current tree?
Interesting.

> You'll have to give me a better bug report than this if
> you expect me to look into it at all.

I currently have two installed gcc trees on my Red Hat 6.2 system (glibc
2.1.3-22) which were built from exactly the same source (cvs from earlier
today), including libstdc++-v3 and libgcj, except in one of them I reverted
this patch (which I will attach just to make sure that we're talking about the
same thing here.)

The tree with the patch reverted works fine. The unmodified tree crashes on
any attempt to run a Java program, in __register_frame_info(). See stack trace
in previous message.

Looking at a dump of the __register_frame_info() function in gdb, we can see a
problem:

Dump of assembler code for function __register_frame_info:
0x804aa90 <__register_frame_info>:      push   %ebp
0x804aa91 <__register_frame_info+1>:    mov    %esp,%ebp
0x804aa93 <__register_frame_info+3>:    push   %edi
0x804aa94 <__register_frame_info+4>:    push   %esi
0x804aa95 <__register_frame_info+5>:    push   %ebx
0x804aa96 <__register_frame_info+6>:    sub    $0xc,%esp
0x804aa99 <__register_frame_info+9>:    call   0x0      <---- eh?
0x804aa9e <__register_frame_info+14>:   add    $0x29b2,%ebx
0x804aaa4 <__register_frame_info+20>:   mov    0xc(%ebp),%esi
0x804aaa7 <__register_frame_info+23>:   lea    0xfffff9e0(%ebx),%edi

while in the working tree, it looks like this:

(gdb) disass
Dump of assembler code for function __register_frame_info:
0x804aa90 <__register_frame_info>:      push   %ebp
0x804aa91 <__register_frame_info+1>:    mov    %esp,%ebp
0x804aa93 <__register_frame_info+3>:    push   %edi
0x804aa94 <__register_frame_info+4>:    push   %esi
0x804aa95 <__register_frame_info+5>:    push   %ebx
0x804aa96 <__register_frame_info+6>:    sub    $0xc,%esp
0x804aa99 <__register_frame_info+9>:    call   0x804a600 <fde_merge+208>
0x804aa9e <__register_frame_info+14>:   add    $0x29b2,%ebx
0x804aaa4 <__register_frame_info+20>:   mov    0xc(%ebp),%esi
0x804aaa7 <__register_frame_info+23>:   lea    0xfffff9e0(%ebx),%edi

Several other Java hackers have reported that they're also seeing this, so I
think that rules out anything silly I might have done locally.

regards

  [ bryce ]

Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -r1.204 -r1.205
--- i386.c	2001/01/15 13:19:31	1.204
+++ i386.c	2001/01/15 23:43:10	1.205
@@ -1689,44 +1689,53 @@
   return tsize == 0 && nregs == 0;
 }
 
-static const char *pic_label_name;
-static int pic_label_output;
+static char pic_label_name[32];
 
 /* This function generates code for -fpic that loads %ebx with
    the return address of the caller and then returns.  */
 
 void
-asm_output_function_prefix (file, name)
+ix86_asm_file_end (file)
      FILE *file;
-     const char *name ATTRIBUTE_UNUSED;
 {
   rtx xops[2];
-  int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
-				  || current_function_uses_const_pool);
-  xops[0] = pic_offset_table_rtx;
-  xops[1] = stack_pointer_rtx;
 
-  /* Deep branch prediction favors having a return for every call.  */
-  if (pic_reg_used && TARGET_DEEP_BRANCH_PREDICTION)
-    {
-      if (!pic_label_output)
-	{
-	  /* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an
-	     internal (non-global) label that's being emitted, it didn't make
-	     sense to have .type information for local labels.   This caused
-	     the SCO OpenServer 5.0.4 ELF assembler grief (why are you giving
-	     me debug info for a label that you're declaring non-global?) this
-	     was changed to call ASM_OUTPUT_LABEL() instead.  */
-
-	  ASM_OUTPUT_LABEL (file, pic_label_name);
-
-	  xops[1] = gen_rtx_MEM (SImode, xops[1]);
-	  output_asm_insn ("mov{l}\t{%1, %0|%0, %1}", xops);
-	  output_asm_insn ("ret", xops);
+  if (! TARGET_DEEP_BRANCH_PREDICTION || pic_label_name[0] == 0)
+    return;
 
-	  pic_label_output = 1;
-	}
-    }
+#ifdef ASM_OUTPUT_SECTION_NAME
+  /* The trick here is to create a linkonce section containing the
+     pic label thunk, but to refer to it with an internal label.
+     Because the label is internal, we don't have inter-dso name
+     binding issues on hosts that don't support ".hidden".
+
+     In order to use these macros, however, we must create a fake
+     function decl.  */
+  {
+    tree decl = build_decl (FUNCTION_DECL,
+			    get_identifier ("i686.get_pc_thunk"),
+			    error_mark_node);
+    DECL_ONE_ONLY (decl) = 1;
+    UNIQUE_SECTION (decl, 0);
+    named_section (decl, NULL, 0);
+  }
+#else
+  text_section ();
+#endif
+
+  /* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an
+     internal (non-global) label that's being emitted, it didn't make
+     sense to have .type information for local labels.   This caused
+     the SCO OpenServer 5.0.4 ELF assembler grief (why are you giving
+     me debug info for a label that you're declaring non-global?) this
+     was changed to call ASM_OUTPUT_LABEL() instead.  */
+
+  ASM_OUTPUT_LABEL (file, pic_label_name);
+
+  xops[0] = pic_offset_table_rtx;
+  xops[1] = gen_rtx_MEM (SImode, stack_pointer_rtx);
+  output_asm_insn ("mov{l}\t{%1, %0|%0, %1}", xops);
+  output_asm_insn ("ret", xops);
 }
 
 void
@@ -1738,12 +1747,8 @@
 
   if (TARGET_DEEP_BRANCH_PREDICTION)
     {
-      if (pic_label_name == NULL)
-	{
-	  char buf[32];
-	  ASM_GENERATE_INTERNAL_LABEL (buf, "LPR", 0);
-	  pic_label_name = ggc_strdup (buf);
-	}
+      if (! pic_label_name[0])
+	ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", 0);
       pclab = gen_rtx_MEM (QImode, gen_rtx_SYMBOL_REF (Pmode, pic_label_name));
     }
   else
@@ -1951,8 +1956,8 @@
 void
 ix86_expand_prologue ()
 {
-  HOST_WIDE_INT tsize = ix86_compute_frame_size (get_frame_size (), (int *) 0, (int *) 0,
-						 (int *) 0);
+  HOST_WIDE_INT tsize = ix86_compute_frame_size (get_frame_size (), (int *) 0,
+						 (int *) 0, (int *) 0);
   rtx insn;
   int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
 				  || current_function_uses_const_pool);
Index: config/i386/cygwin.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/cygwin.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- cygwin.h	2000/11/10 04:10:04	1.28
+++ cygwin.h	2001/01/15 23:43:10	1.29
@@ -498,6 +498,7 @@
   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
 
 /* Output function declarations at the end of the file.  */
+#undef ASM_FILE_END
 #define ASM_FILE_END(FILE) \
   i386_pe_asm_file_end (FILE)
 
Index: config/i386/i386-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386-protos.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- i386-protos.h	2001/01/14 09:14:03	1.34
+++ i386-protos.h	2001/01/15 23:43:10	1.35
@@ -26,7 +26,7 @@
 
 extern int ix86_can_use_return_insn_p PARAMS ((void));
 
-extern void asm_output_function_prefix PARAMS ((FILE *, const char *));
+extern void ix86_asm_file_end PARAMS ((FILE *));
 extern void load_pic_register PARAMS ((void));
 extern HOST_WIDE_INT ix86_initial_elimination_offset PARAMS((int, int));
 extern void ix86_expand_prologue PARAMS ((void));
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -r1.144 -r1.145
--- i386.h	2001/01/13 08:57:29	1.144
+++ i386.h	2001/01/15 23:43:10	1.145
@@ -1356,13 +1356,11 @@
        || ! FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (DECL)))) \
        || FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (TREE_TYPE (cfun->decl))))))
 
-/* This macro is invoked just before the start of a function.
-   It is used here to output code for -fpic that will load the
-   return address into %ebx.  */
+/* This macro is invoked at the end of compilation.  It is used here to
+   output code for -fpic that will load the return address into %ebx.  */
 
-#undef ASM_OUTPUT_FUNCTION_PREFIX
-#define ASM_OUTPUT_FUNCTION_PREFIX(FILE, FNNAME) \
-  asm_output_function_prefix (FILE, FNNAME)
+#undef ASM_FILE_END
+#define ASM_FILE_END(FILE)  ix86_asm_file_end (FILE)
 
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.  */
Index: config/i386/osfrose.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/osfrose.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- osfrose.h	2000/11/02 23:29:10	1.16
+++ osfrose.h	2001/01/15 23:43:10	1.17
@@ -752,12 +752,13 @@
 #define SCCS_DIRECTIVE
 
 /* This says what to print at the end of the assembly file */
+#undef ASM_FILE_END
 #define ASM_FILE_END(STREAM)						\
 do									\
   {									\
     if (HALF_PIC_P ())							\
       HALF_PIC_FINISH (STREAM);						\
-									\
+    ix86_asm_file_end (STREAM);						\
     if (!flag_no_ident)							\
       {									\
 	char *fstart = main_input_filename;				\
Index: config/i386/sco5.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/sco5.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- sco5.h	2000/12/30 17:14:52	1.41
+++ sco5.h	2001/01/15 23:43:10	1.42
@@ -213,6 +213,7 @@
 #undef ASM_FILE_END
 #define ASM_FILE_END(FILE)						\
 do {									\
+     ix86_asm_file_end (FILE);						\
      if (!flag_no_ident)						\
 	fprintf ((FILE), "%s\"GCC: (GNU) %s\"\n",			\
 		 IDENT_ASM_OP, version_string);				\
Index: config/i386/winnt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/winnt.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- winnt.c	2000/01/22 19:49:21	1.18
+++ winnt.c	2001/01/15 23:43:10	1.19
@@ -592,6 +592,8 @@
 {
   struct extern_list *p;
 
+  ix86_asm_file_end (file);
+
   for (p = extern_head; p != NULL; p = p->next)
     {
       tree decl;
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config.gcc,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- config.gcc	2001/01/09 22:10:52	1.20
+++ config.gcc	2001/01/15 23:43:10	1.21
@@ -979,7 +979,7 @@
 	;;
 i[34567]86-*-elf*)
 	xm_file="${xm_file} xm-svr4.h i386/xm-sysv4.h"
-	tm_file="i386/i386.h i386/att.h elfos.h i386/i386elf.h"
+	tm_file="i386/i386.h i386/att.h elfos.h i386/i386afe.h i386/i386elf.h"
 	tmake_file=i386/t-i386elf
 	xmake_file=x-svr4
 	;;
@@ -1095,7 +1095,7 @@
 	tmake_file=t-freebsd
 	;;
 i[34567]86-*-freebsd*)
-	tm_file="i386/i386.h i386/att.h svr4.h freebsd.h i386/freebsd.h i386/perform.h"
+	tm_file="i386/i386.h i386/att.h svr4.h freebsd.h i386/i386afe.h i386/freebsd.h i386/perform.h"
 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
 	tmake_file=t-freebsd
 	gas=yes
@@ -1166,7 +1166,7 @@
 				# with ELF format using the
 				# GNU/Linux C library 5
 	xmake_file=x-linux	
-	tm_file="i386/i386.h i386/att.h linux.h i386/linux.h"
+	tm_file="i386/i386.h i386/att.h linux.h i386/i386afe.h i386/linux.h"
 	tmake_file="t-linux t-linux-gnulibc1 i386/t-crtstuff"
 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
 	gnu_ld=yes
@@ -1179,7 +1179,7 @@
 			# with ELF format using glibc 2
 			# aka GNU/Linux C library 6
 	xmake_file=x-linux
-	tm_file="i386/i386.h i386/att.h linux.h i386/linux.h"
+	tm_file="i386/i386.h i386/att.h linux.h i386/i386afe.h i386/linux.h"
 	tmake_file="t-linux i386/t-crtstuff"
 	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
 	gnu_ld=yes
@@ -1210,7 +1210,7 @@
 	esac
 	;;
 i[34567]86-moss-msdos* | i[34567]86-*-moss*)
-	tm_file="i386/i386.h i386/att.h linux.h i386/linux.h i386/moss.h"
+	tm_file="i386/i386.h i386/att.h linux.h i386/i386afe.h i386/linux.h i386/moss.h"
 	tmake_file=t-libc-ok
 	gnu_ld=yes
 	gas=yes
Index: config/elfos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/elfos.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- elfos.h	2000/11/27 04:25:32	1.23
+++ elfos.h	2001/01/15 23:43:10	1.24
@@ -100,6 +100,7 @@
 
 #define IDENT_ASM_OP "\t.ident\t"
 
+#undef ASM_FILE_END
 #define ASM_FILE_END(FILE)				\
   do							\
     {				 			\

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