From f99ffb608b3069da8ac2b9f25c61c4b4ad77f571 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 17 Aug 2001 11:57:51 -0700 Subject: [PATCH] varasm.c (text_section): Allow TEXT_SECTION to override the printing of TEXT_SECTION_ASM_OP. * 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. From-SVN: r44973 --- gcc/ChangeLog | 20 ++++++++++++++++ gcc/config/mips/elf.h | 13 +++++++++++ gcc/config/mips/elf64.h | 13 +++++++++++ gcc/config/mips/mips.c | 12 ++++++---- gcc/config/mips/mips.h | 40 +++++++++++++++----------------- gcc/config/mips/netbsd.h | 13 +++++++++++ gcc/config/mips/openbsd.h | 13 +++++++++++ gcc/dwarf2out.c | 12 +++------- gcc/dwarfout.c | 48 +++++++++++++++++++-------------------- gcc/varasm.c | 4 ++++ 10 files changed, 128 insertions(+), 60 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 65578bc5458..c7c7cf4ea96 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2001-08-17 Richard Henderson + + * 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 * dwarf2out.c (dwarf2out_init): Don't emit .debug_loc label here. diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h index aa094b6b836..7408704658a 100644 --- a/gcc/config/mips/elf.h +++ b/gcc/config/mips/elf.h @@ -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 diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h index c9bcd3ead2d..c218c3743bf 100644 --- a/gcc/config/mips/elf64.h +++ b/gcc/config/mips/elf64.h @@ -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 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 5e8516059b7..68d9e53dfff 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -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 (); + } } /* Expand the epilogue into a bunch of separate insns. */ diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index c4411989105..d86cf1c9863 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -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. */ diff --git a/gcc/config/mips/netbsd.h b/gcc/config/mips/netbsd.h index 13e7b089d79..cdb80376cef 100644 --- a/gcc/config/mips/netbsd.h +++ b/gcc/config/mips/netbsd.h @@ -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 diff --git a/gcc/config/mips/openbsd.h b/gcc/config/mips/openbsd.h index e4847cef9a2..886c229f979 100644 --- a/gcc/config/mips/openbsd.h +++ b/gcc/config/mips/openbsd.h @@ -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. */ diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 30cf0721578..cc1de94fa3e 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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, diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c index 057dee29d82..5c8b8bc6a2d 100644 --- a/gcc/dwarfout.c +++ b/gcc/dwarfout.c @@ -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 /* 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); diff --git a/gcc/varasm.c b/gcc/varasm.c index 8b752dc1e9b..c3a6322c8df 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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; } } -- 2.30.2