[committed] PA section handling

John David Anglin dave@hiauly1.hia.nrc.ca
Mon Dec 12 17:28:00 GMT 2005


The enclosed change fixes a number os issues with section handling
on the trunk.

1) It fixes PR target/25258.  This was a problem in the sequencing of
   debug information.
2) We need to output the assembler code for COMDAT subspaces even when
   we are already in the section.
3) Plabels can go in readonly data when not generating PIC code.

Tested on hppa2.0w-hp-hpux11.11 and hppa-unknown-linux-gnu.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2005-12-12  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR target/25258
	* pa.c (pa_output_function_epilogue): Set cfun->machine->in_nsubspa to
	indicate function epilogue has been output.
	(pa_asm_output_mi_thunk): Likewise.
	(output_deferred_plabels): Put plabels in readonly data section when
	not generating PIC code.
	(som_output_text_section_asm_op): Use .NSUBSPA to output debug
	information.  Add assert.
	(som_output_comdat_data_section_asm_op): New function.
	(pa_som_asm_init_sections): Use som_output_comdat_data_section_asm_op
	instead of output_section_asm_op for COMDAT sections.

Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 108357)
+++ config/pa/pa.c	(working copy)
@@ -3935,6 +3935,7 @@
 	 debug information.  Forget that we are in this subspace to ensure
 	 that the next function is output in its own subspace.  */
       in_section = NULL;
+      cfun->machine->in_nsubspa = 2;
     }
 
   if (INSN_ADDRESSES_SET_P ())
@@ -5300,12 +5301,13 @@
 output_deferred_plabels (void)
 {
   size_t i;
-  /* If we have deferred plabels, then we need to switch into the data
-     section and align it to a 4 byte boundary before we output the
-     deferred plabels.  */
+
+  /* If we have some deferred plabels, then we need to switch into the
+     data or readonly data section, and align it to a 4 byte boundary
+     before outputing the deferred plabels.  */
   if (n_deferred_plabels)
     {
-      switch_to_section (data_section);
+      switch_to_section (flag_pic ? data_section : readonly_data_section);
       ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2);
     }
 
@@ -7799,6 +7801,15 @@
 
   fprintf (file, "\t.EXIT\n\t.PROCEND\n");
 
+  if (TARGET_SOM && TARGET_GAS)
+    {
+      /* We done with this subspace except possibly for some additional
+	 debug information.  Forget that we are in this subspace to ensure
+	 that the next function is output in its own subspace.  */
+      in_section = NULL;
+      cfun->machine->in_nsubspa = 2;
+    }
+
   if (TARGET_SOM && flag_pic && TREE_PUBLIC (function))
     {
       switch_to_section (data_section);
@@ -7806,8 +7817,6 @@
       ASM_OUTPUT_LABEL (file, label);
       output_asm_insn (".word P'%0", xoperands);
     }
-  else if (TARGET_SOM && TARGET_GAS)
-    in_section = NULL;
 
   current_thunk_number++;
   nbytes = ((nbytes + FUNCTION_BOUNDARY / BITS_PER_UNIT - 1)
@@ -9058,27 +9067,39 @@
 	  if (cfun->decl
 	      && DECL_ONE_ONLY (cfun->decl)
 	      && !DECL_WEAK (cfun->decl))
-	    output_section_asm_op ("\t.SPACE $TEXT$\n"
-				   "\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,"
-				   "ACCESS=44,SORT=24,COMDAT");
-	  else
-	    output_section_asm_op ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$");
-	  return;
+	    {
+	      output_section_asm_op ("\t.SPACE $TEXT$\n"
+				     "\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,"
+				     "ACCESS=44,SORT=24,COMDAT");
+	      return;
+	    }
 	}
       else
 	{
 	  /* There isn't a current function or the body of the current
 	     function has been completed.  So, we are changing to the
-	     text section to output debugging information.  Do this in
-	     the default text section.  We need to forget that we are
-	     in the text section so that varasm.c will call us when
-	     text_section is selected again.  */
+	     text section to output debugging information.  Thus, we
+	     need to forget that we are in the text section so that
+	     varasm.c will call us when text_section is selected again.  */
+	  gcc_assert (!cfun || cfun->machine->in_nsubspa == 2);
 	  in_section = NULL;
 	}
+      output_section_asm_op ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$");
+      return;
     }
   output_section_asm_op ("\t.SPACE $TEXT$\n\t.SUBSPA $CODE$");
 }
 
+/* A get_unnamed_section callback for switching to comdat data
+   sections.  This function is only used with SOM.  */
+
+static void
+som_output_comdat_data_section_asm_op (const void *data)
+{
+  in_section = NULL;
+  output_section_asm_op (data);
+}
+
 /* Implement TARGET_ASM_INITIALIZE_SECTIONS  */
 
 static void
@@ -9097,7 +9118,7 @@
      data one-only by creating a new $LIT$ subspace in $TEXT$ with
      the comdat flag.  */
   som_one_only_readonly_data_section
-    = get_unnamed_section (0, output_section_asm_op,
+    = get_unnamed_section (0, som_output_comdat_data_section_asm_op,
 			   "\t.SPACE $TEXT$\n"
 			   "\t.NSUBSPA $LIT$,QUAD=0,ALIGN=8,"
 			   "ACCESS=0x2c,SORT=16,COMDAT");
@@ -9106,7 +9127,8 @@
   /* When secondary definitions are not supported, SOM makes data one-only
      by creating a new $DATA$ subspace in $PRIVATE$ with the comdat flag.  */
   som_one_only_data_section
-    = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
+    = get_unnamed_section (SECTION_WRITE,
+			   som_output_comdat_data_section_asm_op,
 			   "\t.SPACE $PRIVATE$\n"
 			   "\t.NSUBSPA $DATA$,QUAD=1,ALIGN=8,"
 			   "ACCESS=31,SORT=24,COMDAT");



More information about the Gcc-patches mailing list