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.
#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
#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
/* 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 ();
}
}
- if (TARGET_FILE_SWITCHING && ! TARGET_MIPS16)
+ if (TARGET_FILE_SWITCHING)
{
fprintf (file, "\n\t.text\n");
rewind (asm_out_text_file);
/* 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. */
/* 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
#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. */
#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
#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. */
#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
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,
#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
/* 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);
/* 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
/* 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);
/* 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
/* 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);
/* 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);
/* 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
/* 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);
/* 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
/* 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);
{
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;
}
}