[committed] Remove init_section and fini_section

Richard Sandiford richard@codesourcery.com
Sat Dec 10 00:32:00 GMT 2005


My recent section patch caused a bootstrap failure on hppa64-hpux11.*.
The problem was caused by an empty definition of INIT_SECTION_ASM_OP
in pa64-hpux.h:

------------------------------------------------------------------------
/* Since HP uses the .init and .fini sections for array initializers
   and finalizers, we need different defines for INIT_SECTION_ASM_OP
   and FINI_SECTION_ASM_OP.  With the implementation adopted below,
   the sections are not actually used.  However, we still must provide
   defines to select the proper code path.  */
#undef INIT_SECTION_ASM_OP
#define INIT_SECTION_ASM_OP
#undef FINI_SECTION_ASM_OP
#define FINI_SECTION_ASM_OP
------------------------------------------------------------------------

This conflicted with the new varasm.c code:

------------------------------------------------------------------------
#ifdef INIT_SECTION_ASM_OP
  init_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
                                      INIT_SECTION_ASM_OP);
#endif

#ifdef FINI_SECTION_ASM_OP
  fini_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
                                      FINI_SECTION_ASM_OP);
#endif
------------------------------------------------------------------------

However, I was misled by the old output.h declarations:

------------------------------------------------------------------------
#ifdef INIT_SECTION_ASM_OP
extern void init_section (void);
#endif

#ifdef FINI_SECTION_ASM_OP
extern void fini_section (void);
#endif
------------------------------------------------------------------------

and the associated function definitions in some ports' EXTRA_SECTIONS.
It turns out that, although these functions were sometimes defined,
they were never actually used.  I've therefore removed their variable
equivalents in the patch below.

Bootstrapped & regression tested on i686-pc-linux-gnu.  Joseph also
confirms that it fixes the hppa64 failure (thanks!).  Installed as
obvious.

Richard


	* output.h (init_section, fini_section): Delete.
	* varasm.c (init_section, fini_section): Delete.
	(init_varasm_once): Don't initialize them.
	* doc/tm.texi (INIT_SECTION_ASM_OP, FINI_SECTION_ASM_OP): Say that
	there are no corresponding varasm.c variables.

Index: gcc/output.h
===================================================================
--- gcc/output.h	(revision 108276)
+++ gcc/output.h	(working copy)
@@ -501,8 +501,6 @@ extern GTY(()) section *ctors_section;
 extern GTY(()) section *dtors_section;
 extern GTY(()) section *bss_section;
 extern GTY(()) section *sbss_section;
-extern GTY(()) section *init_section;
-extern GTY(()) section *fini_section;
 extern GTY(()) section *exception_section;
 extern GTY(()) section *eh_frame_section;
 
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 108276)
+++ gcc/varasm.c	(working copy)
@@ -152,8 +152,6 @@ static void mark_weak (tree);
 section *dtors_section;
 section *bss_section;
 section *sbss_section;
-section *init_section;
-section *fini_section;
 
 /* The section that holds the main exception table.  */
 section *exception_section;
@@ -4854,16 +4852,6 @@ init_varasm_once (void)
 				      SBSS_SECTION_ASM_OP);
 #endif
 
-#ifdef INIT_SECTION_ASM_OP
-  init_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
-				      INIT_SECTION_ASM_OP);
-#endif
-
-#ifdef FINI_SECTION_ASM_OP
-  fini_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,
-				      FINI_SECTION_ASM_OP);
-#endif
-
   targetm.asm_out.init_sections ();
 
   if (readonly_data_section == NULL)
Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi	(revision 108276)
+++ gcc/doc/tm.texi	(working copy)
@@ -5994,14 +5994,16 @@ uninitialized, writable small data.
 If defined, a C expression whose value is a string, including spacing,
 containing the assembler operation to identify the following data as
 initialization code.  If not defined, GCC will assume such a section does
-not exist.
+not exist.  This section has no corresponding @code{init_section}
+variable; it is used entirely in runtime code.
 @end defmac
 
 @defmac FINI_SECTION_ASM_OP
 If defined, a C expression whose value is a string, including spacing,
 containing the assembler operation to identify the following data as
 finalization code.  If not defined, GCC will assume such a section does
-not exist.
+not exist.  This section has no corresponding @code{fini_section}
+variable; it is used entirely in runtime code.
 @end defmac
 
 @defmac INIT_ARRAY_SECTION_ASM_OP



More information about the Gcc-patches mailing list