diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 65578bc545817d1622e39776ecee553f3747d774..c7c7cf4ea965f21eef0bd2fc0acfc62fb59eed10 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +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. diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h index aa094b6b8363b10936df4dc1eb0188949158822a..7408704658a5397094ff88651617810de282ab9f 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 c9bcd3ead2d23e221d9462b186a548845917f13e..c218c3743bf5381e4e9eafed9a1e0f96497c0c6b 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 5e8516059b73f5c16f48ffe409ef0fa15a086201..68d9e53dfff1540776a82701e1c0f136d6c46fb7 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 c441198910548fe261ddc26bd9d6364deb8ebb4a..d86cf1c986379fc3ae20d875789e028ba7757f67 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 13e7b089d79890e465ff9aaea891e606dbfa09c0..cdb80376cef57f7ce187a9fc44302c764659c906 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 e4847cef9a26e3ef1ad9f37c54b9cb2a921c7940..886c229f979f15abca006d86fe75466a300d080b 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 30cf07215781e40fdaf6f240c8db7fc036d23d60..cc1de94fa3e709621a3b4319a1816734d55ccd57 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 057dee29d8246956cc6643aafcb232722e2484d2..5c8b8bc6a2d5b9998dd2f9a0e8111ccc8cef1d80 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 8b752dc1e9bdab3ad17986c670e9fe0eaf031ec0..c3a6322c8df1be61fc374a9a0716ddef6618226e 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; } }