OSDN Git Service

* varasm.c (text_section): Allow TEXT_SECTION to override the
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Aug 2001 18:57:51 +0000 (18:57 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 17 Aug 2001 18:57:51 +0000 (18:57 +0000)
        printing of TEXT_SECTION_ASM_OP.
        * dwarf2out.c (TEXT_SECTION_NAME): Rename from TEXT_SECTION.
        (DATA_SECTION, BSS_SECTION): Remove.
        * dwarfout.c (TEXT_SECTION_NAME, DATA_SECTION_NAME, DATA1_SECTION_NAME,
        RODATA_SECTION_NAME, RODATA1_SECTION_NAME, BSS_SECTION_NAME):
        Rename from s/_NAME//.
        * config/mips/mips.h (TARGET_FILE_SWITCHING): Add !TARGET_MIPS16.
        (ASM_DECLARE_FUNCTION_NAME): Move file switching ...
        (TEXT_SECTION): ... here.  New.
        * config/mips/elf.h (TEXT_SECTION): New; no file switching.
        * config/mips/elf64.h, config/mips/netbsd.h: Likewise.
        * config/mips/openbsd.h: Likewise.
        * config/mips/mips.c (mips_asm_file_start): Tidy file switching test.
        (mips_asm_file_end): Likewise test.
        (mips_output_function_epilogue): Likewise.  Switch back to data
        section after emitting the function.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44973 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/mips/elf.h
gcc/config/mips/elf64.h
gcc/config/mips/mips.c
gcc/config/mips/mips.h
gcc/config/mips/netbsd.h
gcc/config/mips/openbsd.h
gcc/dwarf2out.c
gcc/dwarfout.c
gcc/varasm.c

index 65578bc..c7c7cf4 100644 (file)
@@ -1,5 +1,25 @@
 2001-08-17  Richard Henderson  <rth@redhat.com>
 
+       * varasm.c (text_section): Allow TEXT_SECTION to override the
+       printing of TEXT_SECTION_ASM_OP.
+       * dwarf2out.c (TEXT_SECTION_NAME): Rename from TEXT_SECTION.
+       (DATA_SECTION, BSS_SECTION): Remove.
+       * dwarfout.c (TEXT_SECTION_NAME, DATA_SECTION_NAME, DATA1_SECTION_NAME,
+       RODATA_SECTION_NAME, RODATA1_SECTION_NAME, BSS_SECTION_NAME):
+       Rename from s/_NAME//.
+       * config/mips/mips.h (TARGET_FILE_SWITCHING): Add !TARGET_MIPS16.
+       (ASM_DECLARE_FUNCTION_NAME): Move file switching ...
+       (TEXT_SECTION): ... here.  New.
+       * config/mips/elf.h (TEXT_SECTION): New; no file switching.
+       * config/mips/elf64.h, config/mips/netbsd.h: Likewise.
+       * config/mips/openbsd.h: Likewise.
+       * config/mips/mips.c (mips_asm_file_start): Tidy file switching test.
+       (mips_asm_file_end): Likewise test.
+       (mips_output_function_epilogue): Likewise.  Switch back to data
+       section after emitting the function.
+
+2001-08-17  Richard Henderson  <rth@redhat.com>
+
        * dwarf2out.c (dwarf2out_init): Don't emit .debug_loc label here.
        (dwarf2out_finish): Do it here.  Emit .debug_loc before .debug_info.
 
index aa094b6..7408704 100644 (file)
@@ -60,6 +60,19 @@ do {                                                 \
 #undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
 
+/* Given that Irix has it's own headers, not having TARGET_GAS here
+   seems a mistake.  If we actually need to be prepared for file
+   switching, then we need a custom TARGET_ASM_NAMED_SECTION too.  */
+
+#undef TEXT_SECTION
+#define TEXT_SECTION()
+do {
+  if (TARGET_FILE_SWITCHING)
+    abort ();
+  fputs (TEXT_SECTION_ASM_OP, asm_out_file);
+  fputc ('\n', asm_out_file);
+} while (0)
+
 /* The following macro defines the format used to output the second
    operand of the .type assembler directive.  Different svr4 assemblers
    expect various different forms for this operand.  The one given here
index c9bcd3e..c218c37 100644 (file)
@@ -77,6 +77,19 @@ do {                                                 \
 #undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
 
+/* Given that Irix has it's own headers, not having TARGET_GAS here
+   seems a mistake.  If we actually need to be prepared for file
+   switching, then we need a custom TARGET_ASM_NAMED_SECTION too.  */
+
+#undef TEXT_SECTION
+#define TEXT_SECTION()
+do {
+  if (TARGET_FILE_SWITCHING)
+    abort ();
+  fputs (TEXT_SECTION_ASM_OP, asm_out_file);
+  fputc ('\n', asm_out_file);
+} while (0)
+
 /* The following macro defines the format used to output the second
    operand of the .type assembler directive.  Different svr4 assemblers
    expect various different forms for this operand.  The one given here
index 5e85160..68d9e53 100644 (file)
@@ -6053,7 +6053,7 @@ mips_asm_file_start (stream)
   /* This code exists so that we can put all externs before all symbol
      references.  This is necessary for the MIPS assembler's global pointer
      optimizations to work.  */
-  if (TARGET_FILE_SWITCHING && ! TARGET_MIPS16)
+  if (TARGET_FILE_SWITCHING)
     {
       asm_out_data_file = stream;
       asm_out_text_file = mips_make_temp_file ();
@@ -6113,7 +6113,7 @@ mips_asm_file_end (file)
        }
     }
 
-  if (TARGET_FILE_SWITCHING && ! TARGET_MIPS16)
+  if (TARGET_FILE_SWITCHING)
     {
       fprintf (file, "\n\t.text\n");
       rewind (asm_out_text_file);
@@ -7472,9 +7472,11 @@ mips_output_function_epilogue (file, size)
   /* Restore the output file if optimizing the GP (optimizing the GP causes
      the text to be diverted to a tempfile, so that data decls come before
      references to the data).  */
-
-  if (TARGET_GP_OPT && ! TARGET_MIPS16 && ! TARGET_GAS)
-    asm_out_file = asm_out_data_file;
+  if (TARGET_FILE_SWITCHING)
+    {
+      asm_out_file = asm_out_data_file;
+      data_section ();
+    }
 }
 \f
 /* Expand the epilogue into a bunch of separate insns.  */
index c441198..d86cf1c 100644 (file)
@@ -319,7 +319,8 @@ extern void         sbss_section PARAMS ((void));
 /* This is true if we must enable the assembly language file switching
    code.  */
 
-#define TARGET_FILE_SWITCHING  (TARGET_GP_OPT && ! TARGET_GAS)
+#define TARGET_FILE_SWITCHING \
+  (TARGET_GP_OPT && ! TARGET_GAS && ! TARGET_MIPS16)
 
 /* We must disable the function end stabs when doing the file switching trick,
    because the Lscope stabs end up in the wrong place, making it impossible
@@ -4215,32 +4216,27 @@ while (0)
 #define ASM_FILE_END(STREAM) mips_asm_file_end(STREAM)
 
 
+/* Play switch file games if we're optimizing the global pointer.  */
+
+#undef TEXT_SECTION
+#define TEXT_SECTION()                                 \
+do {                                                   \
+  extern FILE *asm_out_text_file;                      \
+  if (TARGET_FILE_SWITCHING)                           \
+    asm_out_file = asm_out_text_file;                  \
+  fputs (TEXT_SECTION_ASM_OP, asm_out_file);           \
+  fputc ('\n', asm_out_file);                          \
+} while (0)
+
+
 /* This is how to declare a function name.  The actual work of
    emitting the label is moved to function_prologue, so that we can
    get the line number correctly emitted before the .ent directive,
-   and after any .file directives.
-
-   Also, switch files if we are optimizing the global pointer.  */
+   and after any .file directives.  */
 
 #undef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)                    \
-{                                                                      \
-  extern FILE *asm_out_text_file;                                      \
-  if (TARGET_GP_OPT && ! TARGET_MIPS16)                                        \
-    {                                                                  \
-      STREAM = asm_out_text_file;                                      \
-      /* ??? text_section gets called too soon.  If the previous       \
-        function is in a special section and we're not, we have        \
-        to switch back to the text section.  We can't call             \
-        text_section again as gcc thinks we're already there.  */      \
-      /* ??? See varasm.c.  There are other things that get output     \
-        too early, like alignment (before we've switched STREAM).  */  \
-      if (DECL_SECTION_NAME (DECL) == NULL_TREE)                       \
-       fprintf (STREAM, "%s\n", TEXT_SECTION_ASM_OP);                  \
-    }                                                                  \
-                                                                       \
-  HALF_PIC_DECLARE (NAME);                                             \
-}
+#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)    \
+  HALF_PIC_DECLARE (NAME)
 
 /* This is how to output an internal numbered label where
    PREFIX is the class of label and NUM is the number within the class.  */
index 13e7b08..cdb8037 100644 (file)
@@ -205,6 +205,19 @@ do {                                                                        \
 #undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
 
+/* Not having TARGET_GAS here seems a mistake.  If we actually need to
+   be prepared for file switching, then we need a custom
+   TARGET_ASM_NAMED_SECTION too.  */
+
+#undef TEXT_SECTION
+#define TEXT_SECTION()
+do {
+  if (TARGET_FILE_SWITCHING)
+    abort ();
+  fputs (TEXT_SECTION_ASM_OP, asm_out_file);
+  fputc ('\n', asm_out_file);
+} while (0)
+
 /* Since gas and gld are standard on NetBSD, we don't need these */
 #undef ASM_FINAL_SPEC
 #undef STARTFILE_SPEC
index e4847ce..886c229 100644 (file)
@@ -107,6 +107,19 @@ Boston, MA 02111-1307, USA.  */
 #undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
 
+/* Not having TARGET_GAS here seems a mistake.  If we actually need to
+   be prepared for file switching, then we need a custom
+   TARGET_ASM_NAMED_SECTION too.  */
+
+#undef TEXT_SECTION
+#define TEXT_SECTION()
+do {
+  if (TARGET_FILE_SWITCHING)
+    abort ();
+  fputs (TEXT_SECTION_ASM_OP, asm_out_file);
+  fputc ('\n', asm_out_file);
+} while (0)
+
 /* collect2 support (Macros for initialization).  */
 
 /* Mips default configuration is COFF-only, and confuses collect2.  */
index 30cf072..cc1de94 100644 (file)
@@ -3647,14 +3647,8 @@ static char *gen_internal_sym            PARAMS ((const char *));
 #endif
 
 /* Standard ELF section names for compiled code and data.  */
-#ifndef TEXT_SECTION
-#define TEXT_SECTION           ".text"
-#endif
-#ifndef DATA_SECTION
-#define DATA_SECTION           ".data"
-#endif
-#ifndef BSS_SECTION
-#define BSS_SECTION            ".bss"
+#ifndef TEXT_SECTION_NAME
+#define TEXT_SECTION_NAME      ".text"
 #endif
 
 /* Labels we insert at beginning sections we can reference instead of
@@ -11688,7 +11682,7 @@ dwarf2out_init (main_input_filename)
   if (DWARF2_GENERATE_TEXT_SECTION_LABEL)
     ASM_GENERATE_INTERNAL_LABEL (text_section_label, TEXT_SECTION_LABEL, 0);
   else
-    strcpy (text_section_label, stripattributes (TEXT_SECTION));
+    strcpy (text_section_label, stripattributes (TEXT_SECTION_NAME));
   ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label,
                               DEBUG_INFO_SECTION_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label,
index 057dee2..5c8b8bc 100644 (file)
@@ -1006,23 +1006,23 @@ static void retry_incomplete_types      PARAMS ((void));
 #ifndef DEBUG_ARANGES_SECTION
 #define DEBUG_ARANGES_SECTION  ".debug_aranges"
 #endif
-#ifndef TEXT_SECTION
-#define TEXT_SECTION           ".text"
+#ifndef TEXT_SECTION_NAME
+#define TEXT_SECTION_NAME      ".text"
 #endif
-#ifndef DATA_SECTION
-#define DATA_SECTION           ".data"
+#ifndef DATA_SECTION_NAME
+#define DATA_SECTION_NAME      ".data"
 #endif
-#ifndef DATA1_SECTION
-#define DATA1_SECTION          ".data1"
+#ifndef DATA1_SECTION_NAME
+#define DATA1_SECTION_NAME     ".data1"
 #endif
-#ifndef RODATA_SECTION
-#define RODATA_SECTION         ".rodata"
+#ifndef RODATA_SECTION_NAME
+#define RODATA_SECTION_NAME    ".rodata"
 #endif
-#ifndef RODATA1_SECTION
-#define RODATA1_SECTION                ".rodata1"
+#ifndef RODATA1_SECTION_NAME
+#define RODATA1_SECTION_NAME   ".rodata1"
 #endif
-#ifndef BSS_SECTION
-#define BSS_SECTION            ".bss"
+#ifndef BSS_SECTION_NAME
+#define BSS_SECTION_NAME       ".bss"
 #endif
 \f
 /* Definitions of defaults for formats and names of various special
@@ -6326,14 +6326,14 @@ dwarfout_init (main_input_filename)
   /* Output a starting label for the .text section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   /* Output a starting label for the .data section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -6341,7 +6341,7 @@ dwarfout_init (main_input_filename)
   /* Output a starting label for the .data1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -6349,7 +6349,7 @@ dwarfout_init (main_input_filename)
   /* Output a starting label for the .rodata section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -6357,7 +6357,7 @@ dwarfout_init (main_input_filename)
   /* Output a starting label for the .rodata1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -6365,7 +6365,7 @@ dwarfout_init (main_input_filename)
   /* Output a starting label for the .bss section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -6523,14 +6523,14 @@ dwarfout_finish (main_input_filename)
   /* Output a terminator label for the .text section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   /* Output a terminator label for the .data section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -6538,7 +6538,7 @@ dwarfout_finish (main_input_filename)
   /* Output a terminator label for the .data1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -6546,7 +6546,7 @@ dwarfout_finish (main_input_filename)
   /* Output a terminator label for the .rodata section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -6554,7 +6554,7 @@ dwarfout_finish (main_input_filename)
   /* Output a terminator label for the .rodata1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -6562,7 +6562,7 @@ dwarfout_finish (main_input_filename)
   /* Output a terminator label for the .bss section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
index 8b752dc..c3a6322 100644 (file)
@@ -233,7 +233,11 @@ text_section ()
 {
   if (in_section != in_text)
     {
+#ifdef TEXT_SECTION
+      TEXT_SECTION ();
+#else
       fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
+#endif
       in_section = in_text;
     }
 }