re PR target/10913 (mips-elf ICE in text_section at varasm.c: 241)
authorRichard Sandiford <rsandifo@redhat.com>
Mon, 9 Jun 2003 06:55:15 +0000 (06:55 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 9 Jun 2003 06:55:15 +0000 (06:55 +0000)
PR target/10913
* config/mips/mips.h (TARGET_FILE_SWITCHING, NO_DBX_FUNCTION_END,
PUT_SDB_SCL, PUT_SDB_INT_VAL, PUT_SDB_VAL, PUT_SDB_ENDEF,
PUT_SDB_TYPE, PUT_SDB_SIZE, PUT_SDB_DIM, PUT_SDB_START_DIM,
PUT_SDB_NEXT_DIM, PUT_SDB_LAST_DIM, PUT_SDB_TAG, PUT_SDB_SRC_FILE,
SDB_GENERATE_FAKE, TEXT_SECTION): Delete.
(PUT_SDB_DEF, PUT_SDB_PLAIN_DEF, PUT_SDB_BLOCK_START,
PUT_SDB_BLOCK_END, PUT_SDB_FUNCTION_END): Replace use of
asm_out_text_file with asm_out_file.
* config/mips/iris5gas.h (PUT_SDB_SIZE, PUT_SDB_TYPE): Likewise.
* config/mips/elf.h (TEXT_SECTION): Undefine.
* config/mips/elf64.h (TEXT_SECION): Undefine.
* config/mips/openbsd.h (TEXT_SECION): Undefine.
* config/mips/mips.c (asm_out_text_file, asm_out_data_file): Delete.
(override_options): Disable small-data optimizations unless using
gas or explicit relocations.
(mips_asm_file_start, mips_asm_file_end, mips_output_function_epilogue,
iris6_asm_named_section, iris6_asm_file_start): Remove code for
handling TARGET_FILE_SWITCHING.
(copy_file_data): Move into TARGET_IRIX6 block.

From-SVN: r67653

gcc/ChangeLog
gcc/config/mips/elf.h
gcc/config/mips/elf64.h
gcc/config/mips/iris5gas.h
gcc/config/mips/mips.c
gcc/config/mips/mips.h
gcc/config/mips/openbsd.h

index 23a4ae54f5ec31e3ef55e927d5d044b9643ca479..da62392af1c0ac4bd450016c41df257922adf65c 100644 (file)
@@ -1,3 +1,26 @@
+2003-06-09  Richard Sandiford  <rsandifo@redhat.com>
+
+       PR target/10913
+       * config/mips/mips.h (TARGET_FILE_SWITCHING, NO_DBX_FUNCTION_END,
+       PUT_SDB_SCL, PUT_SDB_INT_VAL, PUT_SDB_VAL, PUT_SDB_ENDEF,
+       PUT_SDB_TYPE, PUT_SDB_SIZE, PUT_SDB_DIM, PUT_SDB_START_DIM,
+       PUT_SDB_NEXT_DIM, PUT_SDB_LAST_DIM, PUT_SDB_TAG, PUT_SDB_SRC_FILE,
+       SDB_GENERATE_FAKE, TEXT_SECTION): Delete.
+       (PUT_SDB_DEF, PUT_SDB_PLAIN_DEF, PUT_SDB_BLOCK_START,
+       PUT_SDB_BLOCK_END, PUT_SDB_FUNCTION_END): Replace use of
+       asm_out_text_file with asm_out_file.
+       * config/mips/iris5gas.h (PUT_SDB_SIZE, PUT_SDB_TYPE): Likewise.
+       * config/mips/elf.h (TEXT_SECTION): Undefine.
+       * config/mips/elf64.h (TEXT_SECION): Undefine.
+       * config/mips/openbsd.h (TEXT_SECION): Undefine.
+       * config/mips/mips.c (asm_out_text_file, asm_out_data_file): Delete.
+       (override_options): Disable small-data optimizations unless using
+       gas or explicit relocations.
+       (mips_asm_file_start, mips_asm_file_end, mips_output_function_epilogue,
+       iris6_asm_named_section, iris6_asm_file_start): Remove code for
+       handling TARGET_FILE_SWITCHING.
+       (copy_file_data): Move into TARGET_IRIX6 block.
+
 2003-06-08  Richard Henderson  <rth@redhat.com>
 
        * expr.h (EXPAND_MEMORY): New.
index 8826fa0d1cc79772f79b61e6d7df83737b218447..4c3b9cfe14421007daa5664cb385f12d6fd82bd6 100644 (file)
@@ -48,19 +48,6 @@ Boston, MA 02111-1307, USA.  */
 #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 eb12237a3aeb0473fd7321a56b44533fd76130ef..9328d4797617de72b25e52daf9438eab8660f0de 100644 (file)
@@ -45,19 +45,6 @@ Boston, MA 02111-1307, USA.  */
 #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 30c3a04c726802928c261d0d8a888bf38be29e99..c1ec6eb68188a5b2882932fcd45a559839c7eb45 100644 (file)
@@ -50,18 +50,16 @@ crtbegin.o%s"
    avoid conflicting with ELF directives.  These are only recognized
    by gas, anyhow, not the native assembler.  */
 #undef PUT_SDB_SIZE
-#define PUT_SDB_SIZE(a)                                       \
-do {                                                  \
-  extern FILE *asm_out_text_file;                     \
-  fprintf (asm_out_text_file, "\t.esize\t" HOST_WIDE_INT_PRINT_DEC ";", \
-          (HOST_WIDE_INT) (a));                      \
+#define PUT_SDB_SIZE(a)                                        \
+do {                                                   \
+  fprintf (asm_out_file, "\t.esize\t" HOST_WIDE_INT_PRINT_DEC ";", \
+          (HOST_WIDE_INT) (a));                        \
 } while (0)
 
 #undef PUT_SDB_TYPE
-#define PUT_SDB_TYPE(a)                                       \
-do {                                                  \
-  extern FILE *asm_out_text_file;                     \
-  fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a));        \
+#define PUT_SDB_TYPE(a)                                        \
+do {                                                   \
+  fprintf (asm_out_file, "\t.etype\t0x%x;", (a));      \
 } while (0)
 
 /* Switch into a generic section.  */
index af2bbf3acd81f0fa046a711aa877bc2be5dbfcca..17bfd2b165156980b3c70c3cfa52aec8a3a5de22 100644 (file)
@@ -262,8 +262,8 @@ static bool mips_matching_cpu_name_p                PARAMS ((const char *,
 static const struct mips_cpu_info *mips_parse_cpu   PARAMS ((const char *,
                                                              const char *));
 static const struct mips_cpu_info *mips_cpu_info_from_isa PARAMS ((int));
-static void copy_file_data                     PARAMS ((FILE *, FILE *));
 #ifdef TARGET_IRIX6
+static void copy_file_data                     PARAMS ((FILE *, FILE *));
 static void iris6_asm_named_section_1          PARAMS ((const char *,
                                                         unsigned int,
                                                         unsigned int));
@@ -448,12 +448,6 @@ int sym_lineno = 0;
    handle .files inside of functions.  */
 int inside_function = 0;
 
-/* Files to separate the text and the data output, so that all of the data
-   can be emitted before the text, which will mean that the assembler will
-   generate smaller code, based on the global pointer.  */
-FILE *asm_out_data_file;
-FILE *asm_out_text_file;
-
 /* Linked list of all externals that are to be emitted when optimizing
    for the global pointer if they haven't been declared by the end of
    the program with an appropriate .comm or initialization.  */
@@ -5411,6 +5405,16 @@ override_options ()
   else
     mips_abicalls = MIPS_ABICALLS_NO;
 
+  /* The MIPS and SGI o32 assemblers expect small-data variables to
+     be declared before they are used.  Although we once had code to
+     do this, it was very invasive and fragile.  It no longer seems
+     worth the effort.  */
+  if (!TARGET_EXPLICIT_RELOCS && !TARGET_GAS)
+    {
+      mips_section_threshold = 0;
+      target_flags &= ~MASK_GPOPT;
+    }
+
   /* -membedded-pic is a form of PIC code suitable for embedded
      systems.  All calls are made using PC relative addressing, and
      all data is addressed using the $gp register.  This requires gas,
@@ -6536,17 +6540,6 @@ mips_asm_file_start (stream)
   if (TARGET_MIPS16)
     fprintf (stream, "\t.set\tmips16\n");
 
-  /* 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)
-    {
-      asm_out_data_file = stream;
-      asm_out_text_file = tmpfile ();
-    }
-  else
-    asm_out_data_file = asm_out_text_file = stream;
-
   if (flag_verbose_asm)
     fprintf (stream, "\n%s -G value = %d, Arch = %s, ISA = %d\n",
             ASM_COMMENT_START,
@@ -6589,33 +6582,6 @@ mips_file_end ()
            }
        }
     }
-
-  if (TARGET_FILE_SWITCHING)
-    {
-      fputs ("\n\t.text\n", asm_out_file);
-      copy_file_data (asm_out_file, asm_out_text_file);
-    }
-}
-
-static void
-copy_file_data (to, from)
-     FILE *to, *from;
-{
-  char buffer[8192];
-  size_t len;
-  rewind (from);
-  if (ferror (from))
-    fatal_error ("can't rewind temp file: %m");
-
-  while ((len = fread (buffer, 1, sizeof (buffer), from)) > 0)
-    if (fwrite (buffer, 1, len, to) != len)
-      fatal_error ("can't write to output file: %m");
-
-  if (ferror (from))
-    fatal_error ("can't read from temp file: %m");
-
-  if (fclose (from))
-    fatal_error ("can't close temp file: %m");
 }
 
 /* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
@@ -7849,15 +7815,6 @@ mips_output_function_epilogue (file, size)
   for (string = mips16_strings; string != 0; string = XEXP (string, 1))
     SYMBOL_REF_FLAG (XEXP (string, 0)) = 0;
   free_EXPR_LIST_list (&mips16_strings);
-
-  /* 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_FILE_SWITCHING)
-    {
-      asm_out_file = asm_out_data_file;
-      data_section ();
-    }
 }
 \f
 /* Expand the epilogue into a bunch of separate insns.  SIBCALL_P is true
@@ -10623,8 +10580,6 @@ iris6_asm_named_section (name, flags)
      const char *name;
      unsigned int flags;
 {
-  if (TARGET_FILE_SWITCHING && (flags & SECTION_CODE))
-    asm_out_file = asm_out_text_file;
   iris6_asm_named_section_1 (name, flags, 0);
 }
 
@@ -10691,8 +10646,8 @@ iris6_asm_output_align (file, log)
 }
 
 /* The Iris assembler does not record alignment from .align directives,
-   but takes it from the first .section directive seen.  Play yet more
-   file switching games so that we can emit a .section directive at the
+   but takes it from the first .section directive seen.  Play file
+   switching games so that we can emit a .section directive at the
    beginning of the file with the proper alignment attached.  */
 
 void
@@ -10704,9 +10659,6 @@ iris6_asm_file_start (stream)
   iris_orig_asm_out_file = asm_out_file;
   stream = tmpfile ();
   asm_out_file = stream;
-  asm_out_data_file = stream;
-  if (! TARGET_FILE_SWITCHING)
-    asm_out_text_file = stream;
 
   iris_section_align_htab = htab_create (31, iris_section_align_entry_hash,
                                         iris_section_align_entry_eq, NULL);
@@ -10724,6 +10676,27 @@ iris6_section_align_1 (slot, data)
   return 1;
 }
 
+static void
+copy_file_data (to, from)
+     FILE *to, *from;
+{
+  char buffer[8192];
+  size_t len;
+  rewind (from);
+  if (ferror (from))
+    fatal_error ("can't rewind temp file: %m");
+
+  while ((len = fread (buffer, 1, sizeof (buffer), from)) > 0)
+    if (fwrite (buffer, 1, len, to) != len)
+      fatal_error ("can't write to output file: %m");
+
+  if (ferror (from))
+    fatal_error ("can't read from temp file: %m");
+
+  if (fclose (from))
+    fatal_error ("can't close temp file: %m");
+}
+
 static void
 iris6_file_end ()
 {
index abc3e4fd57ee7a81d28ed43146fc442c0403d6a9..fc4177a34a0d92b1b71dc17b5120105a7e6416a1 100644 (file)
@@ -307,12 +307,6 @@ extern void                sbss_section PARAMS ((void));
 #define TARGET_EXPLICIT_RELOCS (target_flags & MASK_EXPLICIT_RELOCS)
 
 
-/* This is true if we must enable the assembly language file switching
-   code.  */
-
-#define TARGET_FILE_SWITCHING \
-  (TARGET_GP_OPT && ! TARGET_GAS && ! TARGET_MIPS16)
-
 /* True if the call patterns should be split into a jalr followed by
    an instruction to restore $gp.  This is only ever true for SVR4 PIC,
    in which $gp is call-clobbered.  It is only safe to split the load
@@ -342,12 +336,6 @@ extern void                sbss_section PARAMS ((void));
 
 #define TARGET_GPWORD (TARGET_ABICALLS && (!TARGET_NEWABI || TARGET_GAS))
 
-
-/* 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
-   to debug the resulting code.  */
-#define NO_DBX_FUNCTION_END TARGET_FILE_SWITCHING
-
                                        /* Generate mips16 code */
 #define TARGET_MIPS16          (target_flags & MASK_MIPS16)
 
@@ -1370,101 +1358,20 @@ extern int mips_abi;
 
 #define FIND_BASE_TERM(X) mips_delegitimize_address (X)
 
-/* Overrides for the COFF debug format.  */
-#define PUT_SDB_SCL(a)                                 \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.scl\t%d;", (a));     \
-} while (0)
-
-#define PUT_SDB_INT_VAL(a)                             \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC ";", \
-          (HOST_WIDE_INT)(a));                         \
-} while (0)
-
-#define PUT_SDB_VAL(a)                                 \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fputs ("\t.val\t", asm_out_text_file);               \
-  output_addr_const (asm_out_text_file, (a));          \
-  fputc (';', asm_out_text_file);                      \
-} while (0)
-
 #define PUT_SDB_DEF(a)                                 \
 do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t%s.def\t",            \
+  fprintf (asm_out_file, "\t%s.def\t",                 \
           (TARGET_GAS) ? "" : "#");                    \
-  ASM_OUTPUT_LABELREF (asm_out_text_file, a);          \
-  fputc (';', asm_out_text_file);                      \
+  ASM_OUTPUT_LABELREF (asm_out_file, a);               \
+  fputc (';', asm_out_file);                           \
 } while (0)
 
 #define PUT_SDB_PLAIN_DEF(a)                           \
 do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t%s.def\t.%s;",                \
+  fprintf (asm_out_file, "\t%s.def\t.%s;",             \
           (TARGET_GAS) ? "" : "#", (a));               \
 } while (0)
 
-#define PUT_SDB_ENDEF                                  \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.endef\n");           \
-} while (0)
-
-#define PUT_SDB_TYPE(a)                                        \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.type\t0x%x;", (a));  \
-} while (0)
-
-#define PUT_SDB_SIZE(a)                                        \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC ";", \
-          (HOST_WIDE_INT)(a));                         \
-} while (0)
-
-#define PUT_SDB_DIM(a)                                 \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.dim\t%d;", (a));     \
-} while (0)
-
-#ifndef PUT_SDB_START_DIM
-#define PUT_SDB_START_DIM                              \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.dim\t");             \
-} while (0)
-#endif
-
-#ifndef PUT_SDB_NEXT_DIM
-#define PUT_SDB_NEXT_DIM(a)                            \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "%d,", a);               \
-} while (0)
-#endif
-
-#ifndef PUT_SDB_LAST_DIM
-#define PUT_SDB_LAST_DIM(a)                            \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "%d;", a);               \
-} while (0)
-#endif
-
-#define PUT_SDB_TAG(a)                                 \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file, "\t.tag\t");             \
-  ASM_OUTPUT_LABELREF (asm_out_text_file, a);          \
-  fputc (';', asm_out_text_file);                      \
-} while (0)
-
 /* For block start and end, we create labels, so that
    later we can figure out where the correct offset is.
    The normal .ent/.end serve well enough for functions,
@@ -1472,8 +1379,7 @@ do {                                                      \
 
 #define PUT_SDB_BLOCK_START(LINE)                      \
 do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file,                          \
+  fprintf (asm_out_file,                               \
           "%sLb%d:\n\t%s.begin\t%sLb%d\t%d\n",         \
           LOCAL_LABEL_PREFIX,                          \
           sdb_label_count,                             \
@@ -1486,8 +1392,7 @@ do {                                                      \
 
 #define PUT_SDB_BLOCK_END(LINE)                                \
 do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  fprintf (asm_out_text_file,                          \
+  fprintf (asm_out_file,                               \
           "%sLe%d:\n\t%s.bend\t%sLe%d\t%d\n",          \
           LOCAL_LABEL_PREFIX,                          \
           sdb_label_count,                             \
@@ -1502,21 +1407,11 @@ do {                                                    \
 
 #define PUT_SDB_FUNCTION_END(LINE)                     \
 do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  ASM_OUTPUT_SOURCE_LINE (asm_out_text_file, LINE + sdb_begin_function_line); \
+  ASM_OUTPUT_SOURCE_LINE (asm_out_file, LINE + sdb_begin_function_line); \
 } while (0)
 
 #define PUT_SDB_EPILOGUE_END(NAME)
 
-#define PUT_SDB_SRC_FILE(FILENAME)                     \
-do {                                                   \
-  extern FILE *asm_out_text_file;                      \
-  output_file_directive (asm_out_text_file, (FILENAME));\
-} while (0)
-
-#define SDB_GENERATE_FAKE(BUFFER, NUMBER)              \
-  sprintf ((BUFFER), ".%dfake", (NUMBER));
-
 /* Correct the offset of automatic variables and arguments.  Note that
    the MIPS debug format wants all automatic variables and arguments
    to be in terms of the virtual frame pointer (stack pointer before
@@ -3930,18 +3825,6 @@ while (0)
 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
   mips_output_external(STREAM,DECL,NAME)
 
-/* 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
index 8b1c124cf8e5082671ea6427a455aa28e5534f74..a61aac0d43829c14b75516cb5ba6b61bf93a0cf9 100644 (file)
@@ -110,19 +110,6 @@ 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.  */