This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] i386, a.out and _GLOBAL_OFFSET_TABLE_


PIC code does not work on a.out i386--netbsd because the GOT symbol name is
emitted as "__GLOBAL_OFFSET_TABLE_" instead of the expected
"_GLOBAL_OFFSET_TABLE_". This is fixed by the patch below...

Bootstrapped and regtested on i386-unknown-netbsdelf1.6 and
i386-unknown-netbsd1.4.3 (where it fixes 932 test failures :-)

Ok to commit?

   /Krister


2002-09-04  Krister Walfridsson  <cato@df.lth.se>

	* config/i386/i386.h (GOT_SYMBOL_NAME): Define.
	* config/i386/i386.c (output_set_got): Use GOT_SYMBOL_NAME.
	(ix86_output_addr_diff_elt) Likewise.
	(x86_output_mi_thunk) Likewise.
	* config/i386/netbsd.h (GOT_SYMBOL_NAME): Redefine.


Index: i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.280
diff -c -3 -p -r1.280 i386.h
*** i386.h	31 Jul 2002 23:18:43 -0000	1.280
--- i386.h	4 Sep 2002 21:06:20 -0000
*************** do {									\
*** 1098,1103 ****
--- 1098,1105 ----
     : reload_completed ? REGNO (pic_offset_table_rtx)	\
     : REAL_PIC_OFFSET_TABLE_REGNUM)

+ #define GOT_SYMBOL_NAME "_GLOBAL_OFFSET_TABLE_"
+
  /* Register in which address to store a structure value
     arrives in the function.  On the 386, the prologue
     copies this from the stack to register %eax.  */
Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.450
diff -c -3 -p -r1.450 i386.c
*** i386.c	27 Aug 2002 17:52:41 -0000	1.450
--- i386.c	4 Sep 2002 21:07:15 -0000
*************** output_set_got (dest)
*** 3963,3969 ****
    rtx xops[3];

    xops[0] = dest;
!   xops[1] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");

    if (! TARGET_DEEP_BRANCH_PREDICTION || !flag_pic)
      {
--- 3963,3969 ----
    rtx xops[3];

    xops[0] = dest;
!   xops[1] = gen_rtx_SYMBOL_REF (Pmode, GOT_SYMBOL_NAME);

    if (! TARGET_DEEP_BRANCH_PREDICTION || !flag_pic)
      {
*************** ix86_output_addr_diff_elt (file, value,
*** 7335,7342 ****
  	     machopic_function_base_name () + 1);
  #endif
    else
!     asm_fprintf (file, "%s%U_GLOBAL_OFFSET_TABLE_+[.-%s%d]\n",
! 		 ASM_LONG, LPREFIX, value);
  }

  /* Generate either "mov $0, reg" or "xor reg, reg", as appropriate
--- 7335,7342 ----
  	     machopic_function_base_name () + 1);
  #endif
    else
!     asm_fprintf (file, "%s%U%s+[.-%s%d]\n",
! 		 ASM_LONG, GOT_SYMBOL_NAME, LPREFIX, value);
  }

  /* Generate either "mov $0, reg" or "xor reg, reg", as appropriate
*************** x86_output_mi_thunk (file, delta, functi
*** 13800,13806 ****
  	{
  	  xops[0] = pic_offset_table_rtx;
  	  xops[1] = gen_label_rtx ();
! 	  xops[2] = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");

  	  if (ix86_regparm > 2)
  	    abort ();
--- 13800,13806 ----
  	{
  	  xops[0] = pic_offset_table_rtx;
  	  xops[1] = gen_label_rtx ();
! 	  xops[2] = gen_rtx_SYMBOL_REF (Pmode, GOT_SYMBOL_NAME);

  	  if (ix86_regparm > 2)
  	    abort ();
Index: netbsd.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/netbsd.h,v
retrieving revision 1.24
diff -c -3 -p -r1.24 netbsd.h
*** netbsd.h	4 Jun 2002 18:07:41 -0000	1.24
--- netbsd.h	4 Sep 2002 21:07:16 -0000
***************
*** 62,64 ****
--- 62,69 ----
  /* Until they use ELF or something that handles dwarf2 unwinds
     and initialization stuff better.  */
  #define DWARF2_UNWIND_INFO 0
+
+ /* Redefine this so that it becomes "_GLOBAL_OFFSET_TABLE_" when the label
+    prefix is added.  */
+ #undef GOT_SYMBOL_NAME
+ #define GOT_SYMBOL_NAME "GLOBAL_OFFSET_TABLE_"


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