diff options
author | Richard Henderson <rth@redhat.com> | 2001-08-03 18:31:41 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2001-08-03 18:31:41 -0700 |
commit | 7c262518a45491adb8a04f5ec4006dbe957ab7a4 (patch) | |
tree | f3a177e73b80eca5619e6a8d303a81b56c901052 /gcc | |
parent | 4e627c414436df3de424b718f70576abab682e04 (diff) | |
download | gcc-7c262518a45491adb8a04f5ec4006dbe957ab7a4.zip gcc-7c262518a45491adb8a04f5ec4006dbe957ab7a4.tar.gz gcc-7c262518a45491adb8a04f5ec4006dbe957ab7a4.tar.bz2 |
target.h (gcc_target): Add asm_out.named_section, section_type_flags, have_named_sections.
* target.h (gcc_target): Add asm_out.named_section,
section_type_flags, have_named_sections.
* target-def.h (TARGET_ASM_NAMED_SECTION): New.
(TARGET_HAVE_NAMED_SECTIONS): New.
(TARGET_SECTION_TYPE_FLAGS): New.
* Makefile.in (toplev.o): Depend on TARGET_H.
(varasm.o, dbxout.o): Likewise.
* c-common.c (decl_attributes): Check targetm.have_named_sections
instead of ifdef ASM_OUTPUT_SECTION_NAME.
* dbxout.c (dbxout_function_decl): Likewise.
(dbxout_function_end): Likewise.
* toplev.c (compile_file): Likewise.
* varasm.c (exception_section): Likewise.
* cp/decl2.c (finish_objects): Likewise.
* defaults.h (EH_FRAME_SECTION): Remove.
(EH_FRAME_SECTION_ASM_OP): Remove.
(EH_FRAME_SECTION_NAME): New.
(UNIQUE_SECTION): Don't depend on ASM_OUTPUT_SECTION_NAME.
(UNIQUE_SECTION_P): Remove.
* dwarf2out.c (SECTION_FORMAT): Remove.
(ASM_OUTPUT_SECTION): Remove.
(output_call_frame_info): Use named_section_flags.
(output_comp_unit, dwarf2out_start_source_file): Likewise.
(dwarf2out_end_source_file, dwarf2out_define): Likewise.
(dwarf2out_undef, dwarf2out_init, dwarf2out_finish): Likewise.
* varasm.c (in_eh_frame, eh_frame_section): Remove.
(named_section_flags): New.
(named_section): Use it and targetm.section_type_flags.
(resolve_unique_section): New.
(assemble_start_function): Use it.
(asm_emit_uninitialised, assemble_variable): Likewise.
(default_section_type_flags): New.
(default_no_named_section, default_elf_asm_named_section): New.
(default_coff_asm_named_section, default_pe_asm_named_section): New.
* output.h: Update varasm.c decls.
(SECTION_*): New flags.
* crtstuff.c: Check EH_FRAME_SECTION_NAME not EH_FRAME_SECTION_ASM_OP.
(__EH_FRAME_BEGIN__, __FRAME_END__): Use attribute section.
* config/elfos.h (UNIQUE_SECTION_P): Remove.
* config/alpha/elf.h, config/arm/linux-elf.h: Likewise.
* config/arm/pe.h, config/arm/unknown-elf.h: Likewise.
* config/i386/cygwin.h, config/i386/djgpp.h: Likewise.
* config/i386/i386-interix.h, config/i386/win32.h: Likewise.
* config/ia64/sysv4.h, config/mcore/mcore-pe.h: Likewise.
* config/mips/elf.h, config/mips/elf64.h: Likewise.
* config/mips/iris6gld.h, config/mips/mips.h: Likewise.
* config/pa/pa64-hpux.h,
* config/elfos.h (ASM_OUTPUT_SECTION_NAME): Remove.
(TARGET_ASM_NAMED_SECTION): New.
* config/psos.h, config/a29k/a29k.h, config/alpha/elf.h: Likewise.
* config/alpha/vms.h, config/arm/coff.h: Likewise.
* config/arm/conix-elf.h, config/arm/elf.h: Likewise.
* config/arm/linux-elf.h, config/arm/pe.h: Likewise.
* config/arm/unknown-elf.h, config/avr/avr.h: Likewise.
* config/c4x/c4x.h, config/h8300/h8300.h: Likewise.
* config/i386/cygwin.h, config/i386/djgpp.h: Likewise.
* config/i386/i386-interix.h, config/i386/i386elf.h : Likewise.
* config/i386/sco5.h, config/i386/win32.h: Likewise.
* config/m68k/coff.h, config/mcore/mcore-pe.h: Likewise.
* config/mcore/mcore.h, config/mips/elf.h: Likewise.
* config/mips/elf64.h, config/mips/iris6.h: Likewise.
* config/mips/netbsd.h, config/mips/openbsd.h: Likewise.
* config/pa/pa64-hpux.h, config/rs6000/sysv4.h: Likewise.
* config/rs6000/xcoff.h, config/sh/sh.h: Likewise.
* config/sparc/sysv4.h: Likewise.
* config/nextstep.h: Error until named sections implemented.
* config/a29k/a29k.c (a29k_asm_named_section): New.
* config/alpha/alpha.c (SECTION_VMS_OVERLAY): New.
(vms_section_type_flags, vms_asm_named_section): New.
* config/arm/arm.c (arm_elf_asm_named_section): New.
* config/avr/avr.c (asm_output_section_name): Remove.
* config/avr/avr-protos.h: Update.
* config/c4x/c4x.c (c4x_asm_named_section): New.
* config/h8300/h8300.c (h8300_asm_named_section): New.
* config/i386/i386.c (sco_asm_named_section): New.
* config/i386/winnt.c (SECTION_PE_SHARED): New.
(i386_pe_section_type_flags): New.
(i386_pe_asm_named_section): New.
* config/i386/i386-protos.h: Update.
* config/m68k/m68k.c (m68k_coff_asm_named_section): New.
* config/mcore/mcore.c (mcore_asm_named_section): New.
* config/mips/mips.c (iris6_asm_named_section): New.
* config/mips/mips.h (ENCODE_SECTION_INFO): Use DECL_ONE_ONLY
instead of UNIQUE_SECTION_P.
* config/rs6000/rs6000.c (rs6000_elf_section_type_flags): New.
(xcoff_asm_named_section): New.
* config/sh/sh.c (sh_asm_named_section): New.
* config/sparc/sparc.c (sparc_elf_asm_named_section): New.
* config/i386/djgpp.h (EH_FRAME_SECTION_ASM_OP): Remove.
* config/i386/sco5.h (EH_FRAME_SECTION_ASM_OP*): Remove.
(EH_FRAME_SECTION_NAME): New.
(EXCEPTION_SECTION): New.
* config/ia64/ia64.h (EH_FRAME_SECTION_ASM_OP): Remove.
(DEBUG_*_SECTION): Remove.
* config/m68k/rtemself.h (EH_FRAME_SECTION_ASM_OP): Remove.
* config/mips/iris6.h (DEBUG_*_SECTION): Remove.
(EH_FRAME_SECTION_ASM_OP): Remove.
* doc/tm.texi (UNIQUE_SECTION_P): Remove.
(ASM_OUTPUT_SECTION_NAME): Remove.
(TARGET_ASM_NAMED_SECTION): New.
(TARGET_HAVE_NAMED_SECTIONS): New.
(TARGET_SECTION_TYPE_FLAGS): New.
(EH_FRAME_SECTION_ASM_OP): Remove.
(EH_FRAME_SECTION_NAME): New.
From-SVN: r44623
Diffstat (limited to 'gcc')
72 files changed, 1008 insertions, 1179 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 40acfdf..c88ff23 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,119 @@ +2001-08-03 Richard Henderson <rth@redhat.com> + + * target.h (gcc_target): Add asm_out.named_section, + section_type_flags, have_named_sections. + * target-def.h (TARGET_ASM_NAMED_SECTION): New. + (TARGET_HAVE_NAMED_SECTIONS): New. + (TARGET_SECTION_TYPE_FLAGS): New. + + * Makefile.in (toplev.o): Depend on TARGET_H. + (varasm.o, dbxout.o): Likewise. + * c-common.c (decl_attributes): Check targetm.have_named_sections + instead of ifdef ASM_OUTPUT_SECTION_NAME. + * dbxout.c (dbxout_function_decl): Likewise. + (dbxout_function_end): Likewise. + * toplev.c (compile_file): Likewise. + * varasm.c (exception_section): Likewise. + * cp/decl2.c (finish_objects): Likewise. + + * defaults.h (EH_FRAME_SECTION): Remove. + (EH_FRAME_SECTION_ASM_OP): Remove. + (EH_FRAME_SECTION_NAME): New. + (UNIQUE_SECTION): Don't depend on ASM_OUTPUT_SECTION_NAME. + (UNIQUE_SECTION_P): Remove. + * dwarf2out.c (SECTION_FORMAT): Remove. + (ASM_OUTPUT_SECTION): Remove. + (output_call_frame_info): Use named_section_flags. + (output_comp_unit, dwarf2out_start_source_file): Likewise. + (dwarf2out_end_source_file, dwarf2out_define): Likewise. + (dwarf2out_undef, dwarf2out_init, dwarf2out_finish): Likewise. + * varasm.c (in_eh_frame, eh_frame_section): Remove. + (named_section_flags): New. + (named_section): Use it and targetm.section_type_flags. + (resolve_unique_section): New. + (assemble_start_function): Use it. + (asm_emit_uninitialised, assemble_variable): Likewise. + (default_section_type_flags): New. + (default_no_named_section, default_elf_asm_named_section): New. + (default_coff_asm_named_section, default_pe_asm_named_section): New. + * output.h: Update varasm.c decls. + (SECTION_*): New flags. + + * crtstuff.c: Check EH_FRAME_SECTION_NAME not EH_FRAME_SECTION_ASM_OP. + (__EH_FRAME_BEGIN__, __FRAME_END__): Use attribute section. + + * config/elfos.h (UNIQUE_SECTION_P): Remove. + * config/alpha/elf.h, config/arm/linux-elf.h: Likewise. + * config/arm/pe.h, config/arm/unknown-elf.h: Likewise. + * config/i386/cygwin.h, config/i386/djgpp.h: Likewise. + * config/i386/i386-interix.h, config/i386/win32.h: Likewise. + * config/ia64/sysv4.h, config/mcore/mcore-pe.h: Likewise. + * config/mips/elf.h, config/mips/elf64.h: Likewise. + * config/mips/iris6gld.h, config/mips/mips.h: Likewise. + * config/pa/pa64-hpux.h, + + * config/elfos.h (ASM_OUTPUT_SECTION_NAME): Remove. + (TARGET_ASM_NAMED_SECTION): New. + * config/psos.h, config/a29k/a29k.h, config/alpha/elf.h: Likewise. + * config/alpha/vms.h, config/arm/coff.h: Likewise. + * config/arm/conix-elf.h, config/arm/elf.h: Likewise. + * config/arm/linux-elf.h, config/arm/pe.h: Likewise. + * config/arm/unknown-elf.h, config/avr/avr.h: Likewise. + * config/c4x/c4x.h, config/h8300/h8300.h: Likewise. + * config/i386/cygwin.h, config/i386/djgpp.h: Likewise. + * config/i386/i386-interix.h, config/i386/i386elf.h : Likewise. + * config/i386/sco5.h, config/i386/win32.h: Likewise. + * config/m68k/coff.h, config/mcore/mcore-pe.h: Likewise. + * config/mcore/mcore.h, config/mips/elf.h: Likewise. + * config/mips/elf64.h, config/mips/iris6.h: Likewise. + * config/mips/netbsd.h, config/mips/openbsd.h: Likewise. + * config/pa/pa64-hpux.h, config/rs6000/sysv4.h: Likewise. + * config/rs6000/xcoff.h, config/sh/sh.h: Likewise. + * config/sparc/sysv4.h: Likewise. + + * config/nextstep.h: Error until named sections implemented. + + * config/a29k/a29k.c (a29k_asm_named_section): New. + * config/alpha/alpha.c (SECTION_VMS_OVERLAY): New. + (vms_section_type_flags, vms_asm_named_section): New. + * config/arm/arm.c (arm_elf_asm_named_section): New. + * config/avr/avr.c (asm_output_section_name): Remove. + * config/avr/avr-protos.h: Update. + * config/c4x/c4x.c (c4x_asm_named_section): New. + * config/h8300/h8300.c (h8300_asm_named_section): New. + * config/i386/i386.c (sco_asm_named_section): New. + * config/i386/winnt.c (SECTION_PE_SHARED): New. + (i386_pe_section_type_flags): New. + (i386_pe_asm_named_section): New. + * config/i386/i386-protos.h: Update. + * config/m68k/m68k.c (m68k_coff_asm_named_section): New. + * config/mcore/mcore.c (mcore_asm_named_section): New. + * config/mips/mips.c (iris6_asm_named_section): New. + * config/mips/mips.h (ENCODE_SECTION_INFO): Use DECL_ONE_ONLY + instead of UNIQUE_SECTION_P. + * config/rs6000/rs6000.c (rs6000_elf_section_type_flags): New. + (xcoff_asm_named_section): New. + * config/sh/sh.c (sh_asm_named_section): New. + * config/sparc/sparc.c (sparc_elf_asm_named_section): New. + + * config/i386/djgpp.h (EH_FRAME_SECTION_ASM_OP): Remove. + * config/i386/sco5.h (EH_FRAME_SECTION_ASM_OP*): Remove. + (EH_FRAME_SECTION_NAME): New. + (EXCEPTION_SECTION): New. + * config/ia64/ia64.h (EH_FRAME_SECTION_ASM_OP): Remove. + (DEBUG_*_SECTION): Remove. + * config/m68k/rtemself.h (EH_FRAME_SECTION_ASM_OP): Remove. + * config/mips/iris6.h (DEBUG_*_SECTION): Remove. + (EH_FRAME_SECTION_ASM_OP): Remove. + + * doc/tm.texi (UNIQUE_SECTION_P): Remove. + (ASM_OUTPUT_SECTION_NAME): Remove. + (TARGET_ASM_NAMED_SECTION): New. + (TARGET_HAVE_NAMED_SECTIONS): New. + (TARGET_SECTION_TYPE_FLAGS): New. + (EH_FRAME_SECTION_ASM_OP): Remove. + (EH_FRAME_SECTION_NAME): New. + 2001-08-03 Zack Weinberg <zackw@stanford.edu> * builtins.c (fold_builtin_constant_p): Return integer_zero_node diff --git a/gcc/Makefile.in b/gcc/Makefile.in index c465c9c..cdb68f7 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1357,7 +1357,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) function.h \ debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \ dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \ graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) \ - ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h + ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(MAYBE_USE_COLLECT2) \ -DTARGET_NAME=\"$(target_alias)\" \ -c $(srcdir)/toplev.c @@ -1377,7 +1377,7 @@ errors.o : errors.c $(GCONFIG_H) $(SYSTEM_H) errors.h varasm.o : varasm.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \ function.h $(EXPR_H) hard-reg-set.h $(REGS_H) $(OBSTACK_H) \ output.h c-pragma.h toplev.h xcoffout.h debug.h $(GGC_H) $(TM_P_H) \ - $(HASHTAB_H) + $(HASHTAB_H) $(TARGET_H) function.o : function.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \ function.h $(EXPR_H) $(REGS_H) hard-reg-set.h \ insn-config.h $(RECOG_H) output.h toplev.h except.h hash.h $(GGC_H) $(TM_P_H) @@ -1408,7 +1408,7 @@ optabs.o : optabs.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \ insn-config.h $(EXPR_H) $(RECOG_H) reload.h \ toplev.h $(GGC_H) real.h $(TM_P_H) except.h dbxout.o : dbxout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \ - $(REGS_H) debug.h $(TM_P_H) \ + $(REGS_H) debug.h $(TM_P_H) $(TARGET_H) \ insn-config.h reload.h gstab.h xcoffout.h output.h dbxout.h toplev.h debug.o : debug.c $(CONFIG_H) $(SYSTEM_H) sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \ diff --git a/gcc/c-common.c b/gcc/c-common.c index 59be405..dc5ff8f 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -971,33 +971,34 @@ decl_attributes (node, attributes, flags) break; case A_SECTION: -#ifdef ASM_OUTPUT_SECTION_NAME - if ((TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == VAR_DECL) - && TREE_CODE (TREE_VALUE (args)) == STRING_CST) + if (targetm.have_named_sections) { - if (TREE_CODE (decl) == VAR_DECL - && current_function_decl != NULL_TREE - && ! TREE_STATIC (decl)) - error_with_decl (decl, - "section attribute cannot be specified for local variables"); - /* The decl may have already been given a section attribute from - a previous declaration. Ensure they match. */ - else if (DECL_SECTION_NAME (decl) != NULL_TREE - && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), - TREE_STRING_POINTER (TREE_VALUE (args))) != 0) - error_with_decl (*node, - "section of `%s' conflicts with previous declaration"); + if ((TREE_CODE (decl) == FUNCTION_DECL + || TREE_CODE (decl) == VAR_DECL) + && TREE_CODE (TREE_VALUE (args)) == STRING_CST) + { + if (TREE_CODE (decl) == VAR_DECL + && current_function_decl != NULL_TREE + && ! TREE_STATIC (decl)) + error_with_decl (decl, + "section attribute cannot be specified for local variables"); + /* The decl may have already been given a section attribute + from a previous declaration. Ensure they match. */ + else if (DECL_SECTION_NAME (decl) != NULL_TREE + && strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), + TREE_STRING_POINTER (TREE_VALUE (args))) != 0) + error_with_decl (*node, + "section of `%s' conflicts with previous declaration"); + else + DECL_SECTION_NAME (decl) = TREE_VALUE (args); + } else - DECL_SECTION_NAME (decl) = TREE_VALUE (args); + error_with_decl (*node, + "section attribute not allowed for `%s'"); } else error_with_decl (*node, - "section attribute not allowed for `%s'"); -#else - error_with_decl (*node, - "section attributes are not supported for this target"); -#endif + "section attributes are not supported for this target"); break; case A_ALIGNED: diff --git a/gcc/config/a29k/a29k.c b/gcc/config/a29k/a29k.c index 896f162..a4905e6 100644 --- a/gcc/config/a29k/a29k.c +++ b/gcc/config/a29k/a29k.c @@ -48,6 +48,8 @@ static void compute_regstack_size PARAMS ((void)); static void check_epilogue_internal_label PARAMS ((FILE *)); static void output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); +static void a29k_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); #define min(A,B) ((A) < (B) ? (A) : (B)) @@ -1568,3 +1570,13 @@ output_function_epilogue (file, size) free (a29k_first_epilogue_insn); a29k_first_epilogue_insn = 0; } + +static void +a29k_asm_named_section (name, flags, align) + const char *name; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int align ATTRIBUTE_UNUSED; +{ + /* ??? Is it really correct to mark all sections as "bss"? */ + fprintf (asm_out_file, "\t.sect %s, bss\n\t.use %s\n", name, name); +} diff --git a/gcc/config/a29k/a29k.h b/gcc/config/a29k/a29k.h index 96d19ac..8568d5e 100644 --- a/gcc/config/a29k/a29k.h +++ b/gcc/config/a29k/a29k.h @@ -1428,11 +1428,8 @@ literal_section () \ extern int a29k_debug_reg_map[]; #define DBX_REGISTER_NUMBER(REGNO) a29k_debug_reg_map[REGNO] -/* This how to write an assembler directive to FILE to switch to - section NAME for DECL. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - fprintf (FILE, "\t.sect %s, bss\n\t.use %s\n", NAME, NAME) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION a29k_asm_named_section /* This is how to output the definition of a user-level label named NAME, such as the label on a static function or variable NAME. */ diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 2456e99..345d95e 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -148,9 +148,14 @@ static void alpha_output_function_end_prologue /* Initialize the GCC target structure. */ #if TARGET_ABI_OPEN_VMS - static int vms_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree)); -# undef TARGET_VALID_DECL_ATTRIBUTE -# define TARGET_VALID_DECL_ATTRIBUTE vms_valid_decl_attribute_p +static int vms_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree)); +static unsigned int vms_section_type_flags PARAMS ((tree, const char *, int)); +static void vms_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); +# undef TARGET_VALID_DECL_ATTRIBUTE +# define TARGET_VALID_DECL_ATTRIBUTE vms_valid_decl_attribute_p +# undef TARGET_SECTION_TYPE_FLAGS +# define TARGET_SECTION_TYPE_FLAGS vms_section_type_flags #endif #undef TARGET_ASM_FUNCTION_END_PROLOGUE @@ -6535,6 +6540,51 @@ alpha_write_linkage (stream) splay_tree_foreach (alpha_links, alpha_write_one_linkage, stream); } +/* Given a decl, a section name, and whether the decl initializer + has relocs, choose attributes for the section. */ + +#define SECTION_VMS_OVERLAY SECTION_FORGET + +static unsigned int +vms_section_type_flags (decl, name, reloc) + tree decl; + const char *name; + int reloc; +{ + unsigned int flags = default_section_type_flags (decl, name, reloc); + + if (decl && DECL_MACHINE_ATTRIBUTES (decl) + && lookup_attribute ("overlaid", DECL_MACHINE_ATTRIBUTES (decl))) + flags |= SECTION_VMS_OVERLAY; + + return flags; +} + +/* Switch to an arbitrary section NAME with attributes as specified + by FLAGS. ALIGN specifies any known alignment requirements for + the section; 0 if the default should be used. */ + +static void +vms_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align; +{ + const char *flag_str = ""; + + if (flags & SECTION_VMS_OVERLAY) + flag_str = ",OVR"; + else if (flags & SECTION_DEBUG) + flag_str = ",NOWRT"; + + fprintf (asm_out_file, ".section\t%s%s\n", name, flag_str); + + /* ??? An indicated alignment of 1 byte is only used by dwarf, + and for that we turn off auto-alignment. */ + if (align == 1) + ASM_OUTPUT_ALIGN (asm_out_file, 0); +} + #else rtx diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h index dbec2b4..a8e8900 100644 --- a/gcc/config/alpha/elf.h +++ b/gcc/config/alpha/elf.h @@ -294,69 +294,8 @@ void FN () \ } \ } - -/* Switch into a generic section. - - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. - - If the section has already been defined, we must not emit the - attributes here. The SVR4 assembler does not recognize section - redefinitions. If DECL is NULL, no attributes are emitted. */ - -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - do \ - { \ - static htab_t htab; \ - \ - struct section_info \ - { \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - }; \ - \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - PTR* slot; \ - \ - /* The names we put in the hashtable will always be the unique \ - versions gived to us by the stringtable, so we can just use \ - their addresses as the keys. */ \ - if (!htab) \ - htab = htab_create (31, \ - htab_hash_pointer, \ - htab_eq_pointer, \ - NULL); \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = "ax"; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ - type = SECT_RO, mode = "a"; \ - else \ - type = SECT_RW, mode = "aw"; \ - \ - /* See if we already have an entry for this section. */ \ - slot = htab_find_slot (htab, NAME, INSERT); \ - if (!*slot) \ - { \ - s = (struct section_info *) xmalloc (sizeof (* s)); \ - s->type = type; \ - *slot = s; \ - fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \ - NAME, mode); \ - } \ - else \ - { \ - s = (struct section_info *) *slot; \ - if (DECL && s->type != type) \ - error_with_decl (DECL, \ - "%s causes a section type conflict"); \ - \ - fprintf (FILE, "\t.section\t%s\n", NAME); \ - } \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* A C statement (sans semicolon) to output an element in the table of global constructors. */ @@ -460,8 +399,6 @@ void FN () \ #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) - #undef UNIQUE_SECTION #define UNIQUE_SECTION(DECL, RELOC) \ do \ diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h index d10a19d..bc7e1e6 100644 --- a/gcc/config/alpha/vms.h +++ b/gcc/config/alpha/vms.h @@ -407,30 +407,8 @@ do { \ #define ASM_OUTPUT_ALIGN(FILE,LOG) \ fprintf (FILE, "\t.align %d\n", LOG); -#define ASM_OUTPUT_SECTION(FILE,SECTION) \ - (strcmp (SECTION, ".text") == 0) \ - ? text_section () \ - : named_section (NULL_TREE, SECTION, 0), \ - ASM_OUTPUT_ALIGN (FILE, 0) \ - -#define ASM_OUTPUT_SECTION_NAME(FILE,DECL,NAME,RELOC) \ - do \ - { \ - const char *flags; \ - int ovr = 0; \ - if (DECL && DECL_MACHINE_ATTRIBUTES (DECL) \ - && lookup_attribute \ - ("overlaid", DECL_MACHINE_ATTRIBUTES (DECL))) \ - flags = ",OVR", ovr = 1; \ - else if (strncmp (NAME,".debug", 6) == 0) \ - flags = ",NOWRT"; \ - else \ - flags = ""; \ - fputc ('\n', (FILE)); \ - fprintf (FILE, ".section\t%s%s\n", NAME, flags); \ - if (ovr) \ - (NAME) = ""; \ - } while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION vms_asm_named_section #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ do { literals_section(); \ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 35c520c..b79a92b 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -114,6 +114,9 @@ static void thumb_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static int arm_comp_type_attributes PARAMS ((tree, tree)); static void arm_set_default_type_attributes PARAMS ((tree)); +static void arm_elf_asm_named_section PARAMS ((const char *, + unsigned int, + unsigned int)); #undef Hint #undef Mmode #undef Ulong @@ -10632,3 +10635,38 @@ aof_dump_imports (f) } } #endif /* AOF_ASSEMBLER */ + +/* Switch to an arbitrary section NAME with attributes as specified + by FLAGS. ALIGN specifies any known alignment requirements for + the section; 0 if the default should be used. + + Differs from the default elf version only in the prefix character + used before the section type. */ + +static void +arm_elf_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + char flagchars[8], *f = flagchars; + const char *type; + + if (!(flags & SECTION_DEBUG)) + *f++ = 'a'; + if (flags & SECTION_WRITE) + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; + if (flags & SECTION_SMALL) + *f++ = 's'; + *f = '\0'; + + if (flags & SECTION_BSS) + type = "nobits"; + else + type = "progbits"; + + fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s\n", + name, flagchars, type); +} diff --git a/gcc/config/arm/coff.h b/gcc/config/arm/coff.h index eeea20b..11cb9bb 100644 --- a/gcc/config/arm/coff.h +++ b/gcc/config/arm/coff.h @@ -64,21 +64,8 @@ Boston, MA 02111-1307, USA. */ } \ while (0) -/* A C statement to output something to the assembler file to switch to - section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ - do \ - { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \ - else \ - fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section /* Support the ctors/dtors and other sections. */ diff --git a/gcc/config/arm/conix-elf.h b/gcc/config/arm/conix-elf.h index a626af8..f32228f 100644 --- a/gcc/config/arm/conix-elf.h +++ b/gcc/config/arm/conix-elf.h @@ -83,28 +83,14 @@ func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) } asm (DTORS_SECTION_ASM_OP); \ func_ptr __DTOR_END__[1] = { (func_ptr) 0 }; -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ - do \ - { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"a\"\n", (NAME)); \ - else \ - fprintf (STREAM, "\t.section %s,\"aw\"\n", (NAME)); \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* The ARM development system defines __main. */ #define NAME__MAIN "__gccmain" #define SYMBOL__MAIN __gccmain #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) #define UNIQUE_SECTION(DECL,RELOC) \ do \ { \ diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h index 2eb2388..102b53a 100644 --- a/gcc/config/arm/elf.h +++ b/gcc/config/arm/elf.h @@ -299,23 +299,9 @@ dtors_section () \ } #endif -/* A C statement to output something to the assembler file to switch to - section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL - or NULL_TREE. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ - do \ - { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"ax\",%%progbits\n", NAME); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"a\"\n", NAME); \ - else if (! strncmp (NAME, ".bss", 4)) \ - fprintf (STREAM, "\t.section %s,\"aw\",%%nobits\n", NAME); \ - else \ - fprintf (STREAM, "\t.section %s,\"aw\"\n", NAME); \ - } \ - while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION arm_elf_asm_named_section /* Support the ctors/dtors sections for g++. */ #ifndef INT_ASM_OP diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h index 4940ae9..0651960 100644 --- a/gcc/config/arm/linux-elf.h +++ b/gcc/config/arm/linux-elf.h @@ -132,15 +132,8 @@ const_section () \ } \ } -/* Switch into a generic section. - This is currently only used to support section attributes. - - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - fprintf (FILE, ".section\t%s,\"%s\",%%progbits\n", NAME, \ - (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw") +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION arm_elf_asm_named_section /* A C statement or statements to switch to the appropriate section for output of DECL. DECL is either a `VAR_DECL' node @@ -171,8 +164,6 @@ const_section () \ } #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) - #define UNIQUE_SECTION(DECL, RELOC) \ do \ { \ diff --git a/gcc/config/arm/pe.h b/gcc/config/arm/pe.h index 8281886..6d4f61d 100644 --- a/gcc/config/arm/pe.h +++ b/gcc/config/arm/pe.h @@ -118,35 +118,12 @@ Boston, MA 02111-1307, USA. */ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) - #define UNIQUE_SECTION(DECL, RELOC) arm_pe_unique_section (DECL, RELOC) #define SUPPORTS_ONE_ONLY 1 -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ - do \ - { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \ - else \ - fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ - /* Functions may have been compiled at various levels of \ - optimization so we can't use `same_size' here. \ - Instead, have the linker pick one. */ \ - if ((DECL) && DECL_ONE_ONLY (DECL)) \ - fprintf (STREAM, "\t.linkonce %s\n", \ - TREE_CODE (DECL) == FUNCTION_DECL \ - ? "discard" : "same_size"); \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section /* This outputs a lot of .req's to define alias for various registers. Let's try to avoid this. */ diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h index fab8155f..1eebb7b 100644 --- a/gcc/config/arm/unknown-elf.h +++ b/gcc/config/arm/unknown-elf.h @@ -85,23 +85,8 @@ rdata_section () \ asm (DTORS_SECTION_ASM_OP); \ func_ptr __DTOR_END__[1] = { (func_ptr) 0 }; -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ - do \ - { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"a\"\n", (NAME)); \ - else if (! strncmp (NAME, ".bss", 4)) \ - fprintf (STREAM, "\t.section %s,\"aw\",@nobits\n", (NAME)); \ - else \ - fprintf (STREAM, "\t.section %s,\"aw\"\n", (NAME)); \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* The ARM development system defines __main. */ #define NAME__MAIN "__gccmain" @@ -114,8 +99,6 @@ rdata_section () \ #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) - #define UNIQUE_SECTION(DECL, RELOC) \ do \ { \ diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h index 9d98398..b6f4d74 100644 --- a/gcc/config/avr/avr-protos.h +++ b/gcc/config/avr/avr-protos.h @@ -45,9 +45,6 @@ extern void asm_output_external PARAMS ((FILE *file, tree decl, char *name)); extern void unique_section PARAMS ((tree decl, int reloc)); extern void encode_section_info PARAMS ((tree decl)); -extern void asm_output_section_name PARAMS ((FILE *file, tree decl, - const char *name, - int reloc)); extern int avr_progmem_p PARAMS ((tree decl)); diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 605360a..6d11d05 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -4556,23 +4556,6 @@ unique_section (decl, reloc) } -/* Output section name to file FILE - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. */ - -void -asm_output_section_name(file, decl, name, reloc) - FILE *file; - tree decl; - const char *name; - int reloc ATTRIBUTE_UNUSED; -{ - fprintf (file, ".section %s, \"%s\", @progbits\n", name, - decl && TREE_CODE (decl) == FUNCTION_DECL ? "ax" : - decl && TREE_READONLY (decl) ? "a" : "aw"); -} - - /* The routine used to output NUL terminated strings. We use a special version of this for most svr4 targets because doing so makes the generated assembly code more compact (and thus faster to assemble) diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index dfb5882..5467fa4 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -1956,12 +1956,6 @@ progmem_section (void) \ Decode SYM_NAME and store the real name part in VAR, sans the characters that encode section info. Define this macro if `ENCODE_SECTION_INFO' alters the symbol's name string. */ -/* `UNIQUE_SECTION_P (DECL)' - A C expression which evaluates to true if DECL should be placed - into a unique section for some target-specific reason. If you do - not define this macro, the default is `0'. Note that the flag - `-ffunction-sections' will also cause functions to be placed into - unique sections. */ #define UNIQUE_SECTION(DECL, RELOC) unique_section (DECL, RELOC) /* `UNIQUE_SECTION (DECL, RELOC)' @@ -1971,7 +1965,6 @@ progmem_section (void) \ link-time relocations. If you do not define this macro, GNU CC will use the symbol name prefixed by `.' as the section name. */ - #define ASM_FILE_START(STREAM) asm_file_start (STREAM) /* A C expression which outputs to the stdio stream STREAM some appropriate text to go at the start of an assembler file. @@ -2022,19 +2015,8 @@ progmem_section (void) \ This macro need not be defined if the standard form of debugging information for the debugger in use is appropriate. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - asm_output_section_name(FILE, DECL, NAME, RELOC) - -/* `ASM_OUTPUT_SECTION_NAME (STREAM, DECL, NAME, RELOC)' - A C statement to output something to the assembler file to switch - to section NAME for object DECL which is either a `FUNCTION_DECL', - a `VAR_DECL' or `NULL_TREE'. RELOC indicates whether the initial - value of EXP requires link-time relocations. Some target formats - do not support arbitrary sections. Do not define this macro in - such cases. - - At present this macro is only used to support section attributes. - When this macro is undefined, section attributes are disabled. */ +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section #define OBJC_PROLOGUE {} /* A C statement to output any assembler statements which are diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c index 02a3dcd..da2f90d 100644 --- a/gcc/config/c4x/c4x.c +++ b/gcc/config/c4x/c4x.c @@ -191,6 +191,8 @@ static int c4x_rptb_valid_p PARAMS ((rtx, rtx)); static int c4x_label_ref_used_p PARAMS ((rtx, rtx)); static int c4x_valid_type_attribute_p PARAMS ((tree, tree, tree, tree)); static void c4x_insert_attributes PARAMS ((tree, tree *)); +static void c4x_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); /* Initialize the GCC target structure. */ #undef TARGET_VALID_TYPE_ATTRIBUTE @@ -5177,3 +5179,12 @@ c4x_expand_builtin (exp, target, subtarget, mode, ignore) } return NULL_RTX; } + +static void +c4x_asm_named_section (name, flags, align) + const char *name; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int align ATTRIBUTE_UNUSED; +{ + fprintf (asm_out_file, "\t.sect\t\"%s\"\n", name); +} diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index 102346f..dba5e47 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -2087,8 +2087,8 @@ dtors_section () \ } \ } -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - fprintf (FILE, "\t.sect\t\"%s\"\n", NAME); +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION c4x_asm_named_section /* This is machine-dependent because it needs to push something on the stack. */ diff --git a/gcc/config/d30v/d30v.h b/gcc/config/d30v/d30v.h index 5e0f0b0..2b1321b 100644 --- a/gcc/config/d30v/d30v.h +++ b/gcc/config/d30v/d30v.h @@ -3760,16 +3760,6 @@ extern const char *d30v_branch_cost_string; the symbol's name string. */ /* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */ -/* A C expression which evaluates to true if DECL should be placed - into a unique section for some target-specific reason. If you do - not define this macro, the default is `0'. Note that the flag - `-ffunction-sections' will also cause functions to be placed into - unique sections. - - Defined in svr4.h. */ -/* #define UNIQUE_SECTION_P(DECL) */ - -/* A C statement to build up a unique section name, expressed as a STRING_CST node, and assign it to `DECL_SECTION_NAME (DECL)'. RELOC indicates whether the initial value of EXP requires link-time relocations. If you do not define this macro, GNU CC @@ -3888,17 +3878,6 @@ extern const char *d30v_branch_cost_string; Defined in svr4.h. */ /* #define ASM_OUTPUT_IDENT(STREAM, STRING) */ -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a `FUNCTION_DECL', a `VAR_DECL' or - `NULL_TREE'. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. - - At present this macro is only used to support section attributes. When this - macro is undefined, section attributes are disabled. - - Defined in svr4.h. */ -/* #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) */ - /* A C statement to output any assembler statements which are required to precede any Objective C object definitions or message sending. The statement is executed only when compiling an Objective C program. */ @@ -4852,23 +4831,6 @@ fprintf (STREAM, "\t.word .L%d\n", VALUE) This macro need not be defined on most platforms. */ /* #define ASM_OUTPUT_EH_REGION_END() */ -/* A C expression to switch to the section in which the main exception table is - to be placed (*note Sections::.). The default is a section named - `.gcc_except_table' on machines that support named sections via - `ASM_OUTPUT_SECTION_NAME', otherwise if `-fpic' or `-fPIC' is in effect, the - `data_section', otherwise the `readonly_data_section'. */ -/* #define EXCEPTION_SECTION() */ - -/* If defined, a C string constant for the assembler operation to switch to the - section for exception handling frame unwind information. If not defined, - GNU CC will provide a default definition if the target supports named - sections. `crtstuff.c' uses this macro to switch to the appropriate - section. - - You should define this symbol if your target supports DWARF 2 frame unwind - information and the default definition does not work. */ -/* #define EH_FRAME_SECTION_ASM_OP */ - /* A C expression that is nonzero if the normal exception table output should be omitted. diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index eef4115..82dde08 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -338,8 +338,6 @@ dtors_section () \ #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) - #define UNIQUE_SECTION(DECL, RELOC) \ do \ { \ @@ -403,69 +401,8 @@ dtors_section () \ } \ while (0) -/* Switch into a generic section. - - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. - - If the section has already been defined, we must not - emit the attributes here. The SVR4 assembler does not - recognize section redefinitions. - If DECL is NULL, no attributes are emitted. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - do \ - { \ - static htab_t htab; \ - \ - struct section_info \ - { \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - }; \ - \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - PTR* slot; \ - \ - /* The names we put in the hashtable will always be the unique \ - versions gived to us by the stringtable, so we can just use \ - their addresses as the keys. */ \ - if (!htab) \ - htab = htab_create (31, \ - htab_hash_pointer, \ - htab_eq_pointer, \ - NULL); \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = "ax"; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ - type = SECT_RO, mode = "a"; \ - else \ - type = SECT_RW, mode = "aw"; \ - \ - \ - /* See if we already have an entry for this section. */ \ - slot = htab_find_slot (htab, NAME, INSERT); \ - if (!*slot) \ - { \ - s = (struct section_info *) xmalloc (sizeof (* s)); \ - s->type = type; \ - *slot = s; \ - fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \ - NAME, mode); \ - } \ - else \ - { \ - s = (struct section_info *) *slot; \ - if (DECL && s->type != type) \ - error_with_decl (DECL, \ - "%s causes a section type conflict"); \ - \ - fprintf (FILE, "\t.section\t%s\n", NAME); \ - } \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* A C statement or statements to switch to the appropriate section for output of RTX in mode MODE. RTX is some kind diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 4628208..55aef38 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -56,6 +56,8 @@ static const char *cond_string PARAMS ((enum rtx_code)); static int h8300_valid_decl_attribute PARAMS ((tree, tree, tree, tree)); static void h8300_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void h8300_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); +static void h8300_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); /* CPU_TYPE, says what cpu we're compiling for. */ int cpu_type; @@ -3325,3 +3327,13 @@ h8300_adjust_insn_length (insn, length) return 0; } + +static void +h8300_asm_named_section (name, flags, align) + const char *name; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int align ATTRIBUTE_UNUSED; +{ + /* ??? Perhaps we should be using default_coff_asm_named_section. */ + fprintf (asm_out_file, "\t.section %s\n", name); +} diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 96fbbbb..f419ba4 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -1225,13 +1225,8 @@ readonly_data () \ fprintf (FILE, \ "\t.text\n.stabs \"\",%d,0,0,.Letext\n.Letext:\n", N_SO) -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - fprintf (FILE, "\t.section %s\n", NAME) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION h8300_asm_named_section /* This is how to output the definition of a user-level label named NAME, such as the label on a static function or variable NAME. */ diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index 6e76f1c..9ea367f 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -407,69 +407,16 @@ do { \ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) extern void i386_pe_unique_section PARAMS ((TREE, int)); #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) #define SUPPORTS_ONE_ONLY 1 -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ -do { \ - static struct section_info \ - { \ - struct section_info *next; \ - char *name; \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - } *sections; \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - \ - for (s = sections; s; s = s->next) \ - if (!strcmp (NAME, s->name)) \ - break; \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = "x"; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ - type = SECT_RO, mode = ""; \ - else \ - { \ - type = SECT_RW; \ - if (DECL && TREE_CODE (DECL) == VAR_DECL \ - && lookup_attribute ("shared", DECL_MACHINE_ATTRIBUTES (DECL))) \ - mode = "ws"; \ - else \ - mode = "w"; \ - } \ - \ - if (s == 0) \ - { \ - s = (struct section_info *) xmalloc (sizeof (struct section_info)); \ - s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \ - strcpy (s->name, NAME); \ - s->type = type; \ - s->next = sections; \ - sections = s; \ - fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \ - /* Functions may have been compiled at various levels of \ - optimization so we can't use `same_size' here. Instead, \ - have the linker pick one. */ \ - if ((DECL) && DECL_ONE_ONLY (DECL)) \ - fprintf (STREAM, "\t.linkonce %s\n", \ - TREE_CODE (DECL) == FUNCTION_DECL \ - ? "discard" : "same_size"); \ - } \ - else \ - { \ - fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \ - } \ -} while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section + +/* Select attributes for named sections. */ +#define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags /* Write the extra assembler code needed to declare a function properly. If we are generating SDB debugging information, this diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h index 14a4357..f5e79c2 100644 --- a/gcc/config/i386/djgpp.h +++ b/gcc/config/i386/djgpp.h @@ -57,10 +57,6 @@ Boston, MA 02111-1307, USA. */ #undef DTORS_SECTION_ASM_OP #define DTORS_SECTION_ASM_OP "\t.section .dtor" -/* Define the name of the .eh_frame section. */ -#undef EH_FRAME_SECTION_ASM_OP -#define EH_FRAME_SECTION_ASM_OP "\t.section .eh_frame" - /* Define the name of the .ident op. */ #undef IDENT_ASM_OP #define IDENT_ASM_OP "\t.ident\t" @@ -189,14 +185,8 @@ dtor_section () \ fprintf (FILE, "\n"); \ } while (0) -/* Tell GCC how to output a section name. Add "x" for code sections. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\ - do { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf ((FILE), "\t.section %s,\"x\"\n", (NAME)); \ - else \ - fprintf ((FILE), "\t.section %s\n", (NAME)); \ - } while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_coff_asm_named_section #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ do { \ @@ -287,11 +277,6 @@ while (0) #undef MAKE_DECL_ONE_ONLY #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -/* Additional support for C++ templates and support for - garbage collection. */ -#undef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) - #undef UNIQUE_SECTION #define UNIQUE_SECTION(DECL,RELOC) \ do { \ diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h index 0460b64..864f520 100644 --- a/gcc/config/i386/i386-interix.h +++ b/gcc/config/i386/i386-interix.h @@ -341,26 +341,6 @@ dtors_section () \ } \ } -#if 0 -/* Currently gas chokes on this; that's not too hard to fix, but there's - not a lot of impeteus to do it, either. If it is done, gas will have - to handle long section name escapes (which are defined in the COFF/PE - document as /nnn where nnn is a string table index). The benefit: - section attributes and -ffunction-sections, neither of which seem to - be critical. */ -/* gas may have been fixed? bfd was. */ - -/* Switch into a generic section. - This is currently only used to support section attributes. - - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ - fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ - (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && TREE_READONLY (DECL) ? "a" : "aw") -#endif - /* The MS compilers take alignment as a number of bytes, so we do as well */ #undef ASM_OUTPUT_ALIGN #define ASM_OUTPUT_ALIGN(FILE,LOG) \ @@ -505,63 +485,13 @@ do { \ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) extern void i386_pe_unique_section (); #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) #define SUPPORTS_ONE_ONLY 1 -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ -do { \ - static struct section_info \ - { \ - struct section_info *next; \ - char *name; \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - } *sections; \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - \ - for (s = sections; s; s = s->next) \ - if (!strcmp (NAME, s->name)) \ - break; \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = "x"; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ - type = SECT_RO, mode = "r"; \ - else \ - type = SECT_RW, mode = "w"; \ - \ - if (s == 0) \ - { \ - s = (struct section_info *) xmalloc (sizeof (struct section_info)); \ - s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \ - strcpy (s->name, NAME); \ - s->type = type; \ - s->next = sections; \ - sections = s; \ - fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \ - /* Functions may have been compiled at various levels of \ - optimization so we can't use `same_size' here. Instead, \ - have the linker pick one. */ \ - if ((DECL) && DECL_ONE_ONLY (DECL)) \ - fprintf (STREAM, "\t.linkonce %s\n", \ - TREE_CODE (DECL) == FUNCTION_DECL \ - ? "discard" : "same_size"); \ - } \ - else \ - { \ - fprintf (STREAM, ".section\t%s,\"%s\"\n", NAME, mode); \ - } \ -} while (0) - +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section #endif /* 0 */ /* DWARF2 Unwinding doesn't work with exception handling yet. */ diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 5b9e979..e263116 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -181,4 +181,8 @@ extern int ix86_constant_alignment PARAMS ((tree, int)); extern int ix86_valid_type_attribute_p PARAMS ((tree, tree, tree, tree)); extern int i386_pe_valid_decl_attribute_p PARAMS ((tree, tree, tree, tree)); extern int i386_pe_valid_type_attribute_p PARAMS ((tree, tree, tree, tree)); +extern unsigned int i386_pe_section_type_flags PARAMS ((tree, const char *, + int)); +extern void i386_pe_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 9017207..2547ea4 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -608,6 +608,11 @@ static int ix86_fp_comparison_cost PARAMS ((enum rtx_code code)); static int ix86_save_reg PARAMS ((int, int)); static void ix86_compute_frame_layout PARAMS ((struct ix86_frame *)); static int ix86_comp_type_attributes PARAMS ((tree, tree)); + +#if defined(TARGET_ELF) && defined(TARGET_COFF) +static void sco_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); +#endif /* Initialize the GCC target structure. */ #undef TARGET_VALID_TYPE_ATTRIBUTE @@ -2323,7 +2328,7 @@ ix86_asm_file_end (file) /* ??? Binutils 2.10 and earlier has a linkonce elimination bug related to updating relocations to a section being discarded such that this doesn't work. Ought to detect this at configure time. */ -#if 0 && defined (ASM_OUTPUT_SECTION_NAME) +#if 0 /* The trick here is to create a linkonce section containing the pic label thunk, but to refer to it with an internal label. Because the label is internal, we don't have inter-dso name @@ -2331,16 +2336,18 @@ ix86_asm_file_end (file) In order to use these macros, however, we must create a fake function decl. */ - { - tree decl = build_decl (FUNCTION_DECL, - get_identifier ("i686.get_pc_thunk"), - error_mark_node); - DECL_ONE_ONLY (decl) = 1; - UNIQUE_SECTION (decl, 0); - named_section (decl, NULL, 0); - } + if (targetm.have_named_sections) + { + tree decl = build_decl (FUNCTION_DECL, + get_identifier ("i686.get_pc_thunk"), + error_mark_node); + DECL_ONE_ONLY (decl) = 1; + UNIQUE_SECTION (decl, 0); + named_section (decl, NULL, 0); + } + else #else - text_section (); + text_section (); #endif /* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an @@ -10822,3 +10829,17 @@ ix86_output_main_function_alignment_hack (file, size) fprintf (file, "\tret\n"); ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (label)); } + +#if defined(TARGET_ELF) && defined(TARGET_COFF) +static void +sco_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align; +{ + if (TARGET_ELF) + default_elf_asm_named_section (name, flags, align); + else + default_coff_asm_named_section (name, flags, align); +} +#endif diff --git a/gcc/config/i386/i386elf.h b/gcc/config/i386/i386elf.h index 1d7d4b7..c2c5cff 100644 --- a/gcc/config/i386/i386elf.h +++ b/gcc/config/i386/i386elf.h @@ -170,21 +170,8 @@ do { long value[3]; \ #define LOCAL_LABEL_PREFIX "." -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ -do { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (FILE, ".section\t%s,\"ax\"\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (FILE, ".section\t%s,\"a\"\n", (NAME)); \ - else \ - fprintf (FILE, ".section\t%s,\"aw\"\n", (NAME)); \ -} while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* If defined, a C expression whose value is a string containing the assembler operation to identify the following data as diff --git a/gcc/config/i386/sco5.h b/gcc/config/i386/sco5.h index 2477b6a..b7a7cdb 100644 --- a/gcc/config/i386/sco5.h +++ b/gcc/config/i386/sco5.h @@ -75,10 +75,10 @@ Boston, MA 02111-1307, USA. */ #define GLOBAL_ASM_OP "\t.globl\t" #undef EH_FRAME_SECTION_ASM_OP -#define EH_FRAME_SECTION_ASM_OP_COFF "\t.section\t.ehfram, \"x\"" -#define EH_FRAME_SECTION_ASM_OP_ELF "\t.section\t.eh_frame, \"aw\"" -#define EH_FRAME_SECTION_ASM_OP \ - ((TARGET_ELF) ? EH_FRAME_SECTION_ASM_OP_ELF : EH_FRAME_SECTION_ASM_OP_COFF) +#define EH_FRAME_SECTION_NAME_COFF ".ehfram" +#define EH_FRAME_SECTION_NAME_ELF ".eh_frame" +#define EH_FRAME_SECTION_NAME \ + ((TARGET_ELF) ? EH_FRAME_SECTION_NAME_ELF : EH_FRAME_SECTION_NAME_COFF) /* Avoid problems (long sectino names, forward assembler refs) with DWARF exception unwinding when we're generating COFF */ @@ -444,56 +444,14 @@ do { \ #define USER_LABEL_PREFIX "" /* - * Compensate for the difference between ELF and COFF assembler syntax. - * Otherwise, this is cribbed from ../svr4.h. * We rename 'gcc_except_table' to the shorter name in preparation - * for the day when we're ready to do DWARF2 eh unwinding under COFF + * for the day when we're ready to do DWARF2 eh unwinding under COFF. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ -do { \ - static struct section_info \ - { \ - struct section_info *next; \ - char *name; \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - } *sections; \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - const char *sname = NAME ; \ - if (strcmp(NAME, ".gcc_except_table") == 0) sname = ".gccexc" ; \ - \ - for (s = sections; s; s = s->next) \ - if (!strcmp (NAME, s->name)) \ - break; \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = (TARGET_ELF) ? "ax" : "x" ; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ - type = SECT_RO, mode = "a"; \ - else \ - type = SECT_RW, mode = (TARGET_ELF) ? "aw" : "w" ; \ - \ - if (s == 0) \ - { \ - s = (struct section_info *) xmalloc (sizeof (struct section_info)); \ - s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \ - strcpy (s->name, NAME); \ - s->type = type; \ - s->next = sections; \ - sections = s; \ - fprintf (FILE, ".section\t%s,\"%s\"%s\n", sname, mode, \ - (TARGET_ELF) ? ",@progbits" : "" ); \ - } \ - else \ - { \ - if (DECL && s->type != type) \ - error_with_decl (DECL, "%s causes a section type conflict"); \ - \ - fprintf (FILE, ".section\t%s\n", sname); \ - } \ -} while (0) +#define EXCEPTION_SECTION() named_section (NULL, ".gccexc", 1) + +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION sco_asm_named_section #undef ASM_OUTPUT_SKIP #define ASM_OUTPUT_SKIP(FILE,SIZE) \ @@ -925,7 +883,7 @@ compiler at the end of the day. Onward we go ... # undef FINI_SECTION_ASM_OP # undef CTORS_SECTION_ASM_OP # undef DTORS_SECTION_ASM_OP -# undef EH_FRAME_SECTION_ASM_OP +# undef EH_FRAME_SECTION_NAME # undef CTOR_LIST_BEGIN # undef CTOR_LIST_END # undef DO_GLOBAL_CTORS_BODY @@ -936,13 +894,13 @@ compiler at the end of the day. Onward we go ... # define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_ELF # define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_ELF # define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_ELF -# define EH_FRAME_SECTION_ASM_OP EH_FRAME_SECTION_ASM_OP_ELF +# define EH_FRAME_SECTION_NAME EH_FRAME_SECTION_NAME_ELF # else /* ! _SCO_ELF */ # define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_COFF # define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_COFF # define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_COFF # define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_COFF -# define EH_FRAME_SECTION_ASM_OP EH_FRAME_SECTION_ASM_OP_COFF +# define EH_FRAME_SECTION_NAME EH_FRAME_SECTION_NAME_COFF # define CTOR_LIST_BEGIN asm (INIT_SECTION_ASM_OP); asm ("pushl $0") # define CTOR_LIST_END CTOR_LIST_BEGIN # define DO_GLOBAL_CTORS_BODY \ diff --git a/gcc/config/i386/win32.h b/gcc/config/i386/win32.h index 24d8e2d..7e03383 100644 --- a/gcc/config/i386/win32.h +++ b/gcc/config/i386/win32.h @@ -233,33 +233,16 @@ do { \ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) extern void i386_pe_unique_section (); #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) #define SUPPORTS_ONE_ONLY 1 -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ -do { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \ - else \ - fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ - /* Functions may have been compiled at various levels of \ - optimization so we can't use `same_size' here. Instead, \ - have the linker pick one. */ \ - if ((DECL) && DECL_ONE_ONLY (DECL)) \ - fprintf (STREAM, "\t.linkonce %s\n", \ - TREE_CODE (DECL) == FUNCTION_DECL \ - ? "discard" : "same_size"); \ -} while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION i386_pe_asm_named_section + +/* Select attributes for named sections. */ +#define TARGET_SECTION_TYPE_FLAGS i386_pe_section_type_flags #undef ASM_COMMENT_START #define ASM_COMMENT_START " #" diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 2d85b66..ff13c38 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ #include "flags.h" #include "tm_p.h" #include "toplev.h" +#include "hashtab.h" /* i386/PE specific attribute support. @@ -55,7 +56,7 @@ void i386_pe_mark_dllimport PARAMS ((tree)); int i386_pe_valid_decl_attribute_p (decl, attributes, attr, args) tree decl; - tree attributes; + tree attributes ATTRIBUTE_UNUSED; tree attr; tree args; { @@ -455,6 +456,99 @@ i386_pe_unique_section (decl, reloc) DECL_SECTION_NAME (decl) = build_string (len, string); } + +/* Select a set of attributes for section NAME based on the properties + of DECL and whether or not RELOC indicates that DECL's initializer + might contain runtime relocations. + + We make the section read-only and executable for a function decl, + read-only for a const data decl, and writable for a non-const data decl. + + If the section has already been defined, to not allow it to have + different attributes, as (1) this is ambiguous since we're not seeing + all the declarations up front and (2) some assemblers (e.g. SVR4) + do not recoginize section redefinitions. */ +/* ??? This differs from the "standard" PE implementation in that we + handle the SHARED variable attribute. Should this be done for all + PE targets? */ + +#define SECTION_PE_SHARED SECTION_MACH_DEP + +unsigned int +i386_pe_section_type_flags (decl, name, reloc) + tree decl; + const char *name; + int reloc; +{ + static htab_t htab; + unsigned int flags; + unsigned int **slot; + + /* The names we put in the hashtable will always be the unique + versions gived to us by the stringtable, so we can just use + their addresses as the keys. */ + if (!htab) + htab = htab_create (31, htab_hash_pointer, htab_eq_pointer, NULL); + + if (decl && TREE_CODE (decl) == FUNCTION_DECL) + flags = SECTION_CODE; + else if (decl && DECL_READONLY_SECTION (decl, reloc)) + flags = 0; + else + { + flags = SECTION_WRITE; + + if (decl && TREE_CODE (decl) == VAR_DECL + && lookup_attribute ("shared", DECL_MACHINE_ATTRIBUTES (decl))) + flags |= SECTION_PE_SHARED; + } + + if (decl && DECL_ONE_ONLY (decl)) + flags |= SECTION_LINKONCE; + + /* See if we already have an entry for this section. */ + slot = (unsigned int **) htab_find_slot (htab, name, INSERT); + if (!*slot) + { + *slot = (unsigned int *) xmalloc (sizeof (unsigned int)); + **slot = flags; + } + else + { + if (decl && **slot != flags) + error_with_decl (decl, "%s causes a section type conflict"); + } + + return flags; +} + +void +i386_pe_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + char flagchars[8], *f = flagchars; + + if (flags & SECTION_CODE) + *f++ = 'x'; + if (flags & SECTION_WRITE) + *f++ = 'w'; + if (flags & SECTION_PE_SHARED) + *f++ = 's'; + *f = '\0'; + + fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars); + + if (flags & SECTION_LINKONCE) + { + /* Functions may have been compiled at various levels of + optimization so we can't use `same_size' here. + Instead, have the linker pick one. */ + fprintf (asm_out_file, "\t.linkonce %s\n", + (flags & SECTION_CODE ? "discard" : "same_size")); + } +} /* The Microsoft linker requires that every function be marked as DT_FCN. When using gas on cygwin, we must emit appropriate .type diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index 0df4ceb..b5fe7ef 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -2454,16 +2454,6 @@ do { \ /* Assembler Commands for Exception Regions. */ -/* If defined, a C string constant for the assembler operation to switch to the - section for exception handling frame unwind information. If not defined, - GNU CC will provide a default definition if the target supports named - sections. `crtstuff.c' uses this macro to switch to the appropriate - section. - - You should define this symbol if your target supports DWARF 2 frame unwind - information and the default definition does not work. */ -#define EH_FRAME_SECTION_ASM_OP "\t.section\t.IA_64.unwind,\"aw\"" - /* Select a format to encode pointers in exception handling data. CODE is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is true if the symbol may be affected by dynamic relocations. */ @@ -2551,18 +2541,6 @@ do { \ #define DWARF2_DEBUGGING_INFO -/* Section names for DWARF2 debug info. */ - -#define DEBUG_INFO_SECTION ".debug_info, \"\", \"progbits\"" -#define DEBUG_ABBREV_SECTION ".debug_abbrev, \"\", \"progbits\"" -#define DEBUG_ARANGES_SECTION ".debug_aranges, \"\", \"progbits\"" -#define DEBUG_MACINFO_SECTION ".debug_macinfo, \"\", \"progbits\"" -#define DEBUG_LINE_SECTION ".debug_line, \"\", \"progbits\"" -#define DEBUG_LOC_SECTION ".debug_loc, \"\", \"progbits\"" -#define DEBUG_PUBNAMES_SECTION ".debug_pubnames, \"\", \"progbits\"" -#define DEBUG_STR_SECTION ".debug_str, \"\", \"progbits\"" -#define DEBUG_RANGES_SECTION ".debug_ranges, \"\", \"progbits\"" - /* C string constants giving the pseudo-op to use for a sequence of 2, 4, and 8 byte unaligned constants. dwarf2out.c needs these. */ diff --git a/gcc/config/ia64/sysv4.h b/gcc/config/ia64/sysv4.h index de39c1e..ea9eb2f 100644 --- a/gcc/config/ia64/sysv4.h +++ b/gcc/config/ia64/sysv4.h @@ -47,11 +47,6 @@ do { \ ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \ } while (0) -/* ??? Intel assembler does not allow "." in section names, so turn off - gnu.linkonce section support, but only when using the Intel assembler. */ -#undef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) (TARGET_GNU_AS ? DECL_ONE_ONLY (DECL) : 0) - /* The # tells the Intel assembler that this is not a register name. However, we can't emit the # in a label definition, so we set a variable in ASM_OUTPUT_LABEL to control whether we want the postfix here or not. diff --git a/gcc/config/m68k/coff.h b/gcc/config/m68k/coff.h index 4565f77..8a63c6c 100644 --- a/gcc/config/m68k/coff.h +++ b/gcc/config/m68k/coff.h @@ -100,13 +100,9 @@ Boston, MA 02111-1307, USA. */ #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN)) -/* Support generic sections */ - -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - fprintf((FILE), ".section\t%s,\"%c\"\n", (NAME), \ - (DECL) && (TREE_CODE (DECL) == FUNCTION_DECL || \ - DECL_READONLY_SECTION (DECL, RELOC)) ? 'x' : 'd') +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION m68k_coff_asm_named_section /* Support the ctors and dtors sections for g++. */ diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index 46aeea0..b18c07c 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -60,6 +60,8 @@ static rtx find_addr_reg PARAMS ((rtx)); static const char *singlemove_string PARAMS ((rtx *)); static void m68k_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void m68k_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); +static void m68k_coff_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); /* Alignment to use for loops and jumps */ @@ -4208,3 +4210,21 @@ output_xorsi3 (operands) } return "eor%.l %2,%0"; } + +/* Output assembly to switch to section NAME with attribute FLAGS. */ + +static void +m68k_coff_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + char flagchar; + + if (flags & SECTION_WRITE) + flagchar = 'd'; + else + flagchar = 'x'; + + fprintf (asm_out_file, "\t.section\t%s,\"%c\"\n", name, flagchar); +} diff --git a/gcc/config/m68k/rtemself.h b/gcc/config/m68k/rtemself.h index 6a06d35..a8b32e6 100644 --- a/gcc/config/m68k/rtemself.h +++ b/gcc/config/m68k/rtemself.h @@ -58,9 +58,6 @@ Boston, MA 02111-1307, USA. */ #undef FINI_SECTION_ASM_OP #define FINI_SECTION_ASM_OP "\t.section\t.fini" -#undef EH_FRAME_SECTION_ASM_OP -#define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame" - /* Do I need this? */ #undef INVOKE__main diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h index 2be3432..81358f7 100644 --- a/gcc/config/m88k/m88k.h +++ b/gcc/config/m88k/m88k.h @@ -1673,7 +1673,7 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, #undef CONST_SECTION_ASM_OP #undef CTORS_SECTION_ASM_OP #undef DTORS_SECTION_ASM_OP -#undef ASM_OUTPUT_SECTION_NAME +#undef TARGET_ASM_NAMED_SECTION #undef INIT_SECTION_ASM_OP #undef FINI_SECTION_ASM_OP #undef TYPE_ASM_OP diff --git a/gcc/config/mcore/mcore-pe.h b/gcc/config/mcore/mcore-pe.h index 417271d..2d0c195 100644 --- a/gcc/config/mcore/mcore-pe.h +++ b/gcc/config/mcore/mcore-pe.h @@ -221,30 +221,8 @@ rdata_section () \ #undef DO_GLOBAL_DTORS_BODY #undef INIT_SECTION_ASM_OP -#define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL) - #define SUPPORTS_ONE_ONLY 1 -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \ - do \ - { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (STREAM, "\t.section %s,\"x\"\n", NAME); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (STREAM, "\t.section %s,\"\"\n", NAME); \ - else \ - fprintf (STREAM, "\t.section %s,\"w\"\n", NAME); \ - /* Functions may have been compiled at various levels of \ - optimization so we can't use `same_size' here. \ - Instead, have the linker pick one. */ \ - if ((DECL) && DECL_ONE_ONLY (DECL)) \ - fprintf (STREAM, "\t.linkonce %s\n", \ - TREE_CODE (DECL) == FUNCTION_DECL \ - ? "discard" : "same_size"); \ - } \ - while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION default_pe_asm_named_section diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index e1f0f33..778b734 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -132,6 +132,9 @@ static int mcore_dllexport_p PARAMS ((tree)); static int mcore_dllimport_p PARAMS ((tree)); static int mcore_valid_decl_attribute PARAMS ((tree, tree, tree, tree)); +static void mcore_asm_named_section PARAMS ((const char *, + unsigned int, + unsigned int)); /* Initialize the GCC target structure. */ #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES @@ -3594,3 +3597,12 @@ mcore_naked_function_p () { return lookup_attribute ("naked", DECL_MACHINE_ATTRIBUTES (current_function_decl)) != NULL_TREE; } + +static void +mcore_asm_named_section (name, flags, align) + const char *name; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int align ATTRIBUTE_UNUSED; +{ + fprintf (asm_out_file, "\t.section %s\n", name); +} diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index fecb9d8..3cd595e 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -1137,9 +1137,8 @@ switch_to_section (section, decl) \ } \ } - -#define ASM_OUTPUT_SECTION(file, nam) \ - do { fprintf (file, "\t.section\t%s\n", nam); } while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION mcore_asm_named_section /* This is how to output an insn to push a register on the stack. It need not be very fast code. */ diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h index 34d26c7..3ef9020 100644 --- a/gcc/config/mips/elf.h +++ b/gcc/config/mips/elf.h @@ -56,24 +56,9 @@ do { \ #undef MAX_OFILE_ALIGNMENT #define MAX_OFILE_ALIGNMENT (32768*8) -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ -do { \ - extern FILE *asm_out_text_file; \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ - else if (! strcmp (NAME, ".bss")) \ - fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \ - else \ - fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ -} while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* The following macro defines the format used to output the second operand of the .type assembler directive. Different svr4 assemblers @@ -211,8 +196,6 @@ do { \ } while (0) #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#undef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) #undef UNIQUE_SECTION #define UNIQUE_SECTION(DECL,RELOC) \ do { \ diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h index 0636200..782c62b 100644 --- a/gcc/config/mips/elf64.h +++ b/gcc/config/mips/elf64.h @@ -73,24 +73,9 @@ do { \ fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \ } while (0) -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ -do { \ - extern FILE *asm_out_text_file; \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ - else if (! strcmp (NAME, ".bss")) \ - fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \ - else \ - fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ -} while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* The following macro defines the format used to output the second operand of the .type assembler directive. Different svr4 assemblers @@ -192,8 +177,6 @@ do { \ } while (0) #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#undef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) #undef UNIQUE_SECTION #define UNIQUE_SECTION(DECL,RELOC) \ do { \ diff --git a/gcc/config/mips/iris6.h b/gcc/config/mips/iris6.h index 62ddc19..4e3a227 100644 --- a/gcc/config/mips/iris6.h +++ b/gcc/config/mips/iris6.h @@ -217,19 +217,6 @@ Boston, MA 02111-1307, USA. */ #define POPSECTION_ASM_OP "\t.popsection" -#define DEBUG_INFO_SECTION ".debug_info,0x7000001e,0,0,1" -#define DEBUG_LINE_SECTION ".debug_line,0x7000001e,0,0,1" -#define DEBUG_SFNAMES_SECTION ".debug_sfnames,0x7000001e,0,0,1" -#define DEBUG_SRCINFO_SECTION ".debug_srcinfo,0x7000001e,0,0,1" -#define DEBUG_MACINFO_SECTION ".debug_macinfo,0x7000001e,0,0,1" -#define DEBUG_PUBNAMES_SECTION ".debug_pubnames,0x7000001e,0,0,1" -#define DEBUG_ARANGES_SECTION ".debug_aranges,0x7000001e,0,0,1" -#define DEBUG_FRAME_SECTION ".debug_frame,0x7000001e,0x08000000,0,1" -#define DEBUG_ABBREV_SECTION ".debug_abbrev,0x7000001e,0,0,1" -#define DEBUG_LOC_SECTION ".debug_loc,0x7000001e,0,0,1" -#define DEBUG_STR_SECTION ".debug_str,0x7000001e,0,0,1" -#define DEBUG_RANGES_SECTION ".debug_ranges,0x7000001e,0,0,1" - /* ??? If no mabi=X option give, but a mipsX option is, then should depend on the mipsX option. */ /* If no mips[3,4] option given, give the appropriate default for mabi=X */ @@ -278,12 +265,9 @@ Boston, MA 02111-1307, USA. */ #if _MIPS_SZPTR == 64 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,1,2,0,8" #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,1,2,0,8" -#define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame,1,2,0,8" #else /* _MIPS_SZPTR != 64 */ #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,1,2,0,4" #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,1,2,0,4" -#define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame,1,2,0,4" - #endif /* _MIPS_SZPTR == 64 */ #else /* ! (defined (CRT_BEGIN) || defined (CRT_END)) */ @@ -293,8 +277,6 @@ Boston, MA 02111-1307, USA. */ (Pmode == DImode ? "\t.section\t.ctors,1,2,0,8" : "\t.section\t.ctors,1,2,0,4") #define DTORS_SECTION_ASM_OP \ (Pmode == DImode ? "\t.section\t.dtors,1,2,0,8" : "\t.section\t.dtors,1,2,0,4") -#define EH_FRAME_SECTION_ASM_OP \ - (Pmode == DImode ? "\t.section\t.eh_frame,1,2,0,8" : "\t.section\t.eh_frame,1,2,0,4") #endif /* defined (CRT_BEGIN) || defined (CRT_END) */ /* A default list of other sections which we might be "in" at any given @@ -382,22 +364,9 @@ dtors_section () \ fprintf (FILE, "\n"); \ } while (0) -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. */ - -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ -do { \ - extern FILE *asm_out_text_file; \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (asm_out_text_file, "\t.section %s,1,6,4,4\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (F, "\t.section %s,1,2,0,8\n", (NAME)); \ - else if (! strcmp (NAME, ".bss")) \ - fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \ - else \ - fprintf (F, "\t.section %s,1,3,0,8\n", (NAME)); \ -} while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION iris6_asm_named_section /* Stuff for constructors. End here. */ diff --git a/gcc/config/mips/iris6gld.h b/gcc/config/mips/iris6gld.h index 76559e3..409af7d 100644 --- a/gcc/config/mips/iris6gld.h +++ b/gcc/config/mips/iris6gld.h @@ -49,8 +49,6 @@ Boston, MA 02111-1307, USA. */ /* The GNU linker supports one-only sections. */ #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#undef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) #define UNIQUE_SECTION(DECL, RELOC) \ do \ { \ diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index fc181f6..be0033a 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -110,7 +110,9 @@ static void mips_add_gc_roots PARAMS ((void)); static void mips_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); static void mips_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static enum processor_type mips_parse_cpu PARAMS ((const char *)); - +static void iris6_asm_named_section PARAMS ((const char *, + unsigned int, + unsigned int)); /* Global variables for machine-dependent things. */ /* Threshold for data being put into the small data/bss area, instead @@ -9800,3 +9802,49 @@ mips_parse_cpu (cpu_string) return cpu; } + +/* Output assembly to switch to section NAME with attribute FLAGS. */ + +static void +iris6_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align; +{ + unsigned int sh_type, sh_flags, sh_entsize; + + sh_flags = 0; + if (!(flags & SECTION_DEBUG)) + sh_flags |= 2; /* SHF_ALLOC */ + if (flags & SECTION_WRITE) + sh_flags |= 1; /* SHF_WRITE */ + if (flags & SECTION_CODE) + sh_flags |= 4; /* SHF_EXECINSTR */ + if (flags & SECTION_SMALL) + sh_flags |= 0x10000000; /* SHF_MIPS_GPREL */ + if (strcmp (name, ".debug_frame") == 0) + sh_flags |= 0x08000000; /* SHF_MIPS_NOSTRIP */ + + if (flags & SECTION_DEBUG) + sh_type = 0x7000001e; /* SHT_MIPS_DWARF */ + else if (flags & SECTION_BSS) + sh_type = 8; /* SHT_NOBITS */ + else + sh_type = 1; /* SHT_PROGBITS */ + + if (flags & SECTION_CODE) + sh_entsize = 4; + else + sh_entsize = 0; + + if (align == 0) + { + if (flags & SECTION_CODE) + align = 4; + else + align = 8; + } + + fprintf (asm_out_file, "\t.section %s,%u,%u,%u,%u\n", + name, sh_type, sh_flags, sh_entsize, align); +} diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 0d47c08..fab6957 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -3097,10 +3097,6 @@ typedef struct mips_args { If you are changing this macro, you should look at mips_select_section and see if it needs a similar change. */ -#ifndef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) (0) -#endif - #define ENCODE_SECTION_INFO(DECL) \ do \ { \ @@ -3120,7 +3116,7 @@ do \ references again. We force it to work by putting string \ addresses in the constant pool and indirecting. */ \ && (! current_function_decl \ - || ! UNIQUE_SECTION_P (current_function_decl))) \ + || ! DECL_ONE_ONLY (current_function_decl))) \ { \ SYMBOL_REF_FLAG (XEXP (TREE_CST_RTL (DECL), 0)) = 1; \ mips_string_length += TREE_STRING_LENGTH (DECL); \ diff --git a/gcc/config/mips/netbsd.h b/gcc/config/mips/netbsd.h index e3f7821..13e7b08 100644 --- a/gcc/config/mips/netbsd.h +++ b/gcc/config/mips/netbsd.h @@ -201,24 +201,9 @@ do { \ } \ } while (0) -/* - A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. -*/ -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ -do { \ - extern FILE *asm_out_text_file; \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ - else if (! strcmp (NAME, ".bss")) \ - fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \ - else \ - fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ -} while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* Since gas and gld are standard on NetBSD, we don't need these */ #undef ASM_FINAL_SPEC diff --git a/gcc/config/mips/openbsd.h b/gcc/config/mips/openbsd.h index 14a1594..e4847ce 100644 --- a/gcc/config/mips/openbsd.h +++ b/gcc/config/mips/openbsd.h @@ -103,23 +103,9 @@ Boston, MA 02111-1307, USA. */ #undef ASM_FINAL_SPEC #undef STARTFILE_SPEC -/* A C statement to output something to the assembler file to switch to - section NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL - or NULL_TREE. Some target formats do not support arbitrary sections. - Do not define this macro in such cases. mips.h doesn't define this, - do it here. */ -#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \ -do { \ - extern FILE *asm_out_text_file; \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \ - else if (! strcmp (NAME, ".bss")) \ - fprintf (F, "\t.section %s,\"aw\",@nobits\n", (NAME)); \ - else \ - fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \ -} while (0) +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* collect2 support (Macros for initialization). */ diff --git a/gcc/config/nextstep.h b/gcc/config/nextstep.h index 76e1a35..d32675c 100644 --- a/gcc/config/nextstep.h +++ b/gcc/config/nextstep.h @@ -232,6 +232,11 @@ Boston, MA 02111-1307, USA. */ fprintf (FILE, ".reference .destructors_used\n"); \ } while (0) +/* ??? Should be changed to EH_FRAME_SECTION_NAME, but that requires + named section support. Based on this definition, it seems clear + that the object file format supports named sections, but it has + not been implemented in gcc. */ +#error "Implement named section support" #define EH_FRAME_SECTION_ASM_OP "\t.section __TEXT,__eh_frame,regular" /* Don't output a .file directive. That is only used by the assembler for diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h index 04bc25b..bc2cc92 100644 --- a/gcc/config/pa/pa64-hpux.h +++ b/gcc/config/pa/pa64-hpux.h @@ -186,72 +186,10 @@ dtors_section () \ } \ } -/* Switch into a generic section. - - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. - - If the section has already been defined, we must not - emit the attributes here. The SVR4 assembler does not - recognize section redefinitions. - If DECL is NULL, no attributes are emitted. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - do \ - { \ - static htab_t htab; \ - \ - struct section_info \ - { \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - }; \ - \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - PTR* slot; \ - \ - /* The names we put in the hashtable will always be the unique \ - versions gived to us by the stringtable, so we can just use \ - their addresses as the keys. */ \ - if (!htab) \ - htab = htab_create (31, \ - htab_hash_pointer, \ - htab_eq_pointer, \ - NULL); \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = "ax"; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ - type = SECT_RO, mode = "a"; \ - else \ - type = SECT_RW, mode = "aw"; \ - \ - \ - /* See if we already have an entry for this section. */ \ - slot = htab_find_slot (htab, NAME, INSERT); \ - if (!*slot) \ - { \ - s = (struct section_info *) xmalloc (sizeof (* s)); \ - s->type = type; \ - *slot = s; \ - fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \ - NAME, mode); \ - } \ - else \ - { \ - s = (struct section_info *) *slot; \ - if (DECL && s->type != type) \ - error_with_decl (DECL, \ - "%s causes a section type conflict"); \ - \ - fprintf (FILE, "\t.section\t%s\n", NAME); \ - } \ - } \ - while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL)) #define UNIQUE_SECTION(DECL,RELOC) \ do { \ int len; \ diff --git a/gcc/config/psos.h b/gcc/config/psos.h index 361c5bb..6f67f35 100644 --- a/gcc/config/psos.h +++ b/gcc/config/psos.h @@ -73,13 +73,8 @@ Boston, MA 02111-1307, USA. do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ fputc ('\n', FILE); } while (0) -/* Switch into a generic section. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \ - (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \ - (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw") - +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section /* Define the pseudo-ops used to switch to the .ctors and .dtors sections. */ diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 867206d..96ac5c7 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -130,6 +130,14 @@ static void rs6000_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void rs6000_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); static rtx rs6000_emit_set_long_const PARAMS ((rtx, HOST_WIDE_INT, HOST_WIDE_INT)); +#if TARGET_ELF +static unsigned int rs6000_elf_section_type_flags PARAMS ((tree, const char *, + int)); +#endif +#ifdef OBJECT_FORMAT_COFF +static void xcoff_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); +#endif /* Default register names. */ char rs6000_reg_names[][8] = @@ -177,6 +185,11 @@ static char alt_reg_names[][8] = #undef TARGET_ASM_FUNCTION_EPILOGUE #define TARGET_ASM_FUNCTION_EPILOGUE rs6000_output_function_epilogue +#if TARGET_ELF +#undef TARGET_SECTION_TYPE_FLAGS +#define TARGET_SECTION_TYPE_FLAGS rs6000_elf_section_type_flags +#endif + struct gcc_target targetm = TARGET_INITIALIZER; /* Override command line options. Mostly we process the processor @@ -8675,3 +8688,33 @@ toc_section () } #endif /* TARGET_MACHO */ + +#if TARGET_ELF +static unsigned int +rs6000_elf_section_type_flags (decl, name, reloc) + tree decl; + const char *name; + int reloc; +{ + unsigned int flags = default_section_type_flags (decl, name, reloc); + + /* ??? The flag_pic check appears redundant with the DECL_READONLY_SECTION + check in default_section_type_flags. */ + if (TARGET_RELOCATABLE || flag_pic) + flags &= ~SECTION_WRITE; + + /* Solaris doesn't like @nobits, and gas can handle .sbss without it. */ + flags &= ~SECTION_BSS; +} +#endif + +#ifdef OBJECT_FORMAT_COFF +static void +xcoff_asm_named_section (name, flags, align) + const char *name; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int align ATTRIBUTE_UNUSED; +{ + fprintf (asm_out_file, "\t.csect %s\n", name); +} +#endif diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 9871d20..3011c30 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -992,63 +992,6 @@ do { \ asm_fprintf (FILE, "%U%s", _name); \ } while (0) -/* Switch into a generic section. - - We make the section read-only and executable for a function decl, - read-only for a const data decl, and writable for a non-const data decl. - - If the section has already been defined, we must not - emit the attributes here. The SVR4 assembler does not - recognize section redefinitions. - If DECL is NULL, no attributes are emitted. - - Note, Solaris as doesn't like @nobits, and gas can handle .sbss without - needing @nobits. */ - -/* Override elfos.h definition. */ -#undef ASM_OUTPUT_SECTION_NAME -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ -do { \ - static struct section_info \ - { \ - struct section_info *next; \ - char *name; \ - enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - } *sections; \ - struct section_info *s; \ - const char *mode; \ - enum sect_enum type; \ - \ - for (s = sections; s; s = s->next) \ - if (!strcmp (NAME, s->name)) \ - break; \ - \ - if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ - type = SECT_EXEC, mode = "ax"; \ - else if (DECL && DECL_READONLY_SECTION (DECL, RELOC) && !TARGET_RELOCATABLE && !flag_pic) \ - type = SECT_RO, mode = "a"; \ - else \ - type = SECT_RW, mode = "aw"; \ - \ - if (s == 0) \ - { \ - s = (struct section_info *) xmalloc (sizeof (struct section_info)); \ - s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \ - strcpy (s->name, NAME); \ - s->type = type; \ - s->next = sections; \ - sections = s; \ - fprintf (FILE, "\t.section\t\"%s\",\"%s\"\n", NAME, mode); \ - } \ - else \ - { \ - if (DECL && s->type != type) \ - error_with_decl (DECL, "%s causes a section type conflict"); \ - \ - fprintf (FILE, "\t.section\t\"%s\"\n", NAME); \ - } \ -} while (0) - /* Override elfos.h definition. */ #undef ASM_OUTPUT_CONSTRUCTOR #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 53cc7e7..4d0a7fd 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -489,11 +489,8 @@ toc_section () \ } \ } while (0) -#define ASM_OUTPUT_SECTION_NAME(ASM_OUT_FILE,DECL,NAME,RELOC) \ - do { fputs ("\t.csect ", ASM_OUT_FILE); \ - fputs (TREE_STRING_POINTER (DECL_SECTION_NAME (DECL)), ASM_OUT_FILE); \ - putc ('\n', ASM_OUT_FILE); \ - } while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION xcoff_asm_named_section /* Define the name of the section to use for the exception tables. TODO: test and see if we can use read_only_data_section, if so, diff --git a/gcc/config/sh/elf.h b/gcc/config/sh/elf.h index 5acfe75..183fa96 100644 --- a/gcc/config/sh/elf.h +++ b/gcc/config/sh/elf.h @@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */ #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END #undef CTORS_SECTION_ASM_OP #undef DTORS_SECTION_ASM_OP -#undef ASM_OUTPUT_SECTION_NAME +#undef TARGET_ASM_NAMED_SECTION #undef ASM_OUTPUT_CONSTRUCTOR #undef ASM_OUTPUT_DESTRUCTOR #undef ASM_DECLARE_FUNCTION_NAME diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 87b5be9..6c2104f 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -156,6 +156,8 @@ static rtx mark_constant_pool_use PARAMS ((rtx)); static int sh_valid_decl_attribute PARAMS ((tree, tree, tree, tree)); static void sh_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); static void sh_insert_attributes PARAMS ((tree, tree *)); +static void sh_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); /* Initialize the GCC target structure. */ #undef TARGET_VALID_DECL_ATTRIBUTE @@ -5556,3 +5558,12 @@ sh_can_redirect_branch (branch1, branch2) return 0; } +static void +sh_asm_named_section (name, flags, align) + const char *name; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int flags ATTRIBUTE_UNUSED; +{ + /* ??? Perhaps we should be using default_coff_asm_named_section. */ + fprintf (asm_out_file, "\t.section %s\n", name); +} diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index e82a9d2..1377610 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -1948,13 +1948,8 @@ dtors_section() \ which could be text or it could be a user defined section. */ #define JUMP_TABLES_IN_TEXT_SECTION 1 -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ - do { fprintf (FILE, ".section\t%s\n", NAME); } while (0) +/* Switch into a generic section. */ +#define TARGET_ASM_NAMED_SECTION sh_asm_named_section /* This is the pseudo-op used to generate a reference to a specific symbol in some section. */ diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index e7413ee..2693f73 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -164,6 +164,8 @@ static void sparc_nonflat_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT, int)); static void sparc_nonflat_function_prologue PARAMS ((FILE *, HOST_WIDE_INT, int)); +static void sparc_elf_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); /* Option handling. */ @@ -8688,3 +8690,23 @@ sparc_add_gc_roots () ggc_add_root (ultra_pipe_hist, ARRAY_SIZE (ultra_pipe_hist), sizeof (ultra_pipe_hist[0]), &mark_ultrasparc_pipeline_state); } + +static void +sparc_elf_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + fprintf (asm_out_file, "\t.section\t\"%s\"", name); + + if (!(flags & SECTION_DEBUG)) + fputs (",#alloc", asm_out_file); + if (flags & SECTION_WRITE) + fputs (",#write", asm_out_file); + if (flags & SECTION_CODE) + fputs (",#execinstr", asm_out_file); + + /* ??? Handle SECTION_BSS. */ + + fputc ('\n', asm_out_file); +} diff --git a/gcc/config/sparc/sysv4.h b/gcc/config/sparc/sysv4.h index 19b7f15..4cd0b39 100644 --- a/gcc/config/sparc/sysv4.h +++ b/gcc/config/sparc/sysv4.h @@ -182,25 +182,10 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \ #define CTORS_SECTION_ASM_OP "\t.section\t\".ctors\",#alloc,#write" #undef DTORS_SECTION_ASM_OP #define DTORS_SECTION_ASM_OP "\t.section\t\".dtors\",#alloc,#write" -#undef EH_FRAME_SECTION_ASM_OP -#define EH_FRAME_SECTION_ASM_OP "\t.section\t\".eh_frame\",#alloc,#write" - -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ -do { \ - if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ - fprintf (FILE, ".section\t\"%s\",#alloc,#execinstr\n", \ - (NAME)); \ - else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \ - fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \ - else \ - fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \ -} while (0) + +/* Switch into a generic section. */ +#undef TARGET_ASM_NAMED_SECTION +#define TARGET_ASM_NAMED_SECTION sparc_elf_asm_named_section /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 4d1ca2c..666c31b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2861,11 +2861,11 @@ finish_objects (method_type, initp, body) else assemble_destructor (fnname); } -#if defined (ASM_OUTPUT_SECTION_NAME) && defined (ASM_OUTPUT_CONSTRUCTOR) +#if defined (ASM_OUTPUT_CONSTRUCTOR) /* If we're using init priority we can't use assemble_*tor, but on ELF targets we can stick the references into named sections for GNU ld to collect. */ - else + else if (targetm.have_named_sections) { char buf[15]; sprintf (buf, ".%ctors.%.5u", method_type == 'I' ? 'c' : 'd', diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c index 9f62009..75e9441 100644 --- a/gcc/crtstuff.c +++ b/gcc/crtstuff.c @@ -211,7 +211,7 @@ __do_global_dtors_aux (void) f (); } -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME #if defined(CRT_GET_RFIB_TEXT) || defined(CRT_GET_RFIB_DATA) /* If we used the new __register_frame_info_bases interface, make sure that we deregister from the same place. */ @@ -240,7 +240,7 @@ fini_dummy (void) asm (TEXT_SECTION_ASM_OP); } -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME /* Stick a call to __register_frame_info into the .init section. For some reason calls with no arguments work more reliably in .init, so stick the call in another function. */ @@ -279,7 +279,7 @@ init_dummy (void) #endif asm (TEXT_SECTION_ASM_OP); } -#endif /* EH_FRAME_SECTION_ASM_OP */ +#endif /* EH_FRAME_SECTION_NAME */ #else /* OBJECT_FORMAT_ELF */ @@ -350,13 +350,13 @@ __do_global_dtors (void) for (p = __DTOR_LIST__ + 1; (f = *p); p++) f (); -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME if (__deregister_frame_info) __deregister_frame_info (__EH_FRAME_BEGIN__); #endif } -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME /* Define a function here to call __register_frame. crtend.o is linked in after libgcc.a, and hence can't call libgcc.a functions directly. That can lead to unresolved function references. */ @@ -404,16 +404,16 @@ asm (DTORS_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */ STATIC func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) }; #endif -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME /* Stick a label at the beginning of the frame unwind info so we can register and deregister it with the exception handling library code. */ - -asm (EH_FRAME_SECTION_ASM_OP); #ifdef INIT_SECTION_ASM_OP STATIC #endif -char __EH_FRAME_BEGIN__[] = { }; -#endif /* EH_FRAME_SECTION_ASM_OP */ +char __EH_FRAME_BEGIN__[] + __attribute__((section(EH_FRAME_SECTION_NAME))) + = { }; +#endif /* EH_FRAME_SECTION_NAME */ #endif /* defined(CRT_BEGIN) */ @@ -494,14 +494,14 @@ asm (TEXT_SECTION_ASM_OP); not an SVR4-style .init section. __do_global_ctors can be non-static in this case because we protect it with -hidden_symbol. */ static func_ptr __CTOR_END__[]; -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME extern void __frame_dummy (void); #endif void __do_global_ctors (void) { func_ptr *p; -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME __frame_dummy (); #endif for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) @@ -535,13 +535,12 @@ STATIC func_ptr __DTOR_END__[1] __attribute__ ((__unused__)) = { (func_ptr) 0 }; #endif -#ifdef EH_FRAME_SECTION_ASM_OP +#ifdef EH_FRAME_SECTION_NAME /* Terminate the frame unwind info section with a 4byte 0 as a sentinel; this would be the 'length' field in a real FDE. */ - -typedef unsigned int ui32 __attribute__ ((mode (SI))); -asm (EH_FRAME_SECTION_ASM_OP); -STATIC ui32 __FRAME_END__[] __attribute__ ((__unused__)) = { 0 }; +STATIC int __FRAME_END__[] + __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME))) + = { 0 }; #endif /* EH_FRAME_SECTION */ #endif /* defined(CRT_END) */ @@ -601,14 +600,9 @@ __dereg_frame_dtor (void) } /* Terminate the frame section with a final zero. */ - -/* Force cc1 to switch to .data section. */ -static void * force_to_data[1] __attribute__ ((__unused__)) = { }; - -typedef unsigned int ui32 __attribute__ ((mode (SI))); -asm (EH_FRAME_SECTION_ASM_OP); -static ui32 __FRAME_END__[] __attribute__ ((__unused__)) = { 0 }; - +STATIC int __FRAME_END__[] + __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME))) + = { 0 }; #endif /* CRT_END */ #endif /* OBJECT_FORMAT_MACHO */ diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 4eea7ca..60a91fe 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -83,6 +83,7 @@ Boston, MA 02111-1307, USA. */ #include "tm_p.h" #include "ggc.h" #include "debug.h" +#include "target.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" @@ -290,9 +291,7 @@ static void dbxout_start_source_file PARAMS ((unsigned, const char *)); static void dbxout_end_source_file PARAMS ((unsigned)); static void dbxout_source_line PARAMS ((unsigned int, const char *)); static void dbxout_source_file PARAMS ((FILE *, const char *)); -#if defined(ASM_OUTPUT_SECTION_NAME) static void dbxout_function_end PARAMS ((void)); -#endif static void dbxout_typedefs PARAMS ((tree)); static void dbxout_type_index PARAMS ((tree)); #if DBX_CONTIN_LENGTH > 0 @@ -378,7 +377,6 @@ struct gcc_debug_hooks xcoff_debug_hooks = }; #endif /* XCOFF_DEBUGGING_INFO */ -#if defined(ASM_OUTPUT_SECTION_NAME) static void dbxout_function_end () { @@ -399,7 +397,6 @@ dbxout_function_end () assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); fprintf (asmfile, "\n"); } -#endif /* ! NO_DBX_FUNCTION_END */ /* At the beginning of compilation, start writing the symbol table. Initialize `typevec' and output the standard data types of C. */ @@ -642,14 +639,12 @@ dbxout_function_decl (decl) #ifdef DBX_OUTPUT_FUNCTION_END DBX_OUTPUT_FUNCTION_END (asmfile, decl); #endif -#if defined(ASM_OUTPUT_SECTION_NAME) if (use_gnu_debug_info_extensions #if defined(NO_DBX_FUNCTION_END) && ! NO_DBX_FUNCTION_END #endif - ) + && targetm.have_named_sections) dbxout_function_end (); -#endif } #endif /* DBX_DEBUGGING_INFO */ diff --git a/gcc/defaults.h b/gcc/defaults.h index d2724f3..2072924 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -209,23 +209,17 @@ do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNATE_NAME (INSN)); } while (0) #define DWARF2_UNWIND_INFO 1 #endif -#if defined (DWARF2_UNWIND_INFO) && !defined (EH_FRAME_SECTION) -# if defined (EH_FRAME_SECTION_ASM_OP) -# define EH_FRAME_SECTION() eh_frame_section () -# else - /* If we aren't using crtstuff to run ctors, don't use it for EH. */ -# if defined (ASM_OUTPUT_SECTION_NAME) && defined (ASM_OUTPUT_CONSTRUCTOR) -# define EH_FRAME_SECTION_ASM_OP "\t.section\t.eh_frame,\"aw\"" -# define EH_FRAME_SECTION() \ - do { named_section (NULL_TREE, ".eh_frame", 0); } while (0) -# endif -# endif +/* If we have named section, and we're using crtstuff to run ctors, + then use named sections for registering eh frame information. */ +#if defined (TARGET_ASM_NAMED_SECTION) && defined (ASM_OUTPUT_CONSTRUCTOR) +#ifndef EH_FRAME_SECTION_NAME +#define EH_FRAME_SECTION_NAME ".eh_frame" +#endif #endif /* If we have no definition for UNIQUE_SECTION, but do have the ability to generate arbitrary sections, construct something reasonable. */ -#ifdef ASM_OUTPUT_SECTION_NAME #ifndef UNIQUE_SECTION #define UNIQUE_SECTION(DECL,RELOC) \ do { \ @@ -244,10 +238,6 @@ do { \ DECL_SECTION_NAME (DECL) = build_string (len, string); \ } while (0) #endif -#ifndef UNIQUE_SECTION_P -#define UNIQUE_SECTION_P(DECL) 0 -#endif -#endif /* By default, we generate a label at the beginning and end of the text section, and compute the size of the text section by diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index bdee2f8..e9c747a 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5614,14 +5614,6 @@ Decode @var{sym_name} and store the real name part in @var{var}, sans the characters that encode section info. Define this macro if @code{ENCODE_SECTION_INFO} alters the symbol's name string. -@findex UNIQUE_SECTION_P -@item UNIQUE_SECTION_P (@var{decl}) -A C expression which evaluates to true if @var{decl} should be placed -into a unique section for some target-specific reason. If you do not -define this macro, the default is @samp{0}. Note that the flag -@option{-ffunction-sections} will also cause functions to be placed into -unique sections. - @findex UNIQUE_SECTION @item UNIQUE_SECTION (@var{decl}, @var{reloc}) A C statement to build up a unique section name, expressed as a @@ -5803,21 +5795,6 @@ A C statement to output something to the assembler file to handle a @samp{#ident} directive containing the text @var{string}. If this macro is not defined, nothing is output for a @samp{#ident} directive. -@findex ASM_OUTPUT_SECTION_NAME -@item ASM_OUTPUT_SECTION_NAME (@var{stream}, @var{decl}, @var{name}, @var{reloc}) -A C statement to output something to the assembler file to switch to section -@var{name} for object @var{decl} which is either a @code{FUNCTION_DECL}, a -@code{VAR_DECL} or @code{NULL_TREE}. @var{reloc} -indicates whether the initial value of @var{exp} requires link-time -relocations. The string given by @var{name} will always be the -canonical version stored in the global stringpool. - -Some target formats do not support arbitrary sections. Do not define -this macro in such cases. - -At present this macro is only used to support section attributes. -When this macro is undefined, section attributes are disabled. - @findex OBJC_PROLOGUE @item OBJC_PROLOGUE A C statement to output any assembler statements which are required to @@ -5825,6 +5802,32 @@ precede any Objective-C object definitions or message sending. The statement is executed only when compiling an Objective-C program. @end table +@deftypefn {Target Hook} void TARGET_ASM_NAMED_SECTION (const char *@var{name}, unsigned int @var{flags}, unsigned int @var{align}) +Output assembly directives to switch to section @var{name}. The section +should have attributes as specified by @var{flags}, which is a bit mask +of the @code{SECTION_*} flags defined in @file{output.h}. If @var{align} +is non-zero, it contains an alignment in bytes to be used for the section, +otherwise some target default should be used. Only targets that must +specify an alignment within the section directive need pay attention to +@var{align} -- we will still use @code{ASM_OUTPUT_ALIGN}. +@end deftypefn + +@deftypefn {Target Hook} bool TARGET_HAVE_NAMED_SECTIONS +This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}. +@end deftypefn + +@deftypefn {Target Hook} {unsigned int} TARGET_SECTION_TYPE_FLAGS (tree @var{decl}, const char *@var{name}, int @var{reloc}) +Choose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION} +based on a variable or function decl, a section name, and whether or not the +declaration's initializer may contain runtime relocations. @var{decl} may be + null, in which case read-write data should be assumed. + +The default version if this function handles choosing code vs data, +read-only vs read-write data, and @code{flag_pic}. You should only +need to override this if your target has special flags that might be +set via @code{__attribute__}. +@end deftypefn + @need 2000 @node Data Output @subsection Output of Data @@ -7058,17 +7061,16 @@ This macro need not be defined on most platforms. A C expression to switch to the section in which the main exception table is to be placed (@pxref{Sections}). The default is a section named @code{.gcc_except_table} on machines that support named -sections via @code{ASM_OUTPUT_SECTION_NAME}, otherwise if @option{-fpic} +sections via @code{TARGET_ASM_NAMED_SECTION}, otherwise if @option{-fpic} or @option{-fPIC} is in effect, the @code{data_section}, otherwise the @code{readonly_data_section}. -@findex EH_FRAME_SECTION_ASM_OP -@item EH_FRAME_SECTION_ASM_OP -If defined, a C string constant, including spacing, for the assembler -operation to switch to the section for exception handling frame unwind -information. If not defined, GCC will provide a default definition if the -target supports named sections. @file{crtstuff.c} uses this macro to -switch to the appropriate section. +@findex EH_FRAME_SECTION_NAME +@item EH_FRAME_SECTION_NAME +If defined, a C string constant for the name of the section containing +exception handling frame unwind information. If not defined, GCC will +provide a default definition if the target supports named sections. +@file{crtstuff.c} uses this macro to switch to the appropriate section. You should define this symbol if your target supports DWARF 2 frame unwind information and the default definition does not work. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index bf72954..bedbf8e 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -277,18 +277,6 @@ static void def_cfa_1 PARAMS ((const char *, dw_cfa_location *)); #define SECTION_ASM_OP "\t.section\t" #endif -/* The default format used by the ASM_OUTPUT_SECTION macro (see below) to - print the SECTION_ASM_OP and the section name. The default here works for - almost all svr4 assemblers, except for the sparc, where the section name - must be enclosed in double quotes. (See sparcv4.h). */ -#ifndef SECTION_FORMAT -#ifdef PUSHSECTION_FORMAT -#define SECTION_FORMAT PUSHSECTION_FORMAT -#else -#define SECTION_FORMAT "%s%s\n" -#endif -#endif - #ifndef DEBUG_FRAME_SECTION #define DEBUG_FRAME_SECTION ".debug_frame" #endif @@ -316,11 +304,6 @@ static void def_cfa_1 PARAMS ((const char *, dw_cfa_location *)); output operations. These may be overridden from within the tm.h file, but typically, that is unnecessary. */ -#ifndef ASM_OUTPUT_SECTION -#define ASM_OUTPUT_SECTION(FILE, SECTION) \ - fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION) -#endif - #ifdef SET_ASM_OP #ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \ @@ -1753,12 +1736,13 @@ output_call_frame_info (for_eh) if (for_eh) { -#ifdef EH_FRAME_SECTION - EH_FRAME_SECTION (); +#ifdef EH_FRAME_SECTION_NAME + named_section_flags (EH_FRAME_SECTION_NAME, SECTION_WRITE, + DWARF_OFFSET_SIZE); #else tree label = get_file_function_name ('F'); - force_data_section (); + data_section (); ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE)); ASM_GLOBALIZE_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); @@ -1766,7 +1750,7 @@ output_call_frame_info (for_eh) assemble_label ("__FRAME_BEGIN__"); } else - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_FRAME_SECTION); + named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG, 1); /* Output the CIE. */ ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh); @@ -1984,7 +1968,7 @@ output_call_frame_info (for_eh) ASM_OUTPUT_LABEL (asm_out_file, l2); } -#ifndef EH_FRAME_SECTION +#ifndef EH_FRAME_SECTION_NAME if (for_eh) dw2_asm_output_data (4, 0, "End of Table"); #endif @@ -6336,7 +6320,7 @@ output_comp_unit (die) secname = (const char *) DEBUG_INFO_SECTION; /* Output debugging information. */ - ASM_OUTPUT_SECTION (asm_out_file, secname); + named_section_flags (secname, SECTION_DEBUG, 1); output_compilation_unit_header (); output_die (die); @@ -11574,10 +11558,12 @@ dwarf2out_start_source_file (lineno, filename) } if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION); + named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1); dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file"); - dw2_asm_output_data_uleb128 (lineno, "Included from line number %d", lineno); - dw2_asm_output_data_uleb128 (lookup_filename (filename), "Filename we just started"); + dw2_asm_output_data_uleb128 (lineno, "Included from line number %d", + lineno); + dw2_asm_output_data_uleb128 (lookup_filename (filename), + "Filename we just started"); } } @@ -11594,7 +11580,7 @@ dwarf2out_end_source_file (lineno) } if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION); + named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1); dw2_asm_output_data (1, DW_MACINFO_end_file, "End file"); } } @@ -11616,7 +11602,7 @@ dwarf2out_define (lineno, buffer) } if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION); + named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1); dw2_asm_output_data (1, DW_MACINFO_define, "Define macro"); dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno); dw2_asm_output_nstring (buffer, -1, "The macro"); @@ -11634,7 +11620,7 @@ dwarf2out_undef (lineno, buffer) { if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION); + named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1); dw2_asm_output_data (1, DW_MACINFO_undef, "Undefine macro"); dw2_asm_output_data_uleb128 (lineno, "At line number %d", lineno); dw2_asm_output_nstring (buffer, -1, "The macro"); @@ -11707,26 +11693,27 @@ dwarf2out_init (main_input_filename) ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label, DEBUG_LINE_SECTION_LABEL, 0); ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, 0); - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LOC_SECTION); + named_section_flags (DEBUG_LOC_SECTION, SECTION_DEBUG, 1); ASM_OUTPUT_LABEL (asm_out_file, loc_section_label); - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_ABBREV_SECTION); + named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG, 1); ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label); - if (DWARF2_GENERATE_TEXT_SECTION_LABEL) - { - ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION); - ASM_OUTPUT_LABEL (asm_out_file, text_section_label); - } - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_INFO_SECTION); + named_section_flags (DEBUG_INFO_SECTION, SECTION_DEBUG, 1); ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label); - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION); + named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG, 1); ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label); if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION); + named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1); ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label, DEBUG_MACINFO_SECTION_LABEL, 0); ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label); } + + if (DWARF2_GENERATE_TEXT_SECTION_LABEL) + { + text_section (); + ASM_OUTPUT_LABEL (asm_out_file, text_section_label); + } } /* Output stuff that dwarf requires at the end of every file, @@ -11783,19 +11770,9 @@ dwarf2out_finish (input_filename) add_sibling_attributes (node->die); /* Output a terminator label for the .text section. */ - ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION); + text_section (); ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, TEXT_END_LABEL, 0); -#if 0 - /* Output a terminator label for the .data section. */ - ASM_OUTPUT_SECTION (asm_out_file, DATA_SECTION); - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, DATA_END_LABEL, 0); - - /* Output a terminator label for the .bss section. */ - ASM_OUTPUT_SECTION (asm_out_file, BSS_SECTION); - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, BSS_END_LABEL, 0); -#endif - /* Output the source line correspondence table. We must do this even if there is no line information. Otherwise, on an empty translation unit, we will generate a present, but empty, @@ -11803,7 +11780,7 @@ dwarf2out_finish (input_filename) examining the file. */ if (! DWARF2_ASM_LINE_DEBUG_INFO) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LINE_SECTION); + named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG, 1); output_line_info (); } @@ -11834,13 +11811,13 @@ dwarf2out_finish (input_filename) output_comp_unit (comp_unit_die); /* Output the abbreviation table. */ - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_ABBREV_SECTION); + named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG, 1); output_abbrev_section (); if (pubname_table_in_use) { /* Output public names table. */ - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION); + named_section_flags (DEBUG_PUBNAMES_SECTION, SECTION_DEBUG, 1); output_pubnames (); } @@ -11849,7 +11826,7 @@ dwarf2out_finish (input_filename) if (fde_table_in_use) { /* Output the address range information. */ - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_ARANGES_SECTION); + named_section_flags (DEBUG_ARANGES_SECTION, SECTION_DEBUG, 1); output_aranges (); } @@ -11857,7 +11834,7 @@ dwarf2out_finish (input_filename) if (have_location_lists) { /* Output the location lists info. */ - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_LOC_SECTION); + named_section_flags (DEBUG_LOC_SECTION, SECTION_DEBUG, 1); output_location_lists (die); have_location_lists = 0; } @@ -11865,14 +11842,14 @@ dwarf2out_finish (input_filename) /* Output ranges section if necessary. */ if (ranges_table_in_use) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_RANGES_SECTION); + named_section_flags (DEBUG_RANGES_SECTION, SECTION_DEBUG, 1); output_ranges (); } /* Have to end the primary source file. */ if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - ASM_OUTPUT_SECTION (asm_out_file, DEBUG_MACINFO_SECTION); + named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG, 1); dw2_asm_output_data (1, DW_MACINFO_end_file, "End file"); } } diff --git a/gcc/output.h b/gcc/output.h index 58c4062..f28c7af 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -159,10 +159,6 @@ extern void readonly_data_section PARAMS ((void)); /* Determine if we're in the text section. */ extern int in_text_section PARAMS ((void)); -#ifdef EH_FRAME_SECTION_ASM_OP -extern void eh_frame_section PARAMS ((void)); -#endif - #ifdef CTORS_SECTION_ASM_OP extern void ctors_section PARAMS ((void)); #endif @@ -459,3 +455,30 @@ extern void default_function_pro_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); /* Default target hook that outputs nothing to a stream. */ extern void no_asm_to_stream PARAMS ((FILE *)); + +/* Flags controling properties of a section. */ +#define SECTION_CODE 1 /* contains code */ +#define SECTION_WRITE 2 /* data is writable */ +#define SECTION_DEBUG 4 /* contains debug data */ +#define SECTION_LINKONCE 8 /* is linkonce */ +#define SECTION_SMALL 16 /* contains "small data" */ +#define SECTION_BSS 32 /* contains zeros only */ +#define SECTION_FORGET 64 /* forget that we've entered the section */ +#define SECTION_MACH_DEP 128 /* subsequent bits reserved for target */ + +extern void named_section_flags PARAMS ((const char *, unsigned int, + unsigned int)); + +union tree_node; +extern unsigned int default_section_type_flags PARAMS ((union tree_node *, + const char *, int)); + +extern void default_no_named_section PARAMS ((const char *, unsigned int, + unsigned int)); +extern void default_elf_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); +extern void default_coff_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); +extern void default_pe_asm_named_section PARAMS ((const char *, unsigned int, + unsigned int)); + diff --git a/gcc/target-def.h b/gcc/target-def.h index 264d22b..939ca8f 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -33,12 +33,20 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream #define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream +#ifdef TARGET_ASM_NAMED_SECTION +#define TARGET_HAVE_NAMED_SECTIONS true +#else +#define TARGET_ASM_NAMED_SECTION default_no_named_section +#define TARGET_HAVE_NAMED_SECTIONS false +#endif + #define TARGET_ASM_OUT {TARGET_ASM_OPEN_PAREN, \ TARGET_ASM_CLOSE_PAREN, \ TARGET_ASM_FUNCTION_PROLOGUE, \ TARGET_ASM_FUNCTION_END_PROLOGUE, \ TARGET_ASM_FUNCTION_BEGIN_EPILOGUE, \ - TARGET_ASM_FUNCTION_EPILOGUE} + TARGET_ASM_FUNCTION_EPILOGUE, \ + TARGET_ASM_NAMED_SECTION} /* All in tree.c. */ #define TARGET_MERGE_DECL_ATTRIBUTES merge_decl_attributes @@ -53,6 +61,11 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_INIT_BUILTINS default_init_builtins #define TARGET_EXPAND_BUILTIN default_expand_builtin +/* In varasm.c. */ +#ifndef TARGET_SECTION_TYPE_FLAGS +#define TARGET_SECTION_TYPE_FLAGS default_section_type_flags +#endif + /* The whole shebang. */ #define TARGET_INITIALIZER \ { \ @@ -65,5 +78,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_SET_DEFAULT_TYPE_ATTRIBUTES, \ TARGET_INSERT_ATTRIBUTES, \ TARGET_INIT_BUILTINS, \ - TARGET_EXPAND_BUILTIN \ + TARGET_EXPAND_BUILTIN, \ + TARGET_SECTION_TYPE_FLAGS, \ + TARGET_HAVE_NAMED_SECTIONS \ } diff --git a/gcc/target.h b/gcc/target.h index fdd0bb1..d3f32fa 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -66,6 +66,12 @@ struct gcc_target /* Output the assembler code for function exit. */ void (* function_epilogue) PARAMS ((FILE *, HOST_WIDE_INT)); + + /* Switch to an arbitrary section NAME with attributes as specified + by FLAGS. ALIGN specifies any known alignment requirements for + the section; 0 if the default should be used. */ + void (* named_section) PARAMS ((const char *, unsigned int, + unsigned int)); } asm_out; /* Given two decls, merge their attributes and return the result. */ @@ -106,6 +112,14 @@ struct gcc_target struct rtx_def *subtarget, enum machine_mode mode, int ignore)); + + /* Given a decl, a section name, and whether the decl initializer + has relocs, choose attributes for the section. */ + /* ??? Should be merged with SELECT_SECTION and UNIQUE_SECTION. */ + unsigned int (* section_type_flags) PARAMS ((tree, const char *, int)); + + /* True if arbitrary sections are supported. */ + bool have_named_sections; }; extern struct gcc_target targetm; diff --git a/gcc/toplev.c b/gcc/toplev.c index f3b50d1..b69ea3f 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -67,6 +67,7 @@ Boston, MA 02111-1307, USA. */ #include "dwarf2asm.h" #include "integrate.h" #include "debug.h" +#include "target.h" #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) #include "dwarf2out.h" @@ -2267,18 +2268,19 @@ compile_file (name) debug_hooks = &dwarf2_debug_hooks; #endif -#ifndef ASM_OUTPUT_SECTION_NAME - if (flag_function_sections) + if (! targetm.have_named_sections) { - warning ("-ffunction-sections not supported for this target."); - flag_function_sections = 0; - } - if (flag_data_sections) - { - warning ("-fdata-sections not supported for this target."); - flag_data_sections = 0; + if (flag_function_sections) + { + warning ("-ffunction-sections not supported for this target."); + flag_function_sections = 0; + } + if (flag_data_sections) + { + warning ("-fdata-sections not supported for this target."); + flag_data_sections = 0; + } } -#endif if (flag_function_sections && (profile_flag || profile_block_flag)) diff --git a/gcc/varasm.c b/gcc/varasm.c index bb723c8..d574a80 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -46,6 +46,7 @@ Boston, MA 02111-1307, USA. */ #include "ggc.h" #include "tm_p.h" #include "debug.h" +#include "target.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" /* Needed for external data @@ -181,14 +182,12 @@ static hashval_t const_str_htab_hash PARAMS ((const void *x)); static int const_str_htab_eq PARAMS ((const void *x, const void *y)); static void const_str_htab_del PARAMS ((void *)); static void asm_emit_uninitialised PARAMS ((tree, const char*, int, int)); +static void resolve_unique_section PARAMS ((tree, int)); static enum in_section { no_section, in_text, in_data, in_named #ifdef BSS_SECTION_ASM_OP , in_bss #endif -#ifdef EH_FRAME_SECTION_ASM_OP - , in_eh_frame -#endif #ifdef EXTRA_SECTIONS , EXTRA_SECTIONS #endif @@ -281,6 +280,28 @@ in_data_section () return in_section == in_data; } +/* Tell assembler to change to section NAME with attributes FLAGS. */ + +void +named_section_flags (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align; +{ + if (in_section != in_named || strcmp (name, in_named_name)) + { + (* targetm.asm_out.named_section) (name, flags, align); + + if (flags & SECTION_FORGET) + in_section = no_section; + else + { + in_named_name = ggc_strdup (name); + in_section = in_named; + } + } +} + /* Tell assembler to change to section NAME for DECL. If DECL is NULL, just switch to section NAME. If NAME is NULL, get the name from DECL. @@ -290,27 +311,31 @@ void named_section (decl, name, reloc) tree decl; const char *name; - int reloc ATTRIBUTE_UNUSED; + int reloc; { + unsigned int flags; + if (decl != NULL_TREE && !DECL_P (decl)) abort (); if (name == NULL) name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); - if (in_section != in_named || strcmp (name, in_named_name)) - { -#ifdef ASM_OUTPUT_SECTION_NAME - ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc); -#else - /* Section attributes are not supported if this macro isn't provided - - some host formats don't support them at all. The front-end should - already have flagged this as an error. */ - abort (); -#endif + flags = (* targetm.section_type_flags) (decl, name, reloc); + named_section_flags (name, flags, 0); +} - in_named_name = ggc_strdup (name); - in_section = in_named; - } +/* If required, set DECL_SECTION_NAME to a unique name. */ + +static void +resolve_unique_section (decl, reloc) + tree decl; + int reloc; +{ + if (DECL_SECTION_NAME (decl) == NULL_TREE + && (flag_function_sections + || (targetm.have_named_sections + && DECL_ONE_ONLY (decl)))) + UNIQUE_SECTION (decl, reloc); } #ifdef BSS_SECTION_ASM_OP @@ -392,18 +417,6 @@ asm_output_aligned_bss (file, decl, name, size, align) #endif /* BSS_SECTION_ASM_OP */ -#ifdef EH_FRAME_SECTION_ASM_OP -void -eh_frame_section () -{ - if (in_section != in_eh_frame) - { - fprintf (asm_out_file, "%s\n", EH_FRAME_SECTION_ASM_OP); - in_section = in_eh_frame; - } -} -#endif - /* Switch to the section for function DECL. If DECL is NULL_TREE, switch to the text section. @@ -467,15 +480,13 @@ exception_section () #if defined (EXCEPTION_SECTION) EXCEPTION_SECTION (); #else -#ifdef ASM_OUTPUT_SECTION_NAME - named_section (NULL_TREE, ".gcc_except_table", 0); -#else - if (flag_pic) + if (targetm.have_named_sections) + named_section (NULL_TREE, ".gcc_except_table", 0); + else if (flag_pic) data_section (); else readonly_data_section (); #endif -#endif } /* Given NAME, a putative register name, discard any customary prefixes. */ @@ -896,15 +907,7 @@ assemble_start_function (decl, fnname) if (CONSTANT_POOL_BEFORE_FUNCTION) output_constant_pool (fnname, decl); -#ifdef ASM_OUTPUT_SECTION_NAME - /* If the function is to be put in its own section and it's not in a section - already, indicate so. */ - if ((flag_function_sections - && DECL_SECTION_NAME (decl) == NULL_TREE) - || UNIQUE_SECTION_P (decl)) - UNIQUE_SECTION (decl, 0); -#endif - + resolve_unique_section (decl, 0); function_section (decl); /* Tell assembler to move to target machine's alignment for functions. */ @@ -1163,12 +1166,8 @@ asm_emit_uninitialised (decl, name, size, rounded) } } -#ifdef ASM_OUTPUT_SECTION_NAME - /* We already know that DECL_SECTION_NAME() == NULL. */ - if (flag_data_sections != 0 || UNIQUE_SECTION_P (decl)) - UNIQUE_SECTION (decl, 0); -#endif - + resolve_unique_section (decl, 0); + switch (destination) { #ifdef ASM_EMIT_BSS @@ -1396,13 +1395,8 @@ assemble_variable (decl, top_level, at_end, dont_output_data) else if (DECL_INITIAL (decl)) reloc = output_addressed_constants (DECL_INITIAL (decl)); -#ifdef ASM_OUTPUT_SECTION_NAME - if ((flag_data_sections != 0 && DECL_SECTION_NAME (decl) == NULL_TREE) - || UNIQUE_SECTION_P (decl)) - UNIQUE_SECTION (decl, reloc); -#endif - /* Switch to the appropriate section. */ + resolve_unique_section (decl, reloc); variable_section (decl, reloc); /* dbxout.c needs to know this. */ @@ -4765,3 +4759,142 @@ init_varasm_once () ggc_add_root (&const_str_htab, 1, sizeof const_str_htab, mark_const_str_htab); } + +/* Select a set of attributes for section NAME based on the properties + of DECL and whether or not RELOC indicates that DECL's initializer + might contain runtime relocations. + + We make the section read-only and executable for a function decl, + read-only for a const data decl, and writable for a non-const data decl. + + If the section has already been defined, to not allow it to have + different attributes, as (1) this is ambiguous since we're not seeing + all the declarations up front and (2) some assemblers (e.g. SVR4) + do not recoginize section redefinitions. */ + +unsigned int +default_section_type_flags (decl, name, reloc) + tree decl; + const char *name; + int reloc; +{ + static htab_t htab; + unsigned int flags; + unsigned int **slot; + + /* The names we put in the hashtable will always be the unique + versions gived to us by the stringtable, so we can just use + their addresses as the keys. */ + if (!htab) + htab = htab_create (31, htab_hash_pointer, htab_eq_pointer, NULL); + + if (decl && TREE_CODE (decl) == FUNCTION_DECL) + flags = SECTION_CODE; + else if (decl && DECL_READONLY_SECTION (decl, reloc)) + flags = 0; + else + flags = SECTION_WRITE; + + if (decl && DECL_ONE_ONLY (decl)) + flags |= SECTION_LINKONCE; + + if (strcmp (name, ".bss") == 0 + || strncmp (name, ".bss.", 5) == 0 + || strncmp (name, ".gnu.linkonce.b.", 16) == 0 + || strcmp (name, ".sbss") == 0 + || strncmp (name, ".sbss.", 6) == 0 + || strncmp (name, ".gnu.linkonce.sb.", 17) == 0) + flags |= SECTION_BSS; + + /* See if we already have an entry for this section. */ + slot = (unsigned int **) htab_find_slot (htab, name, INSERT); + if (!*slot) + { + *slot = (unsigned int *) xmalloc (sizeof (unsigned int)); + **slot = flags; + } + else + { + if (decl && **slot != flags) + error_with_decl (decl, "%s causes a section type conflict"); + } + + return flags; +} + +/* Output assembly to switch to section NAME with attribute FLAGS. + Four variants for common object file formats. */ + +void +default_no_named_section (name, flags, align) + const char *name ATTRIBUTE_UNUSED; + unsigned int flags ATTRIBUTE_UNUSED; + unsigned int align ATTRIBUTE_UNUSED; +{ + /* Some object formats don't support named sections at all. The + front-end should already have flagged this as an error. */ + abort (); +} + +void +default_elf_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + char flagchars[8], *f = flagchars; + const char *type; + + if (!(flags & SECTION_DEBUG)) + *f++ = 'a'; + if (flags & SECTION_WRITE) + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; + if (flags & SECTION_SMALL) + *f++ = 's'; + *f = '\0'; + + if (flags & SECTION_BSS) + type = "nobits"; + else + type = "progbits"; + + fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s\n", + name, flagchars, type); +} + +void +default_coff_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + char flagchars[8], *f = flagchars; + + if (flags & SECTION_WRITE) + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; + *f = '\0'; + + fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars); +} + +void +default_pe_asm_named_section (name, flags, align) + const char *name; + unsigned int flags; + unsigned int align ATTRIBUTE_UNUSED; +{ + default_coff_asm_named_section (name, flags, align); + + if (flags & SECTION_LINKONCE) + { + /* Functions may have been compiled at various levels of + optimization so we can't use `same_size' here. + Instead, have the linker pick one. */ + fprintf (asm_out_file, "\t.linkonce %s\n", + (flags & SECTION_CODE ? "discard" : "same_size")); + } +} |