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]

mips static constructor changes


Hi,

  I'm attaching a patch which changes the way that static constructors
are handled for mips platforms.  In the past, we've used collect to
build the constructor tables.  This patch will cause the compiler to
build them which will bring the mips targets in line with other elf
platforms.  This is important because it allows us to take advantage
of generic elf developments which center around the use of crtbegin/
crtend.  The patch also fixes a problem that is caused because ld/collect
cannot discern whether or not the constructor tables need to be
accessed with 32 or 64 bit pointers.  

  The vxworks, linux and rtems platforms will probably need a little work to get
them to function properly with this change.  For the time being, these
platforms have disabled the new functionality by undefining the CTOR macros.
Please let me know if you need any assistance in upgrading to the new
static ctor/dtor support.

  The patch also requires linker script changes to gather the new .ctor/.dtor
sections.  I will include a sample link script at the end of the patch.

  Thanks,

  --catherine

Mon Apr 12 12:58:03 1999  Catherine Moore  <clm@cygnus.com>

	* config/mips/elf.h, config/mips/elf64.h
	(CTORS_SECTION_ASM_OP): Define.
	(DTORS_SECTION_ASM_OP): Define.
	(EXTRA_SECTIONS): Define.
	(INVOKE__main): Define.
	(NAME__MAIN): Define.
	(SYMBOL__MAIN): Define.
	(EXTRA_SECTIONS_FUNCTIONS): Define.
	(SECTION_FUNCTION_TEMPLATE): Define.
	(ASM_OUTPUT_CONSTRUCTOR): Define.
	(ASM_OUTPUT_DESTRUCTOR): Define.
	(CTOR_LIST_BEGIN): Define.
	(CTOR_LIST_END): Define.
	(DTOR_LIST_BEGIN): Define.
	(DTOR_LIST_END): Define.
	(LIB_SPEC): Define.
	(STARTFILE_SPEC): Define.
	(ENDFILE_SPEC): Define.
	* config/mips/linux.h:  Undefine all of the above.
	* config/mips/rtems64.h: Likewise.
	* config/mips/t-r3900: Likewise.
	* config/mips/t-elf: New file.
	* config/mips/vxworks.h: New file.
	* configure.in (mips-wrs-vxworks): Use mips/vxworks.h.
	(mips*-*-*elf*):  Use t-elf instead of t-ecoff.
	* configure: Regenerate.

Index: configure.in
===================================================================
RCS file: /cvs/egcs/egcs/gcc/configure.in,v
retrieving revision 1.235
diff -p -r1.235 configure.in
*** configure.in	1999/04/10 22:00:02	1.235
--- configure.in	1999/04/13 02:36:51
*************** changequote([,])dnl
*** 2143,2149 ****
  #		fi
  		;;
  	mips-wrs-vxworks)
! 		tm_file="mips/elf.h libgloss.h"
   		tmake_file=mips/t-ecoff
   		gas=yes
  		gnu_ld=yes
--- 2143,2149 ----
  #		fi
  		;;
  	mips-wrs-vxworks)
! 		tm_file="mips/elf.h libgloss.h mips/vxworks.h"
   		tmake_file=mips/t-ecoff
   		gas=yes
  		gnu_ld=yes
*************** changequote([,])dnl
*** 2562,2602 ****
  		;;
  	mipsel-*-elf*)
  		tm_file="mips/elfl.h libgloss.h"
! 		tmake_file=mips/t-ecoff
  		;;
  	mips-*-elf*)
! 		tm_file="mips/elf.h libgloss.h"
! 		tmake_file=mips/t-ecoff
  		;;
  	mips64el-*-elf*)
! 		tm_file="mips/elfl64.h libgloss.h"
! 		tmake_file=mips/t-ecoff
  		;;
  	mips64orionel-*-elf*)
  		tm_file="mips/elforion.h mips/elfl64.h libgloss.h"
! 		tmake_file=mips/t-ecoff
  		;;
  	mips64-*-elf*)
! 		tm_file="mips/elf64.h libgloss.h"
! 		tmake_file=mips/t-ecoff
  		;;
  	mips64orion-*-elf*)
  		tm_file="mips/elforion.h mips/elf64.h libgloss.h"
! 		tmake_file=mips/t-ecoff
  		;;
  	mips64orion-*-rtems*)
  		tm_file="mips/elforion.h mips/elf64.h mips/rtems64.h"
  		tmake_file="mips/t-ecoff t-rtems"
  		;;
  	mipstx39el-*-elf*)
! 		tm_file="mips/r3900.h mips/elfl.h mips/abi64.h libgloss.h"
  		tmake_file=mips/t-r3900
  		;;
  	mipstx39-*-elf*)
! 		tm_file="mips/r3900.h mips/elf.h mips/abi64.h libgloss.h"
  		tmake_file=mips/t-r3900
- 		# FIXME mips-elf should be fixed to use crtstuff.
- 		use_collect2=yes
  		;;
  	mips-*-*)				# Default MIPS RISC-OS 4.0.
  		if test x$stabs = xyes; then
--- 2562,2600 ----
  		;;
  	mipsel-*-elf*)
  		tm_file="mips/elfl.h libgloss.h"
! 		tmake_file=mips/t-elf
  		;;
  	mips-*-elf*)
! 		tm_file="mips/elf.h"
! 		tmake_file=mips/t-elf
  		;;
  	mips64el-*-elf*)
! 		tm_file="mips/elfl64.h"
! 		tmake_file=mips/t-elf
  		;;
  	mips64orionel-*-elf*)
  		tm_file="mips/elforion.h mips/elfl64.h libgloss.h"
! 		tmake_file=mips/t-elf
  		;;
  	mips64-*-elf*)
! 		tm_file="mips/elf64.h"
! 		tmake_file=mips/t-elf
  		;;
  	mips64orion-*-elf*)
  		tm_file="mips/elforion.h mips/elf64.h libgloss.h"
! 		tmake_file=mips/t-elf
  		;;
  	mips64orion-*-rtems*)
  		tm_file="mips/elforion.h mips/elf64.h mips/rtems64.h"
  		tmake_file="mips/t-ecoff t-rtems"
  		;;
  	mipstx39el-*-elf*)
! 		tm_file="mips/r3900.h mips/elfl.h mips/abi64.h"
  		tmake_file=mips/t-r3900
  		;;
  	mipstx39-*-elf*)
! 		tm_file="mips/r3900.h mips/elf.h mips/abi64.h"
  		tmake_file=mips/t-r3900
  		;;
  	mips-*-*)				# Default MIPS RISC-OS 4.0.
  		if test x$stabs = xyes; then
Index: config/mips/elf.h
===================================================================
RCS file: /cvs/egcs/egcs/gcc/config/mips/elf.h,v
retrieving revision 1.9
diff -p -r1.9 elf.h
*** elf.h	1999/04/07 12:59:53	1.9
--- elf.h	1999/04/13 02:36:57
***************
*** 1,6 ****
  /* Definitions of target machine for GNU compiler.  MIPS R3000 version with
     GOFAST floating point library.
!    Copyright (C) 1994, 1997 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
--- 1,6 ----
  /* Definitions of target machine for GNU compiler.  MIPS R3000 version with
     GOFAST floating point library.
!    Copyright (C) 1994, 1997, 1999 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
*************** do {									   \
*** 232,234 ****
--- 232,328 ----
  									   \
    DECL_SECTION_NAME (DECL) = build_string (len, string);		   \
  } while (0)
+ 
+ /* Support the ctors/dtors and other sections.  */
+  
+ /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
+  
+    Note that we want to give these sections the SHF_WRITE attribute
+    because these sections will actually contain data (i.e. tables of
+    addresses of functions in the current root executable or shared library
+    file) and, in the case of a shared library, the relocatable addresses
+    will have to be properly resolved/relocated (and then written into) by
+    the dynamic linker when it actually attaches the given shared library
+    to the executing process.  (Note that on SVR4, you may wish to use the
+    `-z text' option to the ELF linker, when building a shared library, as
+    an additional check that you are doing everything right.  But if you do
+    use the `-z text' option when building a shared library, you will get
+    errors unless the .ctors and .dtors sections are marked as writable
+    via the SHF_WRITE attribute.)  */
+ 
+ #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
+ #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
+  
+ /* A list of other sections which the compiler might be "in" at any
+    given time.  */
+ #undef EXTRA_SECTIONS
+ #define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
+  
+ #define INVOKE__main
+ #define NAME__MAIN "__gccmain"
+ #define SYMBOL__MAIN __gccmain
+ 
+ #undef EXTRA_SECTION_FUNCTIONS
+ #define EXTRA_SECTION_FUNCTIONS                                         \
+   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
+ 
+ #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                               \
+ void FN ()                                                            \
+ {                                                                     \
+   if (in_section != ENUM)                                             \
+     {                                                                 \
+       fprintf (asm_out_file, "%s\n", OP);                             \
+       in_section = ENUM;                                              \
+     }                                                                 \
+ }
+ 
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global constructors.  */
+ #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                             \
+   do {                                                                \
+     ctors_section ();                                                 \
+     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word");     \
+     assemble_name (FILE, NAME);                                       \
+     fprintf (FILE, "\n");                                             \
+   } while (0)
+ 
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global destructors.  */
+ #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                              \
+   do {                                                                \
+     dtors_section ();                                                 \
+     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word");     \
+     assemble_name (FILE, NAME);                                       \
+     fprintf (FILE, "\n");                                             \
+   } while (0)
+ 
+ #define CTOR_LIST_BEGIN                                 \
+ asm (CTORS_SECTION_ASM_OP);                             \
+ func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
+  
+ #define CTOR_LIST_END                                   \
+ asm (CTORS_SECTION_ASM_OP);                             \
+ func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
+  
+ #define DTOR_LIST_BEGIN                                 \
+ asm (DTORS_SECTION_ASM_OP);                             \
+ func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
+ 
+ #define DTOR_LIST_END                                   \
+ asm (DTORS_SECTION_ASM_OP);                             \
+ func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
+ 
+ /* Don't set the target flags, this is done by the linker script */
+ #undef LIB_SPEC
+ #define LIB_SPEC ""
+ 
+ #undef  STARTFILE_SPEC
+ #define STARTFILE_SPEC "crtbegin%O%s crt0%O%s"
+ 
+ #undef  ENDFILE_SPEC
+ #define ENDFILE_SPEC "crtend%O%s"
Index: config/mips/elf64.h
===================================================================
RCS file: /cvs/egcs/egcs/gcc/config/mips/elf64.h,v
retrieving revision 1.9
diff -p -r1.9 elf64.h
*** elf64.h	1998/12/16 21:08:58	1.9
--- elf64.h	1999/04/13 02:37:03
***************
*** 1,6 ****
  /* Definitions of target machine for GNU compiler.  MIPS R4000 version with
     GOFAST floating point library.
!    Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
--- 1,6 ----
  /* Definitions of target machine for GNU compiler.  MIPS R4000 version with
     GOFAST floating point library.
!    Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
*************** do {									   \
*** 256,258 ****
--- 256,352 ----
  									   \
    DECL_SECTION_NAME (DECL) = build_string (len, string);		   \
  } while (0)
+ 
+ /* Support the ctors/dtors and other sections.  */
+  
+ /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
+  
+    Note that we want to give these sections the SHF_WRITE attribute
+    because these sections will actually contain data (i.e. tables of
+    addresses of functions in the current root executable or shared library
+    file) and, in the case of a shared library, the relocatable addresses
+    will have to be properly resolved/relocated (and then written into) by
+    the dynamic linker when it actually attaches the given shared library
+    to the executing process.  (Note that on SVR4, you may wish to use the
+    `-z text' option to the ELF linker, when building a shared library, as
+    an additional check that you are doing everything right.  But if you do
+    use the `-z text' option when building a shared library, you will get
+    errors unless the .ctors and .dtors sections are marked as writable
+    via the SHF_WRITE attribute.)  */
+ 
+ #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
+ #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
+  
+ /* A list of other sections which the compiler might be "in" at any
+    given time.  */
+ #undef EXTRA_SECTIONS
+ #define EXTRA_SECTIONS in_sdata, in_rdata, in_ctors, in_dtors
+  
+ #define INVOKE__main
+ #define NAME__MAIN "__gccmain"
+ #define SYMBOL__MAIN __gccmain
+ 
+ #undef EXTRA_SECTION_FUNCTIONS
+ #define EXTRA_SECTION_FUNCTIONS                                         \
+   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(ctors_section, in_ctors, CTORS_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(dtors_section, in_dtors, DTORS_SECTION_ASM_OP)
+ 
+ #define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                               \
+ void FN ()                                                            \
+ {                                                                     \
+   if (in_section != ENUM)                                             \
+     {                                                                 \
+       fprintf (asm_out_file, "%s\n", OP);                             \
+       in_section = ENUM;                                              \
+     }                                                                 \
+ }
+ 
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global constructors.  */
+ #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                             \
+   do {                                                                \
+     ctors_section ();                                                 \
+     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word");     \
+     assemble_name (FILE, NAME);                                       \
+     fprintf (FILE, "\n");                                             \
+   } while (0)
+ 
+ 
+ /* A C statement (sans semicolon) to output an element in the table of
+    global destructors.  */
+ #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                              \
+   do {                                                                \
+     dtors_section ();                                                 \
+     fprintf (FILE, "\t%s\t", TARGET_LONG64 ? ".dword" : ".word");     \
+     assemble_name (FILE, NAME);                                       \
+     fprintf (FILE, "\n");                                             \
+   } while (0)
+ 
+ #define CTOR_LIST_BEGIN                                 \
+ asm (CTORS_SECTION_ASM_OP);                             \
+ func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) }
+  
+ #define CTOR_LIST_END                                   \
+ asm (CTORS_SECTION_ASM_OP);                             \
+ func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
+  
+ #define DTOR_LIST_BEGIN                                 \
+ asm (DTORS_SECTION_ASM_OP);                             \
+ func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }
+ 
+ #define DTOR_LIST_END                                   \
+ asm (DTORS_SECTION_ASM_OP);                             \
+ func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
+ 
+ /* Don't set the target flags, this is done by the linker script */
+ #undef LIB_SPEC
+ #define LIB_SPEC ""
+ 
+ #undef  STARTFILE_SPEC
+ #define STARTFILE_SPEC "crtbegin%O%s crt0%O%s"
+ 
+ #undef  ENDFILE_SPEC
+ #define ENDFILE_SPEC "crtend%O%s"
Index: config/mips/linux.h
===================================================================
RCS file: /cvs/egcs/egcs/gcc/config/mips/linux.h,v
retrieving revision 1.2
diff -p -r1.2 linux.h
*** linux.h	1998/12/16 21:09:11	1.2
--- linux.h	1999/04/13 02:37:07
*************** Boston, MA 02111-1307, USA.  */
*** 68,70 ****
--- 68,99 ----
  
  #undef SUBTARGET_ASM_SPEC
  #define SUBTARGET_ASM_SPEC "-KPIC"
+ 
+ /* Undefine the following which were defined in elf.h.  This will cause the linux
+    port to continue to use collect2 for constructors/destructors.  These may be removed
+    when .ctor/.dtor section support is desired. */
+ 
+ #undef CTORS_SECTION_ASM_OP
+ #undef DTORS_SECTION_ASM_OP
+ 
+ #undef EXTRA_SECTIONS
+ #define EXTRA_SECTIONS in_sdata, in_rdata
+ 
+ #undef INVOKE__main
+ #undef NAME__MAIN
+ #undef SYMBOL__MAIN
+ 
+ #undef EXTRA_SECTION_FUNCTIONS
+ #define EXTRA_SECTION_FUNCTIONS                                         \
+   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
+ 
+ #undef ASM_OUTPUT_CONSTRUCTOR
+ #undef ASM_OUTPUT_DESTRUCTOR
+ 
+ #undef CTOR_LIST_BEGIN
+ #undef CTOR_LIST_END
+ #undef DTOR_LIST_BEGIN
+ #undef DTOR_LIST_END
+ 
+ /*  End of undefines to turn off .ctor/.dtor section support */
Index: config/mips/rtems64.h
===================================================================
RCS file: /cvs/egcs/egcs/gcc/config/mips/rtems64.h,v
retrieving revision 1.8
diff -p -r1.8 rtems64.h
*** rtems64.h	1998/12/16 21:09:25	1.8
--- rtems64.h	1999/04/13 02:37:10
***************
*** 1,5 ****
  /* Definitions for rtems targeting a MIPS ORION using ecoff.
!    Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
     Contributed by Joel Sherrill (joel@OARcorp.com).
  
  This file is part of GNU CC.
--- 1,5 ----
  /* Definitions for rtems targeting a MIPS ORION using ecoff.
!    Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
     Contributed by Joel Sherrill (joel@OARcorp.com).
  
  This file is part of GNU CC.
*************** Boston, MA 02111-1307, USA.  */
*** 29,31 ****
--- 29,63 ----
  #ifndef TARGET_MEM_FUNCTIONS
  #define TARGET_MEM_FUNCTIONS
  #endif
+ 
+ /* Undefine the following which were defined in elf64.h.  This will cause the rtems64
+    port to continue to use collect2 for constructors/destructors.  These may be removed
+    when .ctor/.dtor section support is desired. */
+ 
+ #undef CTORS_SECTION_ASM_OP
+ #undef DTORS_SECTION_ASM_OP
+ 
+ #undef EXTRA_SECTIONS
+ #define EXTRA_SECTIONS in_sdata, in_rdata
+ 
+ #undef INVOKE__main
+ #undef NAME__MAIN
+ #undef SYMBOL__MAIN
+ 
+ #undef EXTRA_SECTION_FUNCTIONS
+ #define EXTRA_SECTION_FUNCTIONS                                         \
+   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
+ 
+ #undef ASM_OUTPUT_CONSTRUCTOR
+ #undef ASM_OUTPUT_DESTRUCTOR
+ 
+ #undef CTOR_LIST_BEGIN
+ #undef CTOR_LIST_END
+ #undef DTOR_LIST_BEGIN
+ #undef DTOR_LIST_END
+ 
+ #undef STARTFILE_SPEC
+ #undef ENDFILE_SPEC
+ 
+ /*  End of undefines to turn off .ctor/.dtor section support */
Index: config/mips/t-r3900
===================================================================
RCS file: /cvs/egcs/egcs/gcc/config/mips/t-r3900,v
retrieving revision 1.2
diff -p -r1.2 t-r3900
*** t-r3900	1998/12/16 21:09:42	1.2
--- t-r3900	1999/04/13 02:37:14
*************** fp-bit.c: $(srcdir)/config/fp-bit.c
*** 49,54 ****
--- 49,58 ----
  	echo '#define US_SOFTWARE_GOFAST' >> fp-bit.c
  	cat $(srcdir)/config/fp-bit.c >> fp-bit.c
  
+ EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
+ # Don't let CTOR_LIST end up in sdata section.
+ CRTSTUFF_T_CFLAGS = -G 0
+ 
  # Build the libraries for both hard and soft floating point
  
  MULTILIB_OPTIONS = msoft-float/msingle-float EL/EB
Index: config/mips/vxworks.h
===================================================================
RCS file: vxworks.h
diff -N vxworks.h
*** /dev/null	Sat Dec  5 20:30:03 1998
--- vxworks.h	Mon Apr 12 19:37:17 1999
***************
*** 0 ****
--- 1,50 ----
+ /* Copyright (C) 1999 Free Software Foundation, Inc. */
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+ 
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ /* Undefine the following which were defined in elf.h.  Thise will cause the mips-vxworks
+    port to continue to use collect2 for constructors/destructors.  This entire file may
+    be removed when .ctor/.dtor section support is desired. */
+ 
+ #undef CTORS_SECTION_ASM_OP
+ #undef DTORS_SECTION_ASM_OP
+ 
+ #undef EXTRA_SECTIONS
+ #define EXTRA_SECTIONS in_sdata, in_rdata
+ 
+ #undef INVOKE__main
+ #undef NAME__MAIN
+ #undef SYMBOL__MAIN
+ 
+ #undef EXTRA_SECTION_FUNCTIONS
+ #define EXTRA_SECTION_FUNCTIONS                                         \
+   SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+   SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
+ 
+ #undef ASM_OUTPUT_CONSTRUCTOR
+ #undef ASM_OUTPUT_DESTRUCTOR
+ 
+ #undef CTOR_LIST_BEGIN
+ #undef CTOR_LIST_END
+ #undef DTOR_LIST_BEGIN
+ #undef DTOR_LIST_END
+ 
+ #undef STARTFILE_SPEC
+ #undef ENDFILE_SPEC
+ 
+ /*  End of undefines to turn off .ctor/.dtor section support */
Index: config/mips/t-elf
===================================================================
RCS file: t-elf
diff -N t-elf
*** /dev/null	Sat Dec  5 20:30:03 1998
--- t-elf	Mon Apr 12 19:37:22 1999
***************
*** 0 ****
--- 1,96 ----
+ CONFIG2_H	= $(srcdir)/config/mips/ecoff.h
+ 
+ # We have a premade insn-attrtab.c to save the hour it takes to run genattrtab.
+ # PREMADE_ATTRTAB = $(srcdir)/config/mips/mips-at.c
+ # PREMADE_ATTRTAB_MD = $(srcdir)/config/mips/mips-at.md
+ 
+ # Suppress building libgcc1.a, since the MIPS compiler port is complete
+ # and does not need anything from libgcc1.a.
+ LIBGCC1 =
+ 
+ EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
+ # Don't let CTOR_LIST end up in sdata section.
+ CRTSTUFF_T_CFLAGS = -G 0
+ 
+ # When building a cross compiler, put the mips16 support functions in
+ # libgcc1.a.
+ CROSS_LIBGCC1 = libgcc1-asm.a
+ LIB1ASMSRC = mips/mips16.S
+ LIB1ASMFUNCS = _m16addsf3 _m16subsf3 _m16mulsf3 _m16divsf3 \
+ 	_m16eqsf2 _m16nesf2 _m16gtsf2 _m16gesf2 _m16lesf2 _m16ltsf2 \
+ 	_m16fltsisf _m16fixsfsi \
+ 	_m16adddf3 _m16subdf3 _m16muldf3 _m16divdf3 \
+ 	_m16extsfdf2 _m16trdfsf2 \
+ 	_m16eqdf2 _m16nedf2 _m16gtdf2 _m16gedf2 _m16ledf2 _m16ltdf2 \
+ 	_m16fltsidf _m16fixdfsi \
+ 	_m16retsf _m16retdf \
+ 	_m16stub1 _m16stub2 _m16stub5 _m16stub6 _m16stub9 _m16stub10 \
+ 	_m16stubsf0 _m16stubsf1 _m16stubsf2 _m16stubsf5 _m16stubsf6 \
+ 	_m16stubsf9 _m16stubsf10 \
+ 	_m16stubdf0 _m16stubdf1 _m16stubdf2 _m16stubdf5 _m16stubdf6 \
+ 	_m16stubdf9 _m16stubdf10
+ 
+ # We must build libgcc2.a with -G 0, in case the user wants to link
+ # without the $gp register.
+ TARGET_LIBGCC2_CFLAGS = -G 0
+ 
+ # fp-bit and dp-bit are really part of libgcc1, but this will cause
+ # them to be built correctly, so... [taken from t-sparclite]
+ LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
+ 
+ dp-bit.c: $(srcdir)/config/fp-bit.c
+ 	echo '#ifdef __MIPSEL__' > dp-bit.c
+ 	echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
+ 	echo '#endif' >> dp-bit.c
+ 	echo '#define US_SOFTWARE_GOFAST' >> dp-bit.c
+ 	cat $(srcdir)/config/fp-bit.c >> dp-bit.c
+ 
+ fp-bit.c: $(srcdir)/config/fp-bit.c
+ 	echo '#define FLOAT' > fp-bit.c
+ 	echo '#ifdef __MIPSEL__' >> fp-bit.c
+ 	echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
+ 	echo '#endif' >> fp-bit.c
+ 	echo '#define US_SOFTWARE_GOFAST' >> fp-bit.c
+ 	cat $(srcdir)/config/fp-bit.c >> fp-bit.c
+ 
+ # Build the libraries for both hard and soft floating point
+ 
+ MULTILIB_OPTIONS = msoft-float/msingle-float EL/EB mips1/mips3
+ MULTILIB_DIRNAMES = soft-float single el eb mips1 mips3
+ MULTILIB_MATCHES = msingle-float=m4650
+ 
+ LIBGCC = stmp-multilib
+ INSTALL_LIBGCC = install-multilib
+ 
+ # Add additional dependencies to recompile selected modules whenever the
+ # tm.h file changes.  The files compiled are:
+ #
+ #	gcc.c		(*_SPEC changes)
+ #	toplev.c	(new switches + assembly output changes)
+ #	sdbout.c	(debug format changes)
+ #	dbxout.c	(debug format changes)
+ #	dwarfout.c	(debug format changes)
+ #	final.c		(assembly output changes)
+ #	varasm.c	(assembly output changes)
+ #	cse.c		(cost functions)
+ #	insn-output.c	(possible ifdef changes in tm.h)
+ #	regclass.c	(fixed/call used register changes)
+ #	cccp.c		(new preprocessor macros, -v version #)
+ #	explow.c	(GO_IF_LEGITIMATE_ADDRESS)
+ #	recog.c		(GO_IF_LEGITIMATE_ADDRESS)
+ #	reload.c	(GO_IF_LEGITIMATE_ADDRESS)
+ 
+ gcc.o: $(CONFIG2_H)
+ toplev.o: $(CONFIG2_H)
+ sdbout.o: $(CONFIG2_H)
+ dbxout.o: $(CONFIG2_H)
+ dwarfout.o: $(CONFIG2_H)
+ final.o: $(CONFIG2_H)
+ varasm.o: $(CONFIG2_H)
+ cse.o: $(CONFIG2_H)
+ insn-output.o: $(CONFIG2_H)
+ regclass.o: $(CONFIG2_H)
+ cccp.o: $(CONFIG2_H)
+ explow.o: $(CONFIG2_H)
+ recog.o: $(CONFIG2_H)
+ reload.o: $(CONFIG2_H)


 -- Sample linker script changes required to support ctor/dtor

Index: idt.ld
===================================================================
RCS file: /cvs/cvsfiles/devo/libgloss/mips/idt.ld,v
retrieving revision 1.8
diff -p -r1.8 idt.ld
*** idt.ld	1997/09/08 18:46:20	1.8
--- idt.ld	1999/02/04 19:02:22
*************** SECTIONS
*** 44,49 ****
--- 44,65 ----
       etext  =  .;
       _etext  =  .;
    }
+   .ctors         :
+   {
+     ___ctors = .;
+     KEEP(*crtbegin.o(.ctors))
+     KEEP(*(SORT(.ctors.*)))
+     KEEP(*(.ctors))
+     ___ctors_end = .;
+   }
+   .dtors         :
+   {
+     ___dtors = .;
+     KEEP(*crtbegin.o(.dtors))
+     KEEP(*(SORT(.dtors.*)))
+     KEEP(*(.dtors))
+     ___dtors_end = .;
+   }
    . = .;
    .rdata : {
      *(.rdata)
*************** SECTIONS
*** 51,57 ****
     _fdata = ALIGN(16);
    .data : {
      *(.data)
-     CONSTRUCTORS
    }
    . = ALIGN(8);
    _gp = . + 0x8000;
--- 67,72 ----


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