From: rsandifo Date: Wed, 7 Dec 2005 07:53:14 +0000 (+0000) Subject: * config/alpha/alpha.c (alpha_start_function): Use switch_to_section. X-Git-Tag: upstream/4.9.2~57195 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f14b1f9d493c8f64d5ff6b284bfe91ad8433d37;p=platform%2Fupstream%2Flinaro-gcc.git * config/alpha/alpha.c (alpha_start_function): Use switch_to_section. (alpha_elf_select_rtx_section): Return the selected section rather than emitting assembly code. (alpha_write_linkage): Emit a ".link" directive directly and then set in_section to NULL. (vms_asm_out_constructor): Use switch_to_section. (vms_asm_out_destructor): Likewise. (unicosmk_output_common): Set in_section to NULL instead of calling the dummy common_section function. (unicosmk_text_section): Delete in favor of... (unicosmk_output_text_section_asm_op): ...this new function. (unicosmk_data_section): Delete in favor of... (unicosmk_output_data_section_asm_op): ...this new function. (unicosmk_init_sections): New function. (unicosmk_output_deferred_case_vectors): Use switch_to_section. (unicosmk_output_ssib): Set in_section to NULL instead of calling the dummy ssib_section function. (unicosmk_section_buf): Delete. * config/alpha/alpha-protos.h (unicosmk_text_section): Delete. (unicosmk_data_section): Delete. * config/alpha/elf.h (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, sbss_section, sdata_section) (SECTION_FUNCTION_TEMPLATE): Delete. * config/alpha/unicosmk.h (TEXT_SECTION_ASM_OP, DATA_SECTION_ASM_OP) (READONLY_DATA_SECTION, EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (common_section, COMMON_SECTION, ssib_section, SSIB_SECTION): Delete. (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. (TARGET_ASM_INIT_SECTIONS): Define. * config/alpha/vms.h (LINK_SECTION_ASM_OP, LITERALS_SECTION_ASM_OP) (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (link_section, literals_section): Delete. (ASM_OUTPUT_DEF): Emit the ".literal" directive directly and then set in_section to NULL. * config/arm/aof.h (TEXT_SECTION_ASM_OP, DATA_SECTION_ASM_OP): Delete. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, ZERO_INIT_SECTION): Delete. (COMMON_SECTION): Delete. (TARGET_ASM_INIT_SECTIONS): Define. (ASM_OUTPUT_COMMON): Set in_section to NULL rather than calling the dummy common_section function. * config/arm/aout.h (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. * config/arm/arm.c (get_jump_table_size): Use pointer comparison between readonly_data_section and text_section to check whether read-only data is being put in the text section. (arm_output_function_epilogue): Use switch_to_section. (arm_elf_asm_constructor): Likewise. (thumb_call_via_reg): Replace call to in_text_section with a comparison between in_section and text_section. (arm_file_end): Use switch_to_section. (aof_text_section): Delete in favor of... (aof_output_text_section_asm_op): ...this new function. (aof_data_section): Delete in favor of... (aof_output_data_section_asm_op): ...this new function. (aof_asm_init_sections): New function. (zero_init_section): Moved from config/arm/aof.h. (aof_dump_imports, aof_file_start): Use switch_to_section. * config/arm/arm.h (thumb_call_via_label): Update comment. * config/arm/arm-protos.h (aof_text_section, aof_data_section): Delete. (common_section): Delete. * config/arm/pe.h (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. (ASM_DECLARE_OBJECT_NAME): Update the type of save_section. Use the global switch_to_section function instead of the old port-local one. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, DRECTVE_SECTION_FUNCTION) (SWITCH_TO_SECTION_FUNCTION): Delete. (drectve_section): Redefine as a macro. * config/arm/unknown-elf.h (ASM_OUTPUT_ALIGNED_BSS): (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use get_named_section and switch_to_section. * config/avr/avr.c (progmem_section): New variable. (avr_output_progmem_section_asm_op): New function. (avr_asm_init_sections): New function. (avr_output_addr_vec_elt): Use switch_to_section. * config/avr/avr.h (progmem_section): Declare. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (READONLY_DATA_SECTION): Delete. (TARGET_ASM_INIT_SECTIONS): Define. (ASM_OUTPUT_CASE_LABEL): Use switch_to_section. * config/avr/avr-protos.h (progmem_section): Delete. * config/bfin/bfin.h (ASM_OUTPUT_LOCAL): Use switch_to_section. * config/c4x/c4x.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (INIT_SECTION_FUNCTION, FINI_SECTION_FUNCTION): Delete. * config/darwin-sections.def: New file. * config/darwin.c: Define all sections in darwin-sections.def. (output_objc_section_asm_op, darwin_init_sections): New functions. (machopic_output_indirection): Use switch_to_section. (machopic_select_section): Return the selected section rather than emitting assembly code. Replace the static function table with inline conditional expressions. Update the tests of last_text_section and move them into the FUNCTION_DECL block. (machopic_select_rtx_section): Return the selected section rather than emitting assembly code. (machopic_asm_out_constructor, machopic_asm_out_destructor) (darwin_file_end): Use switch_to_section. * config/darwin.h: Use darwin-sections.def to declare sections. (INIT_SECTION_ASM_OP): Remove empty definition. (HAS_INIT_SECTION): Define this instead. (SECTION_FUNCTION, EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (READONLY_DATA_SECTION, TARGET_ASM_EXCEPTION_SECTION): Delete. (TARGET_ASM_EH_FRAME_SECTION): Delete. (TARGET_ASM_INIT_SECTIONS): Define. * config/darwin-protos.h (darwin_init_sections): Declare. (machopic_picsymbol_stub_section, machopic_picsymbol_stub1_section) (machopic_symbol_stub_section, machopic_symbol_stub1_section): Delete. (machopic_lazy_symbol_ptr_section, machopic_nl_symbol_ptr_section) (constructor_section, destructor_section, mod_init_section): Delete. (mod_term_section): Delete. (darwin_exception_section, darwin_eh_frame_section): Delete. (machopic_select_section): Return a section. (machopic_select_rtx_section): Likewise. (text_coal_section, text_unlikely_section, text_unlikely_coal_section) (const_section, const_coal_section, const_data_section): Delete. (const_data_coal_section, data_coal_section, cstring_section): Delete. (literal4_section, literal8_section, constructor_section): Delete. (mod_init_section, mod_term_section, destructor_section): Delete. (objc_class_section, objc_meta_class_section, objc_category_section) (objc_class_vars_section, objc_instance_vars_section): Delete. (objc_cls_meth_section, objc_inst_meth_section): Delete. (objc_cat_cls_meth_section, objc_cat_inst_meth_section): Delete. (objc_selector_refs_section, objc_selector_fixup_section): Delete. (objc_symbols_section, objc_module_info_section): Delete. (objc_image_info_section, objc_protocol_section): Delete. (objc_string_object_section, objc_constant_string_object_section) (objc_class_names_section, objc_meth_var_names_section): Delete. (objc_meth_var_types_section, objc_cls_refs_section): Delete. (machopic_lazy_symbol_ptr_section, machopic_nl_symbol_ptr_section) (machopic_symbol_stub_section, machopic_picsymbol_stub_section) (darwin_exception_section, darwin_eh_frame_section): Delete. * config/t-darwin (darwin.o): Depend on config/darwin-sections.def. * config/frv/frv.c (frv_asm_out_constructor): Use switch_to_section. (frv_asm_out_destructor): Likewise. * config/frv/frv.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (SDATA_SECTION_FUNCTION, FIXUP_SECTION_FUNCTION): Delete. (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use switch_to_section and get_named_section. (ASM_OUTPUT_CASE_LABEL): Use switch_to_section. * config/frv/frv-protos.h (fixup_section, sdata_section, sbss_section) (data_section): Delete. * config/i386/cygming.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (DRECTVE_SECTION_FUNCTION): Delete. (drectve_section): Redefine as a macro that sets in_section after emitting the directive. (SWITCH_TO_SECTION_FUNCTION): Delete. * config/i386/darwin.h (ASM_OUTPUT_ALIGN): Replace call to in_text_section with comparison between in_section and text_section. * config/i386/i386.c (x86_64_elf_select_section): Return the section rather than emitting assembly code. Use get_named_section. (x86_output_aligned_bss, ix86_file_end): Use switch_to_section and get_named_section. (machopic_output_stub): Use switch_to_section. * config/i386/nwld.c (nwld_named_section_asm_out_constructor) (nwld_named_section_asm_out_destructor): Use get_section and switch_to_section. * config/ia64/ia64.c (ia64_select_rtx_section): Return the section rather than emitting assembly code. (ia64_rwreloc_select_section): Likewise. (ia64_rwreloc_select_rtx_section): Likewise. * config/ia64/ia64-protos.h (sdata_section, sbss_section): Delete. * config/ia64/sysv4.h (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use switch_to_section. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (SDATA_SECTION_FUNCTION, SBSS_SECTION_FUNCTION): Delete. * config/iq2000/iq2000.c (iq2000_select_rtx_section): Return the section rather than emitting assembly code. (iq2000_select_section): Likewise. * config/iq2000/iq2000.h (rdata_section, sdata_section): Delete. (sbss_section): Delete. * config/m32r/m32r.h (ASM_OUTPUT_ALIGNED_BSS): Use switch_to_section and get_named_section. * config/m32r/m32r-protos.h (sbss_section, sdata_section): Delete. * config/mcore/mcore-elf.h (EXPORTS_SECTION_ASM_OP): Delete. (SUBTARGET_EXTRA_SECTIONS, SUBTARGET_EXTRA_SECTION_FUNCTIONS): Delete. (EXPORT_SECTION_FUNCTION, SUBTARGET_SWITCH_SECTIONS): Delete. (MCORE_EXPORT_NAME): Emit the exports directive directly, then set in_section to NULL. (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. (ASM_DECLARE_OBJECT_NAME): Update the type of save_section. Use the global switch_to_section function instead of the old port-local one. * config/mcore/mcore.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (SWITCH_SECTION_FUNCTION): Delete. * config/mcore/mcore-pe.h (SUBTARGET_SWITCH_SECTIONS): Delete. (DRECTVE_SECTION_ASM_OP, SUBTARGET_EXTRA_SECTIONS): Delete. (SUBTARGET_EXTRA_SECTION_FUNCTIONS, DRECTVE_SECTION_FUNCTION): Delete. (MCORE_EXPORT_NAME): Emit ".section .drectve" directly, then set in_section to NULL. (ASM_DECLARE_OBJECT_NAME): Update the type of save_section. Use the global switch_to_section function instead of the old port-local one. (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. * config/mips/mips.c (mips_file_start): Update comment. (mips_output_aligned_bss): Use switch_to_section and get_named_section. (mips_output_aligned_decl_common): Use switch_to_section. (mips_select_rtx_section): Return the section rather than emitting assembly code. Use get_named_section. (mips_function_rodata_section: Likewise get_section. (build_mips16_function_stub): Use switch_to_section. * config/mips/mips.h (ASM_OUTPUT_IDENT): Use switch_to_section. (SDATA_SECTION_ASM_OP): Delete. * config/mips/vxworks.h (EXTRA_SECTIONS): Delete. (EXTRA_SECTION_FUNCTIONS): Delete. * config/mmix/mmix.c (mmix_file_start, mmix_file_end) (mmix_asm_output_aligned_local): Use switch_to_section. * config/pa/pa.c (som_readonly_data_section, som_one_only_data_section) (som_one_only_readonly_data_section): New variables. (pa_output_function_epilogue): Set in_section to NULL instead of calling forget_section. (output_deferred_plabels): Use select_section. (pa_asm_output_mi_thunk): Likewise. Set in_section to NULL instead of calling forget_section. (pa_asm_output_aligned_bss, pa_asm_output_aligned_common) (pa_asm_output_aligned_local): Use select_section. (som_text_section_asm_op): Delete in favor of... (som_output_text_section_asm_op): ...this new function. (pa_som_asm_init_sections): New function. (pa_select_section): Return the section rather than emitting assembly code. * config/pa/pa.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (SOM_READONLY_DATA_SECTION_FUNCTION): Delete. (SOM_ONE_ONLY_READONLY_DATA_SECTION_FUNCTION): Delete. (SOM_ONE_ONLY_DATA_SECTION_FUNCTION, FORGET_SECTION_FUNCTION): Delete. * config/pa/pa-protos.h (som_text_section_asm_op): Delete. (som_readonly_data_section, som_one_only_readonly_data_section) (som_one_only_data_section, forget_section): Delete. * config/pa/som.h (TEXT_SECTION_ASM_OP): Delete. (TARGET_ASM_INIT_SECTIONS): Define. (READONLY_DATA_SECTION, TARGET_ASM_EXCEPTION_SECTION): Delete. * config/rs6000/rs6000.c (read_only_data_section): New variable. (private_data_section, read_only_private_data_section): New variables. (sdata2_section, toc_section): New variables. (rs6000_file_start): Use switch_to_section. (rs6000_assemble_integer): Use comparisons against in_section instead of calling in_toc_section and in_text_section. Use unlikely_text_section_p. (rs6000_elf_output_toc_section_asm_op): New function, derived from the old rs6000/sysv4.h toc_section function. (rs6000_elf_asm_init_sections): New function. (rs6000_elf_select_rtx_section, rs6000_elf_select_section): Return the section rather than emitting assembly code. (machopic_output_stub): Use switch_to_section. (toc_section): Delete dummy function. (rs6000_elf_asm_out_constructor, rs6000_elf_asm_out_destructor): Use switch_to_section and get_section. (rs6000_xcoff_output_readonly_section_asm_op): New function. (rs6000_xcoff_output_readwrite_section_asm_op): New function. (rs6000_xcoff_output_toc_section_asm_op): New function, derived from the old rs6000/xcoff.h toc_section function. (rs6000_xcoff_asm_init_sections): New function. (rs6000_xcoff_select_section, rs6000_xcoff_select_rtx_section): Return the section rather than emitting assembly code. (rs6000_xcoff_file_start): Use switch_to_section. (rs6000_xcoff_file_end): Likewise. * config/rs6000/rs6000-protos.h (toc_section, sdata_section): Delete. (sdata2_section, sbss_section, private_data_section): Delete. (read_only_data_section, read_only_private_data_section): Delete. * config/rs6000/sysv4.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (TOC_SECTION_FUNCTION, SDATA_SECTION_FUNCTION, SDATA2_SECTION_FUNCTION) (SBSS_SECTION_FUNCTION, INIT_SECTION_FUNCTION): Delete. (FINI_SECTION_FUNCTION): Delete. (TARGET_ASM_INIT_SECTIONS): Define. (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. * config/rs6000/xcoff.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (READ_ONLY_DATA_SECTION_FUNCTION, PRIVATE_DATA_SECTION_FUNCTION) (READ_ONLY_PRIVATE_DATA_SECTION_FUNCTION, TOC_SECTION_FUNCTION) (READONLY_DATA_SECTION): Delete. (TARGET_ASM_INIT_SECTIONS): Define. (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. Set in_section to NULL rather than no_section. (TARGET_ASM_EXCEPTION_SECTION): Delete. * config/sh/sh.c (sh_file_start): Use switch_to_section. * config/sparc/sparc.c (emit_pic_helper): Use switch_to_section. (sparc_output_deferred_case_vectors): Likewise. Remove argument from call to current_function_section. * config/stormy16/stormy16.c: Include ggc.h and gt-storm16.h. (bss100_section): New variable. (xstormy16_asm_output_aligned_common): Use switch_to_section. (xstormy16_asm_init_sections): New function. (xstormy16_asm_out_destructor, xstormy16_asm_out_constructor): Use switch_to_section and get_section. (xstormy16_output_addr_vec): Use switch_to_section. Remove argument from calls to current_function_section. * config/stormy16/stormy16.h (EXTRA_SECTIONS): Delete. (XSTORMY16_SECTION_FUNCTION, EXTRA_SECTION_FUNCTIONS): Delete. (TARGET_ASM_INIT_SECTIONS): Define. * config/stormy16/stormy16-protos.h (bss100_section): Delete. * config/svr3.h (ASM_OUTPUT_LOCAL): Use switch_to_section. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, INIT_SECTION_FUNCTION) (FINI_SECTION_FUNCTION): Delete. * config/v850/v850.c: Include gt-v850.h. (rosdata_section, rozdata_section, tdata_section, zdata_section) (zbss_section): New variables. (v850_output_aligned_bss): Use switch_to_section. (v850_asm_init_sections): New function. (v850_select_section): Return the section rather than emitting assembly code. * config/v850/v850.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) (ZDATA_SECTION_ASM_OP, ZBSS_SECTION_ASM_OP, TDATA_SECTION_ASM_OP) (ROSDATA_SECTION_ASM_OP, ROZDATA_SECTION_ASM_OP): Delete. (TARGET_ASM_INIT_SECTIONS): Define. * config/v850/v850-protos.h (sdata_section, rosdata_section): Delete. (sbss_section, tdata_section, zdata_section, rozdata_section): Delete. (zbss_section): Delete. * config/vax/vaxv.h (ASM_OUTPUT_LOCAL): Use switch_to_section. * config/vx-common.h (vxworks_exception_section): Delete. (TARGET_ASM_EXCEPTION_SECTION): Delete. * config/xtensa/xtensa.c (xtensa_select_rtx_section): Return the section rather than emitting assembly code. * config/xtensa/xtensa.h (ASM_OUTPUT_POOL_PROLOGUE): Use switch_to_section. * Makefile.in (GTFILES): Add $(srcdir)/output.h. * coretypes.h (section): New union and typedef. * dbxout.c (FORCE_TEXT): Use switch_to_section. Remove argument from call to current_function_section. (dbxout_function_end, dbxout_init, dbxout_source_file, dbxout_finish) (dbxout_symbol_location): Use switch_to_section. * dwarf2out.c (named_section_eh_frame_section): Delete, moving most of the code into... (default_eh_frame_section): ...here. Return a section. (collect2_eh_frame_section): Delete, moving most of the code into.. (switch_to_eh_frame_section): ...this new function. (debug_info_section, debug_abbrev_section, debug_aranges_section) (debug_macinfo_section, debug_line_section, debug_loc_section) (debug_pubnames_section, debug_str_section, debug_ranges_section): New variables. (output_call_frame_info): Call switch_to_eh_frame_section instead of eh_frame_section. Use switch_to_section and get_section. (dwarf2out_begin_prologue): Use switch_to_section. (AT_string_form): Check the flags in debug_str_section instead of DEBUG_STR_SECTION_FLAGS. (output_comp_unit): Use switch_to_section, get_section, and debug_info_section. (output_line_info, secname_for_decl): Use unlikely_text_section_p. (dwarf2out_begin_block): Use switch_to_section. Remove argument from call to current_function_section. (dwarf2out_var_location): Use unlikely_text_section_p. (dwarf2out_source_line): Use switch_to_section. Remove argument from call to current_function_section. (dwarf2out_start_source_file, dwarf2out_end_source_file) (dwarf2out_define, dwarf2out_undef: Use switch_to_section and debug_macinfo_section. (dwarf2out_init): Initialize the new section variables. Use them instead of calls to named_section_flags. Use switch_to_section. (output_indirect_string): Use switch_to_section and debug_str_section. (dwarf2out_finish): Use switch_to_section and the new section variables. * except.c (default_exception_section): Return the section instead of emitting assembly code. (output_function_exception_table): Use the global exception_section variable instead of the target hook. Use switch_to_section. Remove argument from call to current_function_section. * final.c (HAVE_READONLY_DATA_SECTION): Delete. (shorten_branches): Use pointer comparisons to detect whether the text section is the same as readonly_data_section. (profile_function): Use switch_to_section. Remove argument from call to current_function_section. (final_scan_insn): Likewise. Update use of last_text_section. * gengtype.c (open_base_files): Add an include of output.h. * output.h (text_section, data_section, readonly_data_section) (ctors_section, dtors_section, bss_section, init_section) (fini_section, sdata_section): Turn into section pointers. (in_text_section, in_unlikely_text_section, exports_section) (drectve_section, named_section, mergeable_string_section) (last_text_section_name): Delete. (default_exception_section, default_eh_frame_section): Return sections. (SECTION_DECLARED, SECTION_NAMED): New macros. (SECTION_MACH_DEP): Bump value. (section_common, named_section, unnamed_section): New structures. (unnamed_section_callback): New typedef. (section): New union. (sbss_section, exception_section, eh_frame_section): New variables. (in_section, last_text_section): Turn into section pointers. (get_unnamed_section, get_section, get_named_section): New functions. (mergeable_constant_section, function_section): Return a section. (unlikely_text_section): Likewise. (current_function_section): Likewise. Remove the decl argument. (unlikely_text_section_p, switch_to_section): New functions. (output_section_asm_op): New function. (set_named_section_flags, named_section_flags, named_section_real) (named_section_first_declaration): Delete. (default_select_section, default_elf_select_section): Return a section. (default_elf_select_section_1, default_function_rodata_section) (default_no_function_rodata_section, default_select_rtx_section) (default_elf_select_rtx_section): Likewise. * rtl.h (in_data_section): Delete. * sdbout.c (sdbout_one_type): Use switch_to_section. * system.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Poison. (READONLY_DATA_SECTION, TARGET_ASM_EXCEPTION_SECTION): Poison. (TARGET_ASM_EH_FRAME_SECTION): Poison. * target-def.h (TARGET_ASM_INIT_SECTIONS): New macro. (TARGET_ASM_EXCEPTION_SECTION, TARGET_ASM_EH_FRAME_SECTION): Delete. (TARGET_ASM_OUT): Update after above changes. * target.h (init_sections): New hook. (exception_section, eh_frame_section): Delete. (select_section, select_rtx_section, function_rodata_section): Return a section rather than emitting assembly code. * varasm.c (text_section, data_section, readonly_data_section) (ctors_section, dtors_section, bss_section, init_section) (fini_section): Turn into section pointers. (sdata_section, sbss_section, exception_section): New variables. (eh_frame_section): New variable. (in_section): Make global and turn into a section pointer. (last_text_section): Turn into a section pointer. (unnamed_sections): New variable. (in_named_name, last_text_section_name): Delete. (EXTRA_SECTION_FUNCTIONS): Delete. (in_named_entry): Delete. (section_htab): New variable, replacing... (in_named_htab): ...this deleted variable. (section_entry_eq, section_entry_hash): New functions, based on... (in_named_entry_eq, in_named_entry_hash): ...these deleted functions. (get_unnamed_section, get_section): New functions. (unlikely_text_section): Return a section instead of emitting assembly code. (in_text_section, in_unlikely_text_section, in_data_section): Delete. (get_named_section_flags, named_section_first_declaration): Delete. (unlikely_text_section_p): New function. (named_section_real, named_section): Delete. (get_named_section): New function. (asm_output_bss, asm_output_aligned_bss): Use switch_to_section. (function_section): Return a section rather than emitting assembly code. (current_function_section): Likewise. Remove argument. Use last_text_section if nonnull, otherwise use function_section. (default_function_rodata_section): Return a section rather than emitting assembly code. Use get_section. (default_no_function_rodata_section): Return a section rather than emitting assembly code. (variable_section): Use switch_to_section and get_named_section. (mergeable_string_section): Return a section rather than emitting assembly code. Use get_section. Make static. Don't take special countermeasures for empty strings. (mergeable_constant_section): Return a section rather than emitting assembly code. Use get_section. (default_named_section_asm_out_destructor): Use switch_to_section and get_section. (default_dtor_section_asm_out_destructor): Use switch_to_section. (default_named_section_asm_out_constructor): Use switch_to_section and get_section. (default_ctor_section_asm_out_constructor): Use switch_to_section. (assemble_start_function): Likewise. Set last_text_section to NULL rather than no_section. Change the type of save_section. (assemble_zeros, assemble_variable): Use the section flags to detect whether or not a section is text. (assemble_static_space): Use switch_to_section. (assemble_trampoline_template): Likewise. (output_constant_def_contents): Use switch_to_section and get_named_section. (output_constant_pool_1): Use switch_to_section. Use the section flags to see whether sections contain mergeable data. (init_varasm_once): Initialize section_htab instead of in_named_htab. Initialize new section variables. Call TARGET_ASM_INIT_SECTIONS. (default_elf_asm_named_section): Use SECTION_DECLARED to detect whether a section has already been declared. (default_select_section, default_elf_select_section): Return a section rather than emitting assembly code. (default_elf_select_section_1): Likewise. Use bss_section for SECCAT_BSS if nonnull. Use get_named_section. (default_select_rtx_section): Return a section rather than emitting assembly code. (default_elf_select_rtx_section): Likewise. Use get_named_section. (file_end_indicate_exec_stack): Use switch_to_section and get_section. (output_section_asm_op, switch_to_section): New functions. * vmsdbgout.c (vmsdbgout_finish): Use switch_to_section and get_named_section. * doc/tm.texi: Expand the introduction to the sections documentation. (TRAMPOLINE_SECTION): Document new interface. (SDATA_SECTION_ASM_OP): Document new macro. (READONLY_DATA_SECTION): Delete. (SDATA_SECTION_ASM_OP): Document new macro. (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. (TARGET_ASM_INIT_SECTIONS): Document new hook. (TARGET_ASM_SELECT_SECTION, TARGET_ASM_FUNCTION_RODATA_SECTION) (TARGET_ASM_SELECT_RTX_SECTION): Adjust for new interface. (TARGET_EXCEPTION_SECTION, TARGET_EH_FRAME_SECTION): Delete. gcc/java/ * class.c (build_utf8_ref, emit_register_classes): Use switch_to_section and get_section. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108152 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d913d40..89281db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,501 @@ +2005-12-07 Richard Sandiford + + * config/alpha/alpha.c (alpha_start_function): Use switch_to_section. + (alpha_elf_select_rtx_section): Return the selected section rather + than emitting assembly code. + (alpha_write_linkage): Emit a ".link" directive directly and then + set in_section to NULL. + (vms_asm_out_constructor): Use switch_to_section. + (vms_asm_out_destructor): Likewise. + (unicosmk_output_common): Set in_section to NULL instead of calling + the dummy common_section function. + (unicosmk_text_section): Delete in favor of... + (unicosmk_output_text_section_asm_op): ...this new function. + (unicosmk_data_section): Delete in favor of... + (unicosmk_output_data_section_asm_op): ...this new function. + (unicosmk_init_sections): New function. + (unicosmk_output_deferred_case_vectors): Use switch_to_section. + (unicosmk_output_ssib): Set in_section to NULL instead of calling + the dummy ssib_section function. + (unicosmk_section_buf): Delete. + * config/alpha/alpha-protos.h (unicosmk_text_section): Delete. + (unicosmk_data_section): Delete. + * config/alpha/elf.h (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, sbss_section, sdata_section) + (SECTION_FUNCTION_TEMPLATE): Delete. + * config/alpha/unicosmk.h (TEXT_SECTION_ASM_OP, DATA_SECTION_ASM_OP) + (READONLY_DATA_SECTION, EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (common_section, COMMON_SECTION, ssib_section, SSIB_SECTION): Delete. + (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. + (TARGET_ASM_INIT_SECTIONS): Define. + * config/alpha/vms.h (LINK_SECTION_ASM_OP, LITERALS_SECTION_ASM_OP) + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (link_section, literals_section): Delete. + (ASM_OUTPUT_DEF): Emit the ".literal" directive directly and then + set in_section to NULL. + + * config/arm/aof.h (TEXT_SECTION_ASM_OP, DATA_SECTION_ASM_OP): Delete. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, ZERO_INIT_SECTION): Delete. + (COMMON_SECTION): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + (ASM_OUTPUT_COMMON): Set in_section to NULL rather than calling + the dummy common_section function. + * config/arm/aout.h (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. + * config/arm/arm.c (get_jump_table_size): Use pointer comparison + between readonly_data_section and text_section to check whether + read-only data is being put in the text section. + (arm_output_function_epilogue): Use switch_to_section. + (arm_elf_asm_constructor): Likewise. + (thumb_call_via_reg): Replace call to in_text_section with + a comparison between in_section and text_section. + (arm_file_end): Use switch_to_section. + (aof_text_section): Delete in favor of... + (aof_output_text_section_asm_op): ...this new function. + (aof_data_section): Delete in favor of... + (aof_output_data_section_asm_op): ...this new function. + (aof_asm_init_sections): New function. + (zero_init_section): Moved from config/arm/aof.h. + (aof_dump_imports, aof_file_start): Use switch_to_section. + * config/arm/arm.h (thumb_call_via_label): Update comment. + * config/arm/arm-protos.h (aof_text_section, aof_data_section): Delete. + (common_section): Delete. + * config/arm/pe.h (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. + (ASM_DECLARE_OBJECT_NAME): Update the type of save_section. Use the + global switch_to_section function instead of the old port-local one. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, DRECTVE_SECTION_FUNCTION) + (SWITCH_TO_SECTION_FUNCTION): Delete. + (drectve_section): Redefine as a macro. + * config/arm/unknown-elf.h (ASM_OUTPUT_ALIGNED_BSS): + (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use get_named_section and + switch_to_section. + + * config/avr/avr.c (progmem_section): New variable. + (avr_output_progmem_section_asm_op): New function. + (avr_asm_init_sections): New function. + (avr_output_addr_vec_elt): Use switch_to_section. + * config/avr/avr.h (progmem_section): Declare. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (READONLY_DATA_SECTION): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + (ASM_OUTPUT_CASE_LABEL): Use switch_to_section. + * config/avr/avr-protos.h (progmem_section): Delete. + + * config/bfin/bfin.h (ASM_OUTPUT_LOCAL): Use switch_to_section. + + * config/c4x/c4x.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (INIT_SECTION_FUNCTION, FINI_SECTION_FUNCTION): Delete. + + * config/darwin-sections.def: New file. + * config/darwin.c: Define all sections in darwin-sections.def. + (output_objc_section_asm_op, darwin_init_sections): New functions. + (machopic_output_indirection): Use switch_to_section. + (machopic_select_section): Return the selected section rather than + emitting assembly code. Replace the static function table with + inline conditional expressions. Update the tests of last_text_section + and move them into the FUNCTION_DECL block. + (machopic_select_rtx_section): Return the selected section rather than + emitting assembly code. + (machopic_asm_out_constructor, machopic_asm_out_destructor) + (darwin_file_end): Use switch_to_section. + * config/darwin.h: Use darwin-sections.def to declare sections. + (INIT_SECTION_ASM_OP): Remove empty definition. + (HAS_INIT_SECTION): Define this instead. + (SECTION_FUNCTION, EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (READONLY_DATA_SECTION, TARGET_ASM_EXCEPTION_SECTION): Delete. + (TARGET_ASM_EH_FRAME_SECTION): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + * config/darwin-protos.h (darwin_init_sections): Declare. + (machopic_picsymbol_stub_section, machopic_picsymbol_stub1_section) + (machopic_symbol_stub_section, machopic_symbol_stub1_section): Delete. + (machopic_lazy_symbol_ptr_section, machopic_nl_symbol_ptr_section) + (constructor_section, destructor_section, mod_init_section): Delete. + (mod_term_section): Delete. + (darwin_exception_section, darwin_eh_frame_section): Delete. + (machopic_select_section): Return a section. + (machopic_select_rtx_section): Likewise. + (text_coal_section, text_unlikely_section, text_unlikely_coal_section) + (const_section, const_coal_section, const_data_section): Delete. + (const_data_coal_section, data_coal_section, cstring_section): Delete. + (literal4_section, literal8_section, constructor_section): Delete. + (mod_init_section, mod_term_section, destructor_section): Delete. + (objc_class_section, objc_meta_class_section, objc_category_section) + (objc_class_vars_section, objc_instance_vars_section): Delete. + (objc_cls_meth_section, objc_inst_meth_section): Delete. + (objc_cat_cls_meth_section, objc_cat_inst_meth_section): Delete. + (objc_selector_refs_section, objc_selector_fixup_section): Delete. + (objc_symbols_section, objc_module_info_section): Delete. + (objc_image_info_section, objc_protocol_section): Delete. + (objc_string_object_section, objc_constant_string_object_section) + (objc_class_names_section, objc_meth_var_names_section): Delete. + (objc_meth_var_types_section, objc_cls_refs_section): Delete. + (machopic_lazy_symbol_ptr_section, machopic_nl_symbol_ptr_section) + (machopic_symbol_stub_section, machopic_picsymbol_stub_section) + (darwin_exception_section, darwin_eh_frame_section): Delete. + * config/t-darwin (darwin.o): Depend on config/darwin-sections.def. + + * config/frv/frv.c (frv_asm_out_constructor): Use switch_to_section. + (frv_asm_out_destructor): Likewise. + * config/frv/frv.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (SDATA_SECTION_FUNCTION, FIXUP_SECTION_FUNCTION): Delete. + (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use switch_to_section and + get_named_section. + (ASM_OUTPUT_CASE_LABEL): Use switch_to_section. + * config/frv/frv-protos.h (fixup_section, sdata_section, sbss_section) + (data_section): Delete. + + * config/i386/cygming.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (DRECTVE_SECTION_FUNCTION): Delete. + (drectve_section): Redefine as a macro that sets in_section after + emitting the directive. + (SWITCH_TO_SECTION_FUNCTION): Delete. + * config/i386/darwin.h (ASM_OUTPUT_ALIGN): Replace call to + in_text_section with comparison between in_section and text_section. + * config/i386/i386.c (x86_64_elf_select_section): Return the section + rather than emitting assembly code. Use get_named_section. + (x86_output_aligned_bss, ix86_file_end): Use switch_to_section and + get_named_section. + (machopic_output_stub): Use switch_to_section. + * config/i386/nwld.c (nwld_named_section_asm_out_constructor) + (nwld_named_section_asm_out_destructor): Use get_section and + switch_to_section. + + * config/ia64/ia64.c (ia64_select_rtx_section): Return the section + rather than emitting assembly code. + (ia64_rwreloc_select_section): Likewise. + (ia64_rwreloc_select_rtx_section): Likewise. + * config/ia64/ia64-protos.h (sdata_section, sbss_section): Delete. + * config/ia64/sysv4.h (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Use + switch_to_section. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (SDATA_SECTION_FUNCTION, SBSS_SECTION_FUNCTION): Delete. + + * config/iq2000/iq2000.c (iq2000_select_rtx_section): Return the + section rather than emitting assembly code. + (iq2000_select_section): Likewise. + * config/iq2000/iq2000.h (rdata_section, sdata_section): Delete. + (sbss_section): Delete. + + * config/m32r/m32r.h (ASM_OUTPUT_ALIGNED_BSS): Use switch_to_section + and get_named_section. + * config/m32r/m32r-protos.h (sbss_section, sdata_section): Delete. + + * config/mcore/mcore-elf.h (EXPORTS_SECTION_ASM_OP): Delete. + (SUBTARGET_EXTRA_SECTIONS, SUBTARGET_EXTRA_SECTION_FUNCTIONS): Delete. + (EXPORT_SECTION_FUNCTION, SUBTARGET_SWITCH_SECTIONS): Delete. + (MCORE_EXPORT_NAME): Emit the exports directive directly, then set + in_section to NULL. + (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. + (ASM_DECLARE_OBJECT_NAME): Update the type of save_section. Use the + global switch_to_section function instead of the old port-local one. + * config/mcore/mcore.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (SWITCH_SECTION_FUNCTION): Delete. + * config/mcore/mcore-pe.h (SUBTARGET_SWITCH_SECTIONS): Delete. + (DRECTVE_SECTION_ASM_OP, SUBTARGET_EXTRA_SECTIONS): Delete. + (SUBTARGET_EXTRA_SECTION_FUNCTIONS, DRECTVE_SECTION_FUNCTION): Delete. + (MCORE_EXPORT_NAME): Emit ".section .drectve" directly, then set + in_section to NULL. + (ASM_DECLARE_OBJECT_NAME): Update the type of save_section. Use the + global switch_to_section function instead of the old port-local one. + (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. + + * config/mips/mips.c (mips_file_start): Update comment. + (mips_output_aligned_bss): Use switch_to_section and get_named_section. + (mips_output_aligned_decl_common): Use switch_to_section. + (mips_select_rtx_section): Return the section rather than emitting + assembly code. Use get_named_section. + (mips_function_rodata_section: Likewise get_section. + (build_mips16_function_stub): Use switch_to_section. + * config/mips/mips.h (ASM_OUTPUT_IDENT): Use switch_to_section. + (SDATA_SECTION_ASM_OP): Delete. + * config/mips/vxworks.h (EXTRA_SECTIONS): Delete. + (EXTRA_SECTION_FUNCTIONS): Delete. + + * config/mmix/mmix.c (mmix_file_start, mmix_file_end) + (mmix_asm_output_aligned_local): Use switch_to_section. + + * config/pa/pa.c (som_readonly_data_section, som_one_only_data_section) + (som_one_only_readonly_data_section): New variables. + (pa_output_function_epilogue): Set in_section to NULL instead of + calling forget_section. + (output_deferred_plabels): Use select_section. + (pa_asm_output_mi_thunk): Likewise. Set in_section to NULL instead + of calling forget_section. + (pa_asm_output_aligned_bss, pa_asm_output_aligned_common) + (pa_asm_output_aligned_local): Use select_section. + (som_text_section_asm_op): Delete in favor of... + (som_output_text_section_asm_op): ...this new function. + (pa_som_asm_init_sections): New function. + (pa_select_section): Return the section rather than emitting + assembly code. + * config/pa/pa.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (SOM_READONLY_DATA_SECTION_FUNCTION): Delete. + (SOM_ONE_ONLY_READONLY_DATA_SECTION_FUNCTION): Delete. + (SOM_ONE_ONLY_DATA_SECTION_FUNCTION, FORGET_SECTION_FUNCTION): Delete. + * config/pa/pa-protos.h (som_text_section_asm_op): Delete. + (som_readonly_data_section, som_one_only_readonly_data_section) + (som_one_only_data_section, forget_section): Delete. + * config/pa/som.h (TEXT_SECTION_ASM_OP): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + (READONLY_DATA_SECTION, TARGET_ASM_EXCEPTION_SECTION): Delete. + + * config/rs6000/rs6000.c (read_only_data_section): New variable. + (private_data_section, read_only_private_data_section): New variables. + (sdata2_section, toc_section): New variables. + (rs6000_file_start): Use switch_to_section. + (rs6000_assemble_integer): Use comparisons against in_section + instead of calling in_toc_section and in_text_section. Use + unlikely_text_section_p. + (rs6000_elf_output_toc_section_asm_op): New function, derived + from the old rs6000/sysv4.h toc_section function. + (rs6000_elf_asm_init_sections): New function. + (rs6000_elf_select_rtx_section, rs6000_elf_select_section): Return + the section rather than emitting assembly code. + (machopic_output_stub): Use switch_to_section. + (toc_section): Delete dummy function. + (rs6000_elf_asm_out_constructor, rs6000_elf_asm_out_destructor): Use + switch_to_section and get_section. + (rs6000_xcoff_output_readonly_section_asm_op): New function. + (rs6000_xcoff_output_readwrite_section_asm_op): New function. + (rs6000_xcoff_output_toc_section_asm_op): New function, derived from + the old rs6000/xcoff.h toc_section function. + (rs6000_xcoff_asm_init_sections): New function. + (rs6000_xcoff_select_section, rs6000_xcoff_select_rtx_section): Return + the section rather than emitting assembly code. + (rs6000_xcoff_file_start): Use switch_to_section. + (rs6000_xcoff_file_end): Likewise. + * config/rs6000/rs6000-protos.h (toc_section, sdata_section): Delete. + (sdata2_section, sbss_section, private_data_section): Delete. + (read_only_data_section, read_only_private_data_section): Delete. + * config/rs6000/sysv4.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (TOC_SECTION_FUNCTION, SDATA_SECTION_FUNCTION, SDATA2_SECTION_FUNCTION) + (SBSS_SECTION_FUNCTION, INIT_SECTION_FUNCTION): Delete. + (FINI_SECTION_FUNCTION): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + (ASM_OUTPUT_ALIGNED_LOCAL): Use switch_to_section. + * config/rs6000/xcoff.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (READ_ONLY_DATA_SECTION_FUNCTION, PRIVATE_DATA_SECTION_FUNCTION) + (READ_ONLY_PRIVATE_DATA_SECTION_FUNCTION, TOC_SECTION_FUNCTION) + (READONLY_DATA_SECTION): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + (ASM_DECLARE_FUNCTION_NAME): Use switch_to_section. Set in_section + to NULL rather than no_section. + (TARGET_ASM_EXCEPTION_SECTION): Delete. + + * config/sh/sh.c (sh_file_start): Use switch_to_section. + + * config/sparc/sparc.c (emit_pic_helper): Use switch_to_section. + (sparc_output_deferred_case_vectors): Likewise. Remove argument + from call to current_function_section. + + * config/stormy16/stormy16.c: Include ggc.h and gt-storm16.h. + (bss100_section): New variable. + (xstormy16_asm_output_aligned_common): Use switch_to_section. + (xstormy16_asm_init_sections): New function. + (xstormy16_asm_out_destructor, xstormy16_asm_out_constructor): Use + switch_to_section and get_section. + (xstormy16_output_addr_vec): Use switch_to_section. Remove argument + from calls to current_function_section. + * config/stormy16/stormy16.h (EXTRA_SECTIONS): Delete. + (XSTORMY16_SECTION_FUNCTION, EXTRA_SECTION_FUNCTIONS): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + * config/stormy16/stormy16-protos.h (bss100_section): Delete. + + * config/svr3.h (ASM_OUTPUT_LOCAL): Use switch_to_section. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, INIT_SECTION_FUNCTION) + (FINI_SECTION_FUNCTION): Delete. + + * config/v850/v850.c: Include gt-v850.h. + (rosdata_section, rozdata_section, tdata_section, zdata_section) + (zbss_section): New variables. + (v850_output_aligned_bss): Use switch_to_section. + (v850_asm_init_sections): New function. + (v850_select_section): Return the section rather than emitting + assembly code. + * config/v850/v850.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS) + (ZDATA_SECTION_ASM_OP, ZBSS_SECTION_ASM_OP, TDATA_SECTION_ASM_OP) + (ROSDATA_SECTION_ASM_OP, ROZDATA_SECTION_ASM_OP): Delete. + (TARGET_ASM_INIT_SECTIONS): Define. + * config/v850/v850-protos.h (sdata_section, rosdata_section): Delete. + (sbss_section, tdata_section, zdata_section, rozdata_section): Delete. + (zbss_section): Delete. + + * config/vax/vaxv.h (ASM_OUTPUT_LOCAL): Use switch_to_section. + + * config/vx-common.h (vxworks_exception_section): Delete. + (TARGET_ASM_EXCEPTION_SECTION): Delete. + + * config/xtensa/xtensa.c (xtensa_select_rtx_section): Return the + section rather than emitting assembly code. + * config/xtensa/xtensa.h (ASM_OUTPUT_POOL_PROLOGUE): Use + switch_to_section. + + * Makefile.in (GTFILES): Add $(srcdir)/output.h. + * coretypes.h (section): New union and typedef. + * dbxout.c (FORCE_TEXT): Use switch_to_section. Remove argument + from call to current_function_section. + (dbxout_function_end, dbxout_init, dbxout_source_file, dbxout_finish) + (dbxout_symbol_location): Use switch_to_section. + * dwarf2out.c (named_section_eh_frame_section): Delete, moving + most of the code into... + (default_eh_frame_section): ...here. Return a section. + (collect2_eh_frame_section): Delete, moving most of the code into.. + (switch_to_eh_frame_section): ...this new function. + (debug_info_section, debug_abbrev_section, debug_aranges_section) + (debug_macinfo_section, debug_line_section, debug_loc_section) + (debug_pubnames_section, debug_str_section, debug_ranges_section): New + variables. + (output_call_frame_info): Call switch_to_eh_frame_section instead of + eh_frame_section. Use switch_to_section and get_section. + (dwarf2out_begin_prologue): Use switch_to_section. + (AT_string_form): Check the flags in debug_str_section instead of + DEBUG_STR_SECTION_FLAGS. + (output_comp_unit): Use switch_to_section, get_section, and + debug_info_section. + (output_line_info, secname_for_decl): Use unlikely_text_section_p. + (dwarf2out_begin_block): Use switch_to_section. Remove argument + from call to current_function_section. + (dwarf2out_var_location): Use unlikely_text_section_p. + (dwarf2out_source_line): Use switch_to_section. Remove argument + from call to current_function_section. + (dwarf2out_start_source_file, dwarf2out_end_source_file) + (dwarf2out_define, dwarf2out_undef: Use switch_to_section and + debug_macinfo_section. + (dwarf2out_init): Initialize the new section variables. Use them + instead of calls to named_section_flags. Use switch_to_section. + (output_indirect_string): Use switch_to_section and debug_str_section. + (dwarf2out_finish): Use switch_to_section and the new section + variables. + * except.c (default_exception_section): Return the section instead + of emitting assembly code. + (output_function_exception_table): Use the global exception_section + variable instead of the target hook. Use switch_to_section. Remove + argument from call to current_function_section. + * final.c (HAVE_READONLY_DATA_SECTION): Delete. + (shorten_branches): Use pointer comparisons to detect whether the + text section is the same as readonly_data_section. + (profile_function): Use switch_to_section. Remove argument from + call to current_function_section. + (final_scan_insn): Likewise. Update use of last_text_section. + * gengtype.c (open_base_files): Add an include of output.h. + * output.h (text_section, data_section, readonly_data_section) + (ctors_section, dtors_section, bss_section, init_section) + (fini_section, sdata_section): Turn into section pointers. + (in_text_section, in_unlikely_text_section, exports_section) + (drectve_section, named_section, mergeable_string_section) + (last_text_section_name): Delete. + (default_exception_section, default_eh_frame_section): Return sections. + (SECTION_DECLARED, SECTION_NAMED): New macros. + (SECTION_MACH_DEP): Bump value. + (section_common, named_section, unnamed_section): New structures. + (unnamed_section_callback): New typedef. + (section): New union. + (sbss_section, exception_section, eh_frame_section): New variables. + (in_section, last_text_section): Turn into section pointers. + (get_unnamed_section, get_section, get_named_section): New functions. + (mergeable_constant_section, function_section): Return a section. + (unlikely_text_section): Likewise. + (current_function_section): Likewise. Remove the decl argument. + (unlikely_text_section_p, switch_to_section): New functions. + (output_section_asm_op): New function. + (set_named_section_flags, named_section_flags, named_section_real) + (named_section_first_declaration): Delete. + (default_select_section, default_elf_select_section): Return a section. + (default_elf_select_section_1, default_function_rodata_section) + (default_no_function_rodata_section, default_select_rtx_section) + (default_elf_select_rtx_section): Likewise. + * rtl.h (in_data_section): Delete. + * sdbout.c (sdbout_one_type): Use switch_to_section. + * system.h (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Poison. + (READONLY_DATA_SECTION, TARGET_ASM_EXCEPTION_SECTION): Poison. + (TARGET_ASM_EH_FRAME_SECTION): Poison. + * target-def.h (TARGET_ASM_INIT_SECTIONS): New macro. + (TARGET_ASM_EXCEPTION_SECTION, TARGET_ASM_EH_FRAME_SECTION): Delete. + (TARGET_ASM_OUT): Update after above changes. + * target.h (init_sections): New hook. + (exception_section, eh_frame_section): Delete. + (select_section, select_rtx_section, function_rodata_section): Return + a section rather than emitting assembly code. + * varasm.c (text_section, data_section, readonly_data_section) + (ctors_section, dtors_section, bss_section, init_section) + (fini_section): Turn into section pointers. + (sdata_section, sbss_section, exception_section): New variables. + (eh_frame_section): New variable. + (in_section): Make global and turn into a section pointer. + (last_text_section): Turn into a section pointer. + (unnamed_sections): New variable. + (in_named_name, last_text_section_name): Delete. + (EXTRA_SECTION_FUNCTIONS): Delete. + (in_named_entry): Delete. + (section_htab): New variable, replacing... + (in_named_htab): ...this deleted variable. + (section_entry_eq, section_entry_hash): New functions, based on... + (in_named_entry_eq, in_named_entry_hash): ...these deleted functions. + (get_unnamed_section, get_section): New functions. + (unlikely_text_section): Return a section instead of emitting + assembly code. + (in_text_section, in_unlikely_text_section, in_data_section): Delete. + (get_named_section_flags, named_section_first_declaration): Delete. + (unlikely_text_section_p): New function. + (named_section_real, named_section): Delete. + (get_named_section): New function. + (asm_output_bss, asm_output_aligned_bss): Use switch_to_section. + (function_section): Return a section rather than emitting + assembly code. + (current_function_section): Likewise. Remove argument. Use + last_text_section if nonnull, otherwise use function_section. + (default_function_rodata_section): Return a section rather than + emitting assembly code. Use get_section. + (default_no_function_rodata_section): Return a section rather than + emitting assembly code. + (variable_section): Use switch_to_section and get_named_section. + (mergeable_string_section): Return a section rather than emitting + assembly code. Use get_section. Make static. Don't take special + countermeasures for empty strings. + (mergeable_constant_section): Return a section rather than emitting + assembly code. Use get_section. + (default_named_section_asm_out_destructor): Use switch_to_section + and get_section. + (default_dtor_section_asm_out_destructor): Use switch_to_section. + (default_named_section_asm_out_constructor): Use switch_to_section + and get_section. + (default_ctor_section_asm_out_constructor): Use switch_to_section. + (assemble_start_function): Likewise. Set last_text_section to + NULL rather than no_section. Change the type of save_section. + (assemble_zeros, assemble_variable): Use the section flags to detect + whether or not a section is text. + (assemble_static_space): Use switch_to_section. + (assemble_trampoline_template): Likewise. + (output_constant_def_contents): Use switch_to_section and + get_named_section. + (output_constant_pool_1): Use switch_to_section. Use the section + flags to see whether sections contain mergeable data. + (init_varasm_once): Initialize section_htab instead of in_named_htab. + Initialize new section variables. Call TARGET_ASM_INIT_SECTIONS. + (default_elf_asm_named_section): Use SECTION_DECLARED to detect + whether a section has already been declared. + (default_select_section, default_elf_select_section): Return a + section rather than emitting assembly code. + (default_elf_select_section_1): Likewise. Use bss_section for + SECCAT_BSS if nonnull. Use get_named_section. + (default_select_rtx_section): Return a section rather than + emitting assembly code. + (default_elf_select_rtx_section): Likewise. Use get_named_section. + (file_end_indicate_exec_stack): Use switch_to_section and get_section. + (output_section_asm_op, switch_to_section): New functions. + * vmsdbgout.c (vmsdbgout_finish): Use switch_to_section and + get_named_section. + + * doc/tm.texi: Expand the introduction to the sections documentation. + (TRAMPOLINE_SECTION): Document new interface. + (SDATA_SECTION_ASM_OP): Document new macro. + (READONLY_DATA_SECTION): Delete. + (SDATA_SECTION_ASM_OP): Document new macro. + (EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS): Delete. + (TARGET_ASM_INIT_SECTIONS): Document new hook. + (TARGET_ASM_SELECT_SECTION, TARGET_ASM_FUNCTION_RODATA_SECTION) + (TARGET_ASM_SELECT_RTX_SECTION): Adjust for new interface. + (TARGET_EXCEPTION_SECTION, TARGET_EH_FRAME_SECTION): Delete. + 2005-12-07 Alan Modra * gcc.c (init_gcc_specs): Match braces inside conditionally diff --git a/gcc/Makefile.in b/gcc/Makefile.in index a464dd2..51d8731 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2743,7 +2743,7 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \ $(srcdir)/coverage.c $(srcdir)/function.h $(srcdir)/rtl.h \ $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(SYMTAB_H) \ $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \ - $(srcdir)/ipa-reference.h \ + $(srcdir)/ipa-reference.h $(srcdir)/output.h \ $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \ $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \ $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h index f6b237a..00fc525 100644 --- a/gcc/config/alpha/alpha-protos.h +++ b/gcc/config/alpha/alpha-protos.h @@ -127,8 +127,6 @@ extern rtx unicosmk_add_call_info_word (rtx); extern void unicosmk_defer_case_vector (rtx, rtx); extern void unicosmk_add_extern (const char *); extern void unicosmk_output_align (FILE *, int); -extern char * unicosmk_text_section (void); -extern char * unicosmk_data_section (void); extern void unicosmk_output_common (FILE *, const char *, int, int); extern int unicosmk_initial_elimination_offset (int, int); #endif diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 6824d07..244aa27 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -7959,14 +7959,14 @@ alpha_start_function (FILE *file, const char *fnname, #if TARGET_ABI_OPEN_VMS /* Ifdef'ed cause link_section are only available then. */ - readonly_data_section (); + switch_to_section (readonly_data_section); fprintf (file, "\t.align 3\n"); assemble_name (file, fnname); fputs ("..na:\n", file); fputs ("\t.ascii \"", file); assemble_name (file, fnname); fputs ("\\0\"\n", file); alpha_need_linkage (fnname, 1); - text_section (); + switch_to_section (text_section); #endif } @@ -9355,18 +9355,18 @@ alpha_file_start (void) #ifdef OBJECT_FORMAT_ELF -/* Switch to the section to which we should output X. The only thing - special we do here is to honor small data. */ +/* Return a section for X. The only special thing we do here is to + honor small data. */ -static void +static section * alpha_elf_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) { if (TARGET_SMALL_DATA && GET_MODE_SIZE (mode) <= g_switch_value) /* ??? Consider using mergeable sdata sections. */ - sdata_section (); + return sdata_section; else - default_elf_select_rtx_section (mode, x, align); + return default_elf_select_rtx_section (mode, x, align); } #endif /* OBJECT_FORMAT_ELF */ @@ -9636,8 +9636,10 @@ alpha_write_linkage (FILE *stream, const char *funname, tree fundecl) splay_tree_node node; struct alpha_funcs *func; - link_section (); + fprintf (stream, "\t.link\n"); fprintf (stream, "\t.align 3\n"); + in_section = NULL; + node = splay_tree_lookup (alpha_funcs_tree, (splay_tree_key) fundecl); func = (struct alpha_funcs *) node->value; @@ -9717,7 +9719,7 @@ vms_asm_named_section (const char *name, unsigned int flags, static void vms_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - ctors_section (); + switch_to_section (ctors_section); assemble_align (BITS_PER_WORD); assemble_integer (symbol, UNITS_PER_WORD, BITS_PER_WORD, 1); } @@ -9725,7 +9727,7 @@ vms_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) static void vms_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - dtors_section (); + switch_to_section (dtors_section); assemble_align (BITS_PER_WORD); assemble_integer (symbol, UNITS_PER_WORD, BITS_PER_WORD, 1); } @@ -9826,7 +9828,7 @@ unicosmk_output_common (FILE *file, const char *name, int size, int align) tree name_tree; printf ("T3E__: common %s\n", name); - common_section (); + in_section = NULL; fputs("\t.endp\n\n\t.psect ", file); assemble_name(file, name); fprintf(file, ",%d,common\n", floor_log2 (align / BITS_PER_UNIT)); @@ -9841,6 +9843,43 @@ unicosmk_output_common (FILE *file, const char *name, int size, int align) #define SECTION_MAIN (SECTION_PUBLIC << 1) static int current_section_align; +/* A get_unnamed_section callback for switching to the text section. */ + +static void +unicosmk_output_text_section_asm_op (const void *data ATTRIBUTE_UNUSED) +{ + static int count = 0; + fprintf (asm_out_file, "\t.endp\n\n\t.psect\tgcc@text___%d,code\n", count++); +} + +/* A get_unnamed_section callback for switching to the data section. */ + +static void +unicosmk_output_data_section_asm_op (const void *data ATTRIBUTE_UNUSED) +{ + static int count = 1; + fprintf (asm_out_file, "\t.endp\n\n\t.psect\tgcc@data___%d,data\n", count++); +} + +/* Implement TARGET_ASM_INIT_SECTIONS. + + The Cray assembler is really weird with respect to sections. It has only + named sections and you can't reopen a section once it has been closed. + This means that we have to generate unique names whenever we want to + reenter the text or the data section. */ + +static void +unicosmk_init_sections (void) +{ + text_section = get_unnamed_section (SECTION_CODE, + unicosmk_output_text_section_asm_op, + NULL); + data_section = get_unnamed_section (SECTION_WRITE, + unicosmk_output_data_section_asm_op, + NULL); + readonly_data_section = data_section; +} + static unsigned int unicosmk_section_type_flags (tree decl, const char *name, int reloc ATTRIBUTE_UNUSED) @@ -10004,7 +10043,7 @@ unicosmk_output_deferred_case_vectors (FILE *file) if (machine->addr_list == NULL_RTX) return; - data_section (); + switch_to_section (data_section); for (t = machine->addr_list; t; t = XEXP (t, 1)) unicosmk_output_addr_vec (file, XEXP (t, 0)); } @@ -10123,7 +10162,7 @@ unicosmk_output_ssib (FILE *file, const char *fnname) rtx ciw; struct machine_function *machine = cfun->machine; - ssib_section (); + in_section = NULL; fprintf (file, "\t.endp\n\n\t.psect\t%s%s,data\n", user_label_prefix, unicosmk_ssib_name ()); @@ -10195,26 +10234,6 @@ unicosmk_add_call_info_word (rtx x) + strlen (current_function_name ())/8 + 5); } -static char unicosmk_section_buf[100]; - -char * -unicosmk_text_section (void) -{ - static int count = 0; - sprintf (unicosmk_section_buf, "\t.endp\n\n\t.psect\tgcc@text___%d,code", - count++); - return unicosmk_section_buf; -} - -char * -unicosmk_data_section (void) -{ - static int count = 1; - sprintf (unicosmk_section_buf, "\t.endp\n\n\t.psect\tgcc@data___%d,data", - count++); - return unicosmk_section_buf; -} - /* The Cray assembler doesn't accept extern declarations for symbols which are defined in the same file. We have to keep track of all global symbols which are referenced and/or defined in a source file and output diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h index 43449f5..043a524 100644 --- a/gcc/config/alpha/elf.h +++ b/gcc/config/alpha/elf.h @@ -123,9 +123,9 @@ do { \ #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ do { \ if ((SIZE) <= g_switch_value) \ - sbss_section(); \ + switch_to_section (sbss_section); \ else \ - bss_section(); \ + switch_to_section (bss_section); \ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ if (!flag_inhibit_size_directive) \ ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \ @@ -193,37 +193,6 @@ do { \ #endif -/* A default list of other sections which we might be "in" at any given - time. For targets that use additional sections (e.g. .tdesc) you - should override this definition in the target-specific file which - includes this file. */ - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_sbss, in_sdata - -/* A default list of extra section function definitions. For targets - that use additional sections (e.g. .tdesc) you should override this - definition in the target-specific file which includes this file. */ - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \ - SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) - -extern void sbss_section (void); -extern void sdata_section (void); - -#undef SECTION_FUNCTION_TEMPLATE -#define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP) \ -void FN (void) \ -{ \ - if (in_section != ENUM) \ - { \ - fprintf (asm_out_file, "%s\n", OP); \ - in_section = ENUM; \ - } \ -} - /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section #define TARGET_ASM_SELECT_SECTION default_elf_select_section diff --git a/gcc/config/alpha/unicosmk.h b/gcc/config/alpha/unicosmk.h index da7d375..a05b333 100644 --- a/gcc/config/alpha/unicosmk.h +++ b/gcc/config/alpha/unicosmk.h @@ -244,51 +244,9 @@ do { fprintf (FILE, "\tbr $1,0\n"); \ /* Define this as 1 if `char' should by default be signed; else as 0. */ /* #define DEFAULT_SIGNED_CHAR 1 */ -/* The Cray assembler is really weird with respect to sections. It has only - named sections and you can't reopen a section once it has been closed. - This means that we have to generate unique names whenever we want to - reenter the text or the data section. The following is a rather bad hack - as TEXT_SECTION_ASM_OP and DATA_SECTION_ASM_OP are supposed to be - constants. */ - -#undef TEXT_SECTION_ASM_OP -#define TEXT_SECTION_ASM_OP unicosmk_text_section () - -#undef DATA_SECTION_ASM_OP -#define DATA_SECTION_ASM_OP unicosmk_data_section () - /* There are no read-only sections on Unicos/Mk. */ #undef READONLY_DATA_SECTION_ASM_OP -#define READONLY_DATA_SECTION data_section - -/* Define extra sections for common data and SSIBs (static subroutine - information blocks). The actual section header is output by the callers - of these functions. */ - -#undef EXTRA_SECTIONS -#undef EXTRA_SECTION_FUNCTIONS - -#define EXTRA_SECTIONS in_common, in_ssib -#define EXTRA_SECTION_FUNCTIONS \ -COMMON_SECTION \ -SSIB_SECTION - -extern void common_section (void); -#define COMMON_SECTION \ -void \ -common_section (void) \ -{ \ - in_section = in_common; \ -} - -extern void ssib_section (void); -#define SSIB_SECTION \ -void \ -ssib_section (void) \ -{ \ - in_section = in_ssib; \ -} /* We take care of this in unicosmk_file_start. */ @@ -413,7 +371,7 @@ ssib_section (void) \ #undef ASM_OUTPUT_LOCAL #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ - do { data_section (); \ + do { switch_to_section (data_section); \ fprintf (FILE, "\t.align\t%d\n", floor_log2 ((ALIGN) / BITS_PER_UNIT));\ ASM_OUTPUT_LABEL ((FILE), (NAME)); \ fprintf (FILE, "\t.byte 0:"HOST_WIDE_INT_PRINT_UNSIGNED"\n",(SIZE));\ @@ -449,6 +407,7 @@ ssib_section (void) \ /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION unicosmk_asm_named_section +#define TARGET_ASM_INIT_SECTIONS unicosmk_init_sections #undef ASM_OUTPUT_MAX_SKIP_ALIGN #define ASM_OUTPUT_MAX_SKIP_ALIGN(STREAM,POWER,MAXSKIP) diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h index c1f4a43..8354587 100644 --- a/gcc/config/alpha/vms.h +++ b/gcc/config/alpha/vms.h @@ -198,39 +198,10 @@ typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info; #undef STACK_CHECK_BUILTIN #define STACK_CHECK_BUILTIN 0 -#define LINK_SECTION_ASM_OP "\t.link" #define READONLY_DATA_SECTION_ASM_OP "\t.rdata" -#define LITERALS_SECTION_ASM_OP "\t.literals" #define CTORS_SECTION_ASM_OP "\t.ctors" #define DTORS_SECTION_ASM_OP "\t.dtors" -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_link, in_literals - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ -void \ -link_section (void) \ -{ \ - if (in_section != in_link) \ - { \ - fprintf (asm_out_file, "%s\n", LINK_SECTION_ASM_OP); \ - in_section = in_link; \ - } \ -} \ -void \ -literals_section (void) \ -{ \ - if (in_section != in_literals) \ - { \ - fprintf (asm_out_file, "%s\n", LITERALS_SECTION_ASM_OP); \ - in_section = in_literals; \ - } \ -} - -extern void link_section (void); -extern void literals_section (void); - #undef ASM_OUTPUT_ADDR_DIFF_ELT #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) gcc_unreachable () @@ -327,7 +298,8 @@ do { \ #define TARGET_ASM_NAMED_SECTION vms_asm_named_section #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ - do { literals_section(); \ + do { fprintf ((FILE), "\t.literals\n"); \ + in_section = NULL; \ fprintf ((FILE), "\t"); \ assemble_name (FILE, LABEL1); \ fprintf (FILE, " = "); \ diff --git a/gcc/config/arm/aof.h b/gcc/config/arm/aof.h index 45aacfe..8a1223c 100644 --- a/gcc/config/arm/aof.h +++ b/gcc/config/arm/aof.h @@ -44,48 +44,6 @@ #define LIBGCC_SPEC "libgcc.a%s" -/* Dividing the Output into Sections (Text, Data, ...) */ -/* AOF Assembler syntax is a nightmare when it comes to areas, since once - we change from one area to another, we can't go back again. Instead, - we must create a new area with the same attributes and add the new output - to that. Unfortunately, there is nothing we can do here to guarantee that - two areas with the same attributes will be linked adjacently in the - resulting executable, so we have to be careful not to do pc-relative - addressing across such boundaries. */ -#define TEXT_SECTION_ASM_OP aof_text_section () - -#define DATA_SECTION_ASM_OP aof_data_section () - -#define EXTRA_SECTIONS in_zero_init, in_common - -#define EXTRA_SECTION_FUNCTIONS \ - ZERO_INIT_SECTION \ - COMMON_SECTION - -#define ZERO_INIT_SECTION \ - void \ - zero_init_section () \ - { \ - static int zero_init_count = 1; \ - \ - if (in_section != in_zero_init) \ - { \ - fprintf (asm_out_file, "\tAREA |C$$zidata%d|,NOINIT\n", \ - zero_init_count++); \ - in_section = in_zero_init; \ - } \ - } - -/* Used by ASM_OUTPUT_COMMON (below) to tell varasm.c that we've - changed areas. */ -#define COMMON_SECTION \ - void \ - common_section () \ - { \ - if (in_section != in_common) \ - in_section = in_common; \ - } - #define CTOR_LIST_BEGIN \ asm (CTORS_SECTION_ASM_OP); \ extern func_ptr __CTOR_END__[1]; \ @@ -130,6 +88,8 @@ whole table generation until the end of the function. */ #define JUMP_TABLES_IN_TEXT_SECTION 1 +#define TARGET_ASM_INIT_SECTIONS aof_asm_init_sections + /* Some systems use __main in a way incompatible with its use in gcc, in these cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to give the same symbol without quotes for an alternative entry point. You @@ -159,7 +119,7 @@ /* Output of Uninitialized Variables. */ #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \ - (common_section (), \ + (in_section = NULL, \ fprintf ((STREAM), "\tAREA "), \ assemble_name ((STREAM), (NAME)), \ fprintf ((STREAM), ", DATA, COMMON\n\t%% %d\t%s size=%d\n", \ diff --git a/gcc/config/arm/aout.h b/gcc/config/arm/aout.h index 2b5d42f..903afa7 100644 --- a/gcc/config/arm/aout.h +++ b/gcc/config/arm/aout.h @@ -273,7 +273,7 @@ #define ASM_OUTPUT_ALIGNED_LOCAL(STREAM, NAME, SIZE, ALIGN) \ do \ { \ - bss_section (); \ + switch_to_section (bss_section); \ ASM_OUTPUT_ALIGN (STREAM, floor_log2 (ALIGN / BITS_PER_UNIT)); \ ASM_OUTPUT_LABEL (STREAM, NAME); \ fprintf (STREAM, "\t.space\t%d\n", (int)(SIZE)); \ diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 2bd84ca..4e0d77b 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -139,12 +139,9 @@ extern int arm_apply_result_size (void); #if defined AOF_ASSEMBLER extern rtx aof_pic_entry (rtx); -extern char *aof_text_section (void); -extern char *aof_data_section (void); extern void aof_add_import (const char *); extern void aof_delete_import (const char *); extern void zero_init_section (void); -extern void common_section (void); #endif /* AOF_ASSEMBLER */ #endif /* RTX_CODE */ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 009d142..4f35719 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -161,6 +161,7 @@ static void aof_dump_imports (FILE *); static void aof_dump_pic_table (FILE *); static void aof_file_start (void); static void aof_file_end (void); +static void aof_asm_init_sections (void); #endif static rtx arm_struct_value_rtx (tree, int); static void arm_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode, @@ -7297,11 +7298,7 @@ get_jump_table_size (rtx insn) { /* ADDR_VECs only take room if read-only data does into the text section. */ - if (JUMP_TABLES_IN_TEXT_SECTION -#if !defined(READONLY_DATA_SECTION) && !defined(READONLY_DATA_SECTION_ASM_OP) - || 1 -#endif - ) + if (JUMP_TABLES_IN_TEXT_SECTION || readonly_data_section == text_section) { rtx body = PATTERN (insn); int elt = GET_CODE (body) == ADDR_DIFF_VEC ? 1 : 0; @@ -10064,7 +10061,7 @@ arm_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED, if (label != NULL) { - function_section (current_function_decl); + switch_to_section (function_section (current_function_decl)); targetm.asm_out.internal_label (asm_out_file, "L", CODE_LABEL_NUMBER (label)); asm_fprintf (asm_out_file, "\tbx\t%r\n", regno); @@ -11281,7 +11278,7 @@ arm_elf_asm_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) } /* Put these in the .init_array section, using a special relocation. */ - ctors_section (); + switch_to_section (ctors_section); assemble_align (POINTER_SIZE); fputs ("\t.word\t", asm_out_file); output_addr_const (asm_out_file, symbol); @@ -14195,7 +14192,7 @@ thumb_call_via_reg (rtx reg) /* If we are in the normal text section we can use a single instance per compilation unit. If we are doing function sections, then we need an entry per section, since we can't rely on reachability. */ - if (in_text_section ()) + if (in_section == text_section) { thumb_call_reg_needed = 1; @@ -14332,7 +14329,7 @@ arm_file_end (void) if (! thumb_call_reg_needed) return; - text_section (); + switch_to_section (text_section); asm_fprintf (asm_out_file, "\t.code 16\n"); ASM_OUTPUT_ALIGN (asm_out_file, 1); @@ -14407,25 +14404,56 @@ aof_dump_pic_table (FILE *f) int arm_text_section_count = 1; -char * -aof_text_section (void ) +/* A get_unnamed_section callback for switching to the text section. */ + +static void +aof_output_text_section_asm_op (const void *data ATTRIBUTE_UNUSED) { - static char buf[100]; - sprintf (buf, "\tAREA |C$$code%d|, CODE, READONLY", + fprintf (asm_out_file, "\tAREA |C$$code%d|, CODE, READONLY", arm_text_section_count++); if (flag_pic) - strcat (buf, ", PIC, REENTRANT"); - return buf; + fprintf (asm_out_file, ", PIC, REENTRANT"); + fprintf (asm_out_file, "\n"); } static int arm_data_section_count = 1; -char * -aof_data_section (void) +/* A get_unnamed_section callback for switching to the data section. */ + +static void +aof_output_data_section_asm_op (const void *data ATTRIBUTE_UNUSED) +{ + fprintf (asm_out_file, "\tAREA |C$$data%d|, DATA\n", + arm_data_section_count++); +} + +/* Implement TARGET_ASM_INIT_SECTIONS. + + AOF Assembler syntax is a nightmare when it comes to areas, since once + we change from one area to another, we can't go back again. Instead, + we must create a new area with the same attributes and add the new output + to that. Unfortunately, there is nothing we can do here to guarantee that + two areas with the same attributes will be linked adjacently in the + resulting executable, so we have to be careful not to do pc-relative + addressing across such boundaries. */ + +static void +aof_asm_init_sections (void) +{ + text_section = get_unnamed_section (SECTION_CODE, + aof_output_text_section_asm_op, NULL); + data_section = get_unnamed_section (SECTION_WRITE, + aof_output_data_section_asm_op, NULL); + readonly_data_section = text_section; +} + +void +zero_init_section (void) { - static char buf[100]; - sprintf (buf, "\tAREA |C$$data%d|, DATA", arm_data_section_count++); - return buf; + static int zero_init_count = 1; + + fprintf (asm_out_file, "\tAREA |C$$zidata%d|,NOINIT\n", zero_init_count++); + in_section = NULL; } /* The AOF assembler is religiously strict about declarations of @@ -14486,7 +14514,7 @@ aof_dump_imports (FILE *f) automagically. */ if (arm_main_function) { - text_section (); + switch_to_section (text_section); fputs ("\tIMPORT __main\n", f); fputs ("\tDCD __main\n", f); } @@ -14537,7 +14565,7 @@ aof_file_start (void) fputs ("__f5\tFN\t5\n", asm_out_file); fputs ("__f6\tFN\t6\n", asm_out_file); fputs ("__f7\tFN\t7\n", asm_out_file); - text_section (); + switch_to_section (text_section); } static void diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 2bca153..b7b775c 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -1527,7 +1527,7 @@ typedef struct machine_function GTY(()) machine_function; /* As in the machine_function, a global set of call-via labels, for code - that is in text_section(). */ + that is in text_section. */ extern GTY(()) rtx thumb_call_via_label[14]; /* A C type for declaring a variable that is used as the first argument of diff --git a/gcc/config/arm/pe.h b/gcc/config/arm/pe.h index 2b806d3..f96cd66a 100644 --- a/gcc/config/arm/pe.h +++ b/gcc/config/arm/pe.h @@ -93,7 +93,7 @@ drectve_section (); \ fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \ arm_strip_name_encoding (NAME)); \ - function_section (DECL); \ + switch_to_section (function_section (DECL)); \ } \ ARM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL); \ if (TARGET_THUMB) \ @@ -130,11 +130,11 @@ { \ if (arm_dllexport_name_p (NAME)) \ { \ - enum in_section save_section = in_section; \ + section *save_section = in_section; \ drectve_section (); \ fprintf (STREAM, "\t.ascii \" -export:%s\"\n",\ arm_strip_name_encoding (NAME)); \ - switch_to_section (save_section, (DECL)); \ + switch_to_section (save_section); \ } \ ASM_OUTPUT_LABEL ((STREAM), (NAME)); \ } \ @@ -144,51 +144,6 @@ #define DRECTVE_SECTION_ASM_OP "\t.section .drectve" -/* A list of other sections which the compiler might be "in" at any - given time. */ - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_drectve - -/* A list of extra section function definitions. */ - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - DRECTVE_SECTION_FUNCTION \ - SWITCH_TO_SECTION_FUNCTION - -#define DRECTVE_SECTION_FUNCTION \ -void \ -drectve_section (void) \ -{ \ - if (in_section != in_drectve) \ - { \ - fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP); \ - in_section = in_drectve; \ - } \ -} - -/* Switch to SECTION (an `enum in_section'). - - ??? This facility should be provided by GCC proper. - The problem is that we want to temporarily switch sections in - ASM_DECLARE_OBJECT_NAME and then switch back to the original section - afterwards. */ -#define SWITCH_TO_SECTION_FUNCTION \ -static void \ -switch_to_section (enum in_section section, tree decl) \ -{ \ - switch (section) \ - { \ - case in_text: text_section (); break; \ - case in_unlikely_executed_text: unlikely_text_section (); break; \ - case in_data: data_section (); break; \ - case in_named: named_section (decl, NULL, 0); break; \ - case in_readonly_data: readonly_data_section (); break; \ - case in_ctors: ctors_section (); break; \ - case in_dtors: dtors_section (); break; \ - case in_drectve: drectve_section (); break; \ - default: abort (); break; \ - } \ -} - +#define drectve_section() \ + (fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP), \ + in_section = NULL) diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h index 916aac9..c9ad990 100644 --- a/gcc/config/arm/unknown-elf.h +++ b/gcc/config/arm/unknown-elf.h @@ -58,9 +58,9 @@ do \ { \ if (IN_NAMED_SECTION (DECL)) \ - named_section (DECL, NULL, 0); \ + switch_to_section (get_named_section (DECL, NULL, 0)); \ else \ - bss_section (); \ + switch_to_section (bss_section); \ \ ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \ \ @@ -75,9 +75,9 @@ do \ { \ if ((DECL) != NULL && IN_NAMED_SECTION (DECL)) \ - named_section (DECL, NULL, 0); \ + switch_to_section (get_named_section (DECL, NULL, 0)); \ else \ - bss_section (); \ + switch_to_section (bss_section); \ \ ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \ ASM_OUTPUT_LABEL (FILE, NAME); \ diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h index 930329b..169be85 100644 --- a/gcc/config/avr/avr-protos.h +++ b/gcc/config/avr/avr-protos.h @@ -35,7 +35,6 @@ extern void asm_globalize_label (FILE *file, const char *name); extern void order_regs_for_local_alloc (void); extern int initial_elimination_offset (int from, int to); extern int avr_simple_epilogue (void); -extern void progmem_section (void); extern int mask_one_bit_p (HOST_WIDE_INT mask); extern void gas_output_limited_string (FILE *file, const char *str); extern void gas_output_ascii (FILE *file, const char *str, size_t length); diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 5367bd1..f6e9f9f 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -69,6 +69,7 @@ static void avr_file_end (void); static void avr_output_function_prologue (FILE *, HOST_WIDE_INT); static void avr_output_function_epilogue (FILE *, HOST_WIDE_INT); static void avr_insert_attributes (tree, tree *); +static void avr_asm_init_sections (void); static unsigned int avr_section_type_flags (tree, const char *, int); static void avr_reorg (void); @@ -114,6 +115,8 @@ static int jump_tables_size; const char *avr_base_arch_macro; const char *avr_extra_arch_macro; +section *progmem_section; + /* More than 8K of program memory: use "call" and "jmp". */ int avr_mega_p = 0; @@ -4756,6 +4759,29 @@ avr_insert_attributes (tree node, tree *attributes) } } +/* A get_unnamed_section callback for switching to progmem_section. */ + +static void +avr_output_progmem_section_asm_op (const void *arg ATTRIBUTE_UNUSED) +{ + fprintf (asm_out_file, + "\t.section .progmem.gcc_sw_table, \"%s\", @progbits\n", + AVR_MEGA ? "a" : "ax"); + /* Should already be aligned, this is just to be safe if it isn't. */ + fprintf (asm_out_file, "\t.p2align 1\n"); +} + +/* Implement TARGET_ASM_INIT_SECTIONS. */ + +static void +avr_asm_init_sections (void) +{ + progmem_section = get_unnamed_section (AVR_MEGA ? 0 : SECTION_CODE, + avr_output_progmem_section_asm_op, + NULL); + readonly_data_section = data_section; +} + static unsigned int avr_section_type_flags (tree decl, const char *name, int reloc) { @@ -5847,7 +5873,7 @@ avr_output_bld (rtx operands[], int bit_nr) void avr_output_addr_vec_elt (FILE *stream, int value) { - progmem_section (); + switch_to_section (progmem_section); if (AVR_MEGA) fprintf (stream, "\t.word pm(.L%d)\n", value); else diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index 53a0f9f..d69e67b 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -47,6 +47,7 @@ extern const char *avr_extra_arch_macro; extern int avr_mega_p; extern int avr_enhanced_p; extern int avr_asm_only_p; +extern GTY(()) section *progmem_section; #define AVR_MEGA (avr_mega_p && !TARGET_SHORT_CALLS) #define AVR_ENHANCED (avr_enhanced_p) @@ -476,26 +477,6 @@ do { \ #define TARGET_ASM_DESTRUCTOR avr_asm_out_dtor -#define EXTRA_SECTIONS in_progmem - -#define EXTRA_SECTION_FUNCTIONS \ - \ -void \ -progmem_section (void) \ -{ \ - if (in_section != in_progmem) \ - { \ - fprintf (asm_out_file, \ - "\t.section .progmem.gcc_sw_table, \"%s\", @progbits\n", \ - AVR_MEGA ? "a" : "ax"); \ - /* Should already be aligned, this is just to be safe if it isn't. */ \ - fprintf (asm_out_file, "\t.p2align 1\n"); \ - in_section = in_progmem; \ - } \ -} - -#define READONLY_DATA_SECTION data_section - #define JUMP_TABLES_IN_TEXT_SECTION 0 #define ASM_COMMENT_START " ; " @@ -506,6 +487,7 @@ progmem_section (void) \ /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section +#define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections #define ASM_OUTPUT_ASCII(FILE, P, SIZE) gas_output_ascii (FILE,P,SIZE) @@ -682,7 +664,8 @@ sprintf (STRING, "*.%s%lu", PREFIX, (unsigned long)(NUM)) avr_output_addr_vec_elt(STREAM, VALUE) #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \ - progmem_section (), (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM) + (switch_to_section (progmem_section), \ + (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM)) #define ASM_OUTPUT_SKIP(STREAM, N) \ fprintf (STREAM, "\t.skip %lu,0\n", (unsigned long)(N)) diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h index 5ac0036..803aa58 100644 --- a/gcc/config/bfin/bfin.h +++ b/gcc/config/bfin/bfin.h @@ -1094,7 +1094,7 @@ do { char __buf[256]; \ #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ do { \ - data_section(); \ + switch_to_section (data_section); \ if ((SIZE) >= (unsigned int) 4 ) ASM_OUTPUT_ALIGN(FILE,2); \ ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \ ASM_OUTPUT_LABEL (FILE, NAME); \ diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index 43d44b1..22904e1 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -1239,37 +1239,6 @@ if (REG_P (OP1) && ! REG_P (OP0)) \ #define FINI_SECTION_ASM_OP "\t.sect\t\".fini\"" -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_init, in_fini - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - INIT_SECTION_FUNCTION \ - FINI_SECTION_FUNCTION - -#define INIT_SECTION_FUNCTION \ -extern void init_section (void); \ -void \ -init_section (void) \ -{ \ - if (in_section != in_init) \ - { \ - fprintf (asm_out_file, ";\t.init\n"); \ - in_section = in_init; \ - } \ -} - -#define FINI_SECTION_FUNCTION \ -void \ -fini_section () \ -{ \ - if (in_section != in_fini) \ - { \ - fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP); \ - in_section = in_fini; \ - } \ -} - /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION c4x_asm_named_section diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index dfada76..ad9ce78 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -18,6 +18,7 @@ along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +extern void darwin_init_sections (void); extern int name_needs_quotes (const char *); extern void machopic_validate_stub_or_non_lazy_ptr (const char *); @@ -27,18 +28,6 @@ extern void machopic_output_function_base_name (FILE *); extern const char *machopic_indirection_name (rtx, bool); extern const char *machopic_mcount_stub_name (void); -extern void machopic_picsymbol_stub_section (void); -extern void machopic_picsymbol_stub1_section (void); -extern void machopic_symbol_stub_section (void); -extern void machopic_symbol_stub1_section (void); -extern void machopic_lazy_symbol_ptr_section (void); -extern void machopic_nl_symbol_ptr_section (void); - -extern void constructor_section (void); -extern void destructor_section (void); -extern void mod_init_section (void); -extern void mod_term_section (void); - #ifdef RTX_CODE extern rtx machopic_function_base_sym (void); @@ -62,11 +51,9 @@ extern void darwin_encode_section_info (tree, rtx, int); extern void machopic_finish (FILE *); -extern void darwin_exception_section (void); -extern void darwin_eh_frame_section (void); -extern void machopic_select_section (tree, int, unsigned HOST_WIDE_INT); -extern void machopic_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); +extern section *machopic_select_section (tree, int, unsigned HOST_WIDE_INT); +extern section *machopic_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); extern void darwin_unique_section (tree decl, int reloc); extern void darwin_asm_named_section (const char *, unsigned int, tree); @@ -85,51 +72,7 @@ extern void darwin_mark_decl_preserved (const char *); extern tree darwin_handle_weak_import_attribute (tree *node, tree name, tree args, int flags, bool * no_add_attrs); - -/* Expanded by EXTRA_SECTION_FUNCTIONS into varasm.o. */ -extern void text_coal_section (void); -extern void text_unlikely_section (void); -extern void text_unlikely_coal_section (void); -extern void const_section (void); -extern void const_coal_section (void); -extern void const_data_section (void); -extern void const_data_coal_section (void); -extern void data_coal_section (void); -extern void cstring_section (void); -extern void literal4_section (void); -extern void literal8_section (void); -extern void constructor_section (void); -extern void mod_init_section (void); -extern void mod_term_section (void); -extern void destructor_section (void); -extern void objc_class_section (void); -extern void objc_meta_class_section (void); -extern void objc_category_section (void); -extern void objc_class_vars_section (void); -extern void objc_instance_vars_section (void); -extern void objc_cls_meth_section (void); -extern void objc_inst_meth_section (void); -extern void objc_cat_cls_meth_section (void); -extern void objc_cat_inst_meth_section (void); -extern void objc_selector_refs_section (void); -extern void objc_selector_fixup_section (void); -extern void objc_symbols_section (void); -extern void objc_module_info_section (void); -extern void objc_image_info_section (void); -extern void objc_protocol_section (void); -extern void objc_string_object_section (void); -extern void objc_constant_string_object_section (void); -extern void objc_class_names_section (void); -extern void objc_meth_var_names_section (void); -extern void objc_meth_var_types_section (void); -extern void objc_cls_refs_section (void); -extern void machopic_lazy_symbol_ptr_section (void); -extern void machopic_nl_symbol_ptr_section (void); -extern void machopic_symbol_stub_section (void); -extern void machopic_picsymbol_stub_section (void); extern void machopic_output_stub (FILE *, const char *, const char *); -extern void darwin_exception_section (void); -extern void darwin_eh_frame_section (void); extern void darwin_globalize_label (FILE *, const char *); extern void darwin_assemble_visibility (tree, int); extern void darwin_asm_output_dwarf_delta (FILE *, int, const char *, diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def new file mode 100644 index 0000000..327c175 --- /dev/null +++ b/gcc/config/darwin-sections.def @@ -0,0 +1,62 @@ +DEF_SECTION (text_coal_section, SECTION_CODE, + ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", 0) +DEF_SECTION (text_unlikely_coal_section, SECTION_CODE, + ".section __TEXT,__text_unlikely_coal," + "coalesced,pure_instructions", 0) +DEF_SECTION (const_section, 0, ".const", 0) +DEF_SECTION (const_coal_section, 0, + ".section __TEXT,__const_coal,coalesced", 0) +DEF_SECTION (const_data_section, 0, ".const_data", 0) +DEF_SECTION (const_data_coal_section, 0, + ".section __DATA,__const_coal,coalesced", 0) +DEF_SECTION (data_coal_section, SECTION_WRITE, + ".section __DATA,__datacoal_nt,coalesced", 0) +DEF_SECTION (cstring_section, 0, ".cstring", 0) +DEF_SECTION (literal4_section, 0, ".literal4", 0) +DEF_SECTION (literal8_section, 0, ".literal8", 0) +DEF_SECTION (constructor_section, 0, ".constructor", 0) +DEF_SECTION (mod_init_section, 0, ".mod_init_func", 0) +DEF_SECTION (mod_term_section, 0, ".mod_term_func", 0) +DEF_SECTION (destructor_section, 0, ".destructor", 0) +DEF_SECTION (objc_class_section, 0, ".objc_class", 1) +DEF_SECTION (objc_meta_class_section, 0, ".objc_meta_class", 1) +DEF_SECTION (objc_category_section, 0, ".objc_category", 1) +DEF_SECTION (objc_class_vars_section, 0, ".objc_class_vars", 1) +DEF_SECTION (objc_instance_vars_section, 0, ".objc_instance_vars", 1) +DEF_SECTION (objc_cls_meth_section, 0, ".objc_cls_meth", 1) +DEF_SECTION (objc_inst_meth_section, 0, ".objc_inst_meth", 1) +DEF_SECTION (objc_cat_cls_meth_section, 0, ".objc_cat_cls_meth", 1) +DEF_SECTION (objc_cat_inst_meth_section, 0, ".objc_cat_inst_meth", 1) +DEF_SECTION (objc_selector_refs_section, 0, ".objc_message_refs", 1) +DEF_SECTION (objc_selector_fixup_section, 0, + ".section __OBJC, __sel_fixup, regular, no_dead_strip", 1) +DEF_SECTION (objc_symbols_section, 0, ".objc_symbols", 1) +DEF_SECTION (objc_module_info_section, 0, ".objc_module_info", 1) +DEF_SECTION (objc_protocol_section, 0, ".objc_protocol", 1) +DEF_SECTION (objc_string_object_section, 0, ".objc_string_object", 1) +DEF_SECTION (objc_constant_string_object_section, 0, + ".section __OBJC, __cstring_object, regular, no_dead_strip", 1) + +/* Fix-and-Continue image marker. */ +DEF_SECTION (objc_image_info_section, 0, + ".section __OBJC, __image_info, regular, no_dead_strip", 1) +DEF_SECTION (objc_class_names_section, 0, ".objc_class_names", 1) +DEF_SECTION (objc_meth_var_names_section, 0, ".objc_meth_var_names", 1) +DEF_SECTION (objc_meth_var_types_section, 0, ".objc_meth_var_types", 1) +DEF_SECTION (objc_cls_refs_section, 0, ".objc_cls_refs", 1) + +DEF_SECTION (machopic_lazy_symbol_ptr_section, 0, ".lazy_symbol_pointer", 0) +DEF_SECTION (machopic_nl_symbol_ptr_section, 0, ".non_lazy_symbol_pointer", 0) +DEF_SECTION (machopic_symbol_stub_section, 0, ".symbol_stub", 0) +DEF_SECTION (machopic_symbol_stub1_section, 0, + ".section __TEXT,__symbol_stub1,symbol_stubs," + "pure_instructions,16", 0) +DEF_SECTION (machopic_picsymbol_stub_section, 0, ".picsymbol_stub", 0) +DEF_SECTION (machopic_picsymbol_stub1_section, 0, + ".section __TEXT,__picsymbolstub1,symbol_stubs," + "pure_instructions,32", 0) +DEF_SECTION (darwin_exception_section, 0, + ".section __DATA,__gcc_except_tab", 0) +DEF_SECTION (darwin_eh_frame_section, 0, + ".section " EH_FRAME_SECTION_NAME ",__eh_frame" + EH_FRAME_SECTION_ATTR, 0) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 54edae4..badc0d3 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -76,6 +76,65 @@ Boston, MA 02110-1301, USA. */ of MACHO_SYMBOL_STATIC for the code that handles @code{static} symbol indirection. */ +/* Define the individual section variables. */ +#define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) section *NAME; +#include "config/darwin-sections.def" +#undef DEF_SECTION + +/* A get_unnamed_section callback used to switch to an ObjC section. + DIRECTIVE is as for output_section_asm_op. */ + +static void +output_objc_section_asm_op (const void *directive) +{ + static int been_here = 0; + + if (been_here == 0) + { + been_here = 1; + /* written, cold -> hot */ + switch_to_section (objc_cat_cls_meth_section); + switch_to_section (objc_cat_inst_meth_section); + switch_to_section (objc_string_object_section); + switch_to_section (objc_constant_string_object_section); + switch_to_section (objc_selector_refs_section); + switch_to_section (objc_selector_fixup_section); + switch_to_section (objc_cls_refs_section); + switch_to_section (objc_class_section); + switch_to_section (objc_meta_class_section); + /* shared, hot -> cold */ + switch_to_section (objc_cls_meth_section); + switch_to_section (objc_inst_meth_section); + switch_to_section (objc_protocol_section); + switch_to_section (objc_class_names_section); + switch_to_section (objc_meth_var_types_section); + switch_to_section (objc_meth_var_names_section); + switch_to_section (objc_category_section); + switch_to_section (objc_class_vars_section); + switch_to_section (objc_instance_vars_section); + switch_to_section (objc_module_info_section); + switch_to_section (objc_symbols_section); + } + output_section_asm_op (directive); +} + +/* Implement TARGET_ASM_INIT_SECTIONS. */ + +void +darwin_init_sections (void) +{ +#define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) \ + NAME = get_unnamed_section (FLAGS, (OBJC \ + ? output_objc_section_asm_op \ + : output_section_asm_op), \ + "\t" DIRECTIVE); +#include "darwin-sections.def" +#undef DEF_SECTION + + readonly_data_section = const_section; + exception_section = darwin_exception_section; + eh_frame_section = darwin_eh_frame_section; +} int name_needs_quotes (const char *name) @@ -909,7 +968,7 @@ machopic_output_indirection (void **slot, void *data) && (machopic_symbol_defined_p (symbol) || SYMBOL_REF_LOCAL_P (symbol))) { - data_section (); + switch_to_section (data_section); assemble_align (GET_MODE_ALIGNMENT (Pmode)); assemble_label (ptr_name); assemble_integer (gen_rtx_SYMBOL_REF (Pmode, sym_name), @@ -920,7 +979,7 @@ machopic_output_indirection (void **slot, void *data) { rtx init = const0_rtx; - machopic_nl_symbol_ptr_section (); + switch_to_section (machopic_nl_symbol_ptr_section); assemble_name (asm_out_file, ptr_name); fprintf (asm_out_file, ":\n"); @@ -1022,41 +1081,38 @@ darwin_mark_decl_preserved (const char *name) fputc ('\n', asm_out_file); } -void +section * machopic_select_section (tree exp, int reloc, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { - void (*base_function)(void); + section *base_section; bool weak_p = (DECL_P (exp) && DECL_WEAK (exp) && (lookup_attribute ("weak", DECL_ATTRIBUTES (exp)) || ! lookup_attribute ("weak_import", DECL_ATTRIBUTES (exp)))); - static void (* const base_funs[][2])(void) = { - { text_section, text_coal_section }, - { unlikely_text_section, text_unlikely_coal_section }, - { readonly_data_section, const_coal_section }, - { const_data_section, const_data_coal_section }, - { data_section, data_coal_section } - }; - - if (reloc == 0 - && (last_text_section == in_text_unlikely - || last_text_section == in_text_unlikely_coal)) - reloc = 1; - + if (TREE_CODE (exp) == FUNCTION_DECL) - base_function = base_funs[reloc][weak_p]; + { + if (reloc == 1 + || unlikely_text_section_p (last_text_section) + || last_text_section == text_unlikely_coal_section) + base_section = (weak_p + ? text_unlikely_coal_section + : unlikely_text_section ()); + else + base_section = weak_p ? text_coal_section : text_section; + } else if (decl_readonly_section_1 (exp, reloc, MACHOPIC_INDIRECT)) - base_function = base_funs[2][weak_p]; + base_section = weak_p ? const_coal_section : const_section; else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) - base_function = base_funs[3][weak_p]; + base_section = weak_p ? const_data_coal_section : const_data_section; else - base_function = base_funs[4][weak_p]; + base_section = weak_p ? data_coal_section : data_section; if (TREE_CODE (exp) == STRING_CST && ((size_t) TREE_STRING_LENGTH (exp) == strlen (TREE_STRING_POINTER (exp)) + 1)) - cstring_section (); + return cstring_section; else if ((TREE_CODE (exp) == INTEGER_CST || TREE_CODE (exp) == REAL_CST) && flag_merge_constants) { @@ -1065,13 +1121,13 @@ machopic_select_section (tree exp, int reloc, if (TREE_CODE (size) == INTEGER_CST && TREE_INT_CST_LOW (size) == 4 && TREE_INT_CST_HIGH (size) == 0) - literal4_section (); + return literal4_section; else if (TREE_CODE (size) == INTEGER_CST && TREE_INT_CST_LOW (size) == 8 && TREE_INT_CST_HIGH (size) == 0) - literal8_section (); + return literal8_section; else - base_function (); + return base_section; } else if (TREE_CODE (exp) == CONSTRUCTOR && TREE_TYPE (exp) @@ -1085,12 +1141,12 @@ machopic_select_section (tree exp, int reloc, if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_ObjCString")) { if (flag_next_runtime) - objc_constant_string_object_section (); + return objc_constant_string_object_section; else - objc_string_object_section (); + return objc_string_object_section; } else - base_function (); + return base_section; } else if (TREE_CODE (exp) == VAR_DECL && DECL_NAME (exp) && @@ -1101,89 +1157,89 @@ machopic_select_section (tree exp, int reloc, const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) - objc_cls_meth_section (); + return objc_cls_meth_section; else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) - objc_inst_meth_section (); + return objc_inst_meth_section; else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) - objc_cat_cls_meth_section (); + return objc_cat_cls_meth_section; else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) - objc_cat_inst_meth_section (); + return objc_cat_inst_meth_section; else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) - objc_class_vars_section (); + return objc_class_vars_section; else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) - objc_instance_vars_section (); + return objc_instance_vars_section; else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) - objc_cat_cls_meth_section (); + return objc_cat_cls_meth_section; else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) - objc_class_names_section (); + return objc_class_names_section; else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) - objc_meth_var_names_section (); + return objc_meth_var_names_section; else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) - objc_meth_var_types_section (); + return objc_meth_var_types_section; else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) - objc_cls_refs_section (); + return objc_cls_refs_section; else if (!strncmp (name, "_OBJC_CLASS_", 12)) - objc_class_section (); + return objc_class_section; else if (!strncmp (name, "_OBJC_METACLASS_", 16)) - objc_meta_class_section (); + return objc_meta_class_section; else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) - objc_category_section (); + return objc_category_section; else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) - objc_selector_refs_section (); + return objc_selector_refs_section; else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) - objc_selector_fixup_section (); + return objc_selector_fixup_section; else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) - objc_symbols_section (); + return objc_symbols_section; else if (!strncmp (name, "_OBJC_MODULES", 13)) - objc_module_info_section (); + return objc_module_info_section; else if (!strncmp (name, "_OBJC_IMAGE_INFO", 16)) - objc_image_info_section (); + return objc_image_info_section; else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) - objc_cat_inst_meth_section (); + return objc_cat_inst_meth_section; else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) - objc_cat_cls_meth_section (); + return objc_cat_cls_meth_section; else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) - objc_cat_cls_meth_section (); + return objc_cat_cls_meth_section; else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) - objc_protocol_section (); + return objc_protocol_section; else - base_function (); + return base_section; } else - base_function (); + return base_section; } /* This can be called with address expressions as "rtx". They must go in "const". */ -void +section * machopic_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { if (GET_MODE_SIZE (mode) == 8 && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE)) - literal8_section (); + return literal8_section; else if (GET_MODE_SIZE (mode) == 4 && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE)) - literal4_section (); + return literal4_section; else if (MACHOPIC_INDIRECT && (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == CONST || GET_CODE (x) == LABEL_REF)) - const_data_section (); + return const_data_section; else - const_section (); + return const_section; } void machopic_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { if (MACHOPIC_INDIRECT) - mod_init_section (); + switch_to_section (mod_init_section); else - constructor_section (); + switch_to_section (constructor_section); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); @@ -1195,9 +1251,9 @@ void machopic_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { if (MACHOPIC_INDIRECT) - mod_term_section (); + switch_to_section (mod_term_section); else - destructor_section (); + switch_to_section (destructor_section); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); @@ -1389,8 +1445,8 @@ darwin_file_end (void) machopic_finish (asm_out_file); if (strcmp (lang_hooks.name, "GNU C++") == 0) { - constructor_section (); - destructor_section (); + switch_to_section (constructor_section); + switch_to_section (destructor_section); ASM_OUTPUT_ALIGN (asm_out_file, 1); } fprintf (asm_out_file, "\t.subsections_via_symbols\n"); diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 48bf079..8afae45 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -441,7 +441,7 @@ Boston, MA 02110-1301, USA. */ #define NO_PROFILE_COUNTERS 1 #undef INIT_SECTION_ASM_OP -#define INIT_SECTION_ASM_OP +#define HAS_INIT_SECTION #undef INVOKE__main @@ -609,233 +609,10 @@ Boston, MA 02110-1301, USA. */ #undef MAX_OFILE_ALIGNMENT #define MAX_OFILE_ALIGNMENT 0x8000 -/* Create new Mach-O sections. */ - -#undef SECTION_FUNCTION -#define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, OBJC) \ -extern void FUNCTION (void); \ -void \ -FUNCTION (void) \ -{ \ - if (in_section != SECTION) \ - { \ - if (OBJC) \ - objc_section_init (); \ - if (asm_out_file) \ - fputs ("\t" DIRECTIVE "\n", asm_out_file); \ - in_section = SECTION; \ - if ((SECTION == in_text_coal) \ - || (SECTION == in_text_unlikely) \ - || (SECTION == in_text_unlikely_coal)) \ - last_text_section = SECTION; \ - } \ -} \ - -/* Darwin uses many types of special sections. */ - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS \ - in_text_coal, in_text_unlikely, in_text_unlikely_coal, \ - in_const, in_const_data, in_cstring, in_literal4, in_literal8, \ - in_const_coal, in_const_data_coal, in_data_coal, \ - in_constructor, in_destructor, in_mod_init, in_mod_term, \ - in_objc_class, in_objc_meta_class, in_objc_category, \ - in_objc_class_vars, in_objc_instance_vars, \ - in_objc_cls_meth, in_objc_inst_meth, \ - in_objc_cat_cls_meth, in_objc_cat_inst_meth, \ - in_objc_selector_refs, \ - in_objc_selector_fixup, \ - in_objc_symbols, in_objc_module_info, \ - in_objc_protocol, in_objc_string_object, \ - in_objc_constant_string_object, \ - in_objc_image_info, \ - in_objc_class_names, in_objc_meth_var_names, \ - in_objc_meth_var_types, in_objc_cls_refs, \ - in_machopic_nl_symbol_ptr, \ - in_machopic_lazy_symbol_ptr, \ - in_machopic_symbol_stub, \ - in_machopic_symbol_stub1, \ - in_machopic_picsymbol_stub, \ - in_machopic_picsymbol_stub1, \ - in_darwin_exception, in_darwin_eh_frame, \ - num_sections - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ -static void objc_section_init (void); \ -SECTION_FUNCTION (text_coal_section, \ - in_text_coal, \ - ".section __TEXT,__textcoal_nt,coalesced," \ - "pure_instructions", 0) \ -SECTION_FUNCTION (text_unlikely_coal_section, \ - in_text_unlikely_coal, \ - ".section __TEXT,__text_unlikely_coal," \ - "coalesced,pure_instructions", 0) \ -SECTION_FUNCTION (const_section, \ - in_const, \ - ".const", 0) \ -SECTION_FUNCTION (const_coal_section, \ - in_const_coal, \ - ".section __TEXT,__const_coal,coalesced", 0) \ -SECTION_FUNCTION (const_data_section, \ - in_const_data, \ - ".const_data", 0) \ -SECTION_FUNCTION (const_data_coal_section, \ - in_const_data_coal, \ - ".section __DATA,__const_coal,coalesced", 0) \ -SECTION_FUNCTION (data_coal_section, \ - in_data_coal, \ - ".section __DATA,__datacoal_nt,coalesced", 0) \ -SECTION_FUNCTION (cstring_section, \ - in_cstring, \ - ".cstring", 0) \ -SECTION_FUNCTION (literal4_section, \ - in_literal4, \ - ".literal4", 0) \ -SECTION_FUNCTION (literal8_section, \ - in_literal8, \ - ".literal8", 0) \ -SECTION_FUNCTION (constructor_section, \ - in_constructor, \ - ".constructor", 0) \ -SECTION_FUNCTION (mod_init_section, \ - in_mod_init, \ - ".mod_init_func", 0) \ -SECTION_FUNCTION (mod_term_section, \ - in_mod_term, \ - ".mod_term_func", 0) \ -SECTION_FUNCTION (destructor_section, \ - in_destructor, \ - ".destructor", 0) \ -SECTION_FUNCTION (objc_class_section, \ - in_objc_class, \ - ".objc_class", 1) \ -SECTION_FUNCTION (objc_meta_class_section, \ - in_objc_meta_class, \ - ".objc_meta_class", 1) \ -SECTION_FUNCTION (objc_category_section, \ - in_objc_category, \ - ".objc_category", 1) \ -SECTION_FUNCTION (objc_class_vars_section, \ - in_objc_class_vars, \ - ".objc_class_vars", 1) \ -SECTION_FUNCTION (objc_instance_vars_section, \ - in_objc_instance_vars, \ - ".objc_instance_vars", 1) \ -SECTION_FUNCTION (objc_cls_meth_section, \ - in_objc_cls_meth, \ - ".objc_cls_meth", 1) \ -SECTION_FUNCTION (objc_inst_meth_section, \ - in_objc_inst_meth, \ - ".objc_inst_meth", 1) \ -SECTION_FUNCTION (objc_cat_cls_meth_section, \ - in_objc_cat_cls_meth, \ - ".objc_cat_cls_meth", 1) \ -SECTION_FUNCTION (objc_cat_inst_meth_section, \ - in_objc_cat_inst_meth, \ - ".objc_cat_inst_meth", 1) \ -SECTION_FUNCTION (objc_selector_refs_section, \ - in_objc_selector_refs, \ - ".objc_message_refs", 1) \ -SECTION_FUNCTION (objc_selector_fixup_section, \ - in_objc_selector_fixup, \ - ".section __OBJC, __sel_fixup, regular, no_dead_strip", 1) \ -SECTION_FUNCTION (objc_symbols_section, \ - in_objc_symbols, \ - ".objc_symbols", 1) \ -SECTION_FUNCTION (objc_module_info_section, \ - in_objc_module_info, \ - ".objc_module_info", 1) \ -SECTION_FUNCTION (objc_protocol_section, \ - in_objc_protocol, \ - ".objc_protocol", 1) \ -SECTION_FUNCTION (objc_string_object_section, \ - in_objc_string_object, \ - ".objc_string_object", 1) \ -SECTION_FUNCTION (objc_constant_string_object_section, \ - in_objc_constant_string_object, \ - ".section __OBJC, __cstring_object, regular, " \ - "no_dead_strip", 1) \ -/* Fix-and-Continue image marker. */ \ -SECTION_FUNCTION (objc_image_info_section, \ - in_objc_image_info, \ - ".section __OBJC, __image_info, regular, " \ - "no_dead_strip", 1) \ -SECTION_FUNCTION (objc_class_names_section, \ - in_objc_class_names, \ - ".objc_class_names", 1) \ -SECTION_FUNCTION (objc_meth_var_names_section, \ - in_objc_meth_var_names, \ - ".objc_meth_var_names", 1) \ -SECTION_FUNCTION (objc_meth_var_types_section, \ - in_objc_meth_var_types, \ - ".objc_meth_var_types", 1) \ -SECTION_FUNCTION (objc_cls_refs_section, \ - in_objc_cls_refs, \ - ".objc_cls_refs", 1) \ -\ -SECTION_FUNCTION (machopic_lazy_symbol_ptr_section, \ - in_machopic_lazy_symbol_ptr, \ - ".lazy_symbol_pointer", 0) \ -SECTION_FUNCTION (machopic_nl_symbol_ptr_section, \ - in_machopic_nl_symbol_ptr, \ - ".non_lazy_symbol_pointer", 0) \ -SECTION_FUNCTION (machopic_symbol_stub_section, \ - in_machopic_symbol_stub, \ - ".symbol_stub", 0) \ -SECTION_FUNCTION (machopic_symbol_stub1_section, \ - in_machopic_symbol_stub1, \ - ".section __TEXT,__symbol_stub1,symbol_stubs," \ - "pure_instructions,16", 0) \ -SECTION_FUNCTION (machopic_picsymbol_stub_section, \ - in_machopic_picsymbol_stub, \ - ".picsymbol_stub", 0) \ -SECTION_FUNCTION (machopic_picsymbol_stub1_section, \ - in_machopic_picsymbol_stub1, \ - ".section __TEXT,__picsymbolstub1,symbol_stubs," \ - "pure_instructions,32", 0) \ -SECTION_FUNCTION (darwin_exception_section, \ - in_darwin_exception, \ - ".section __DATA,__gcc_except_tab", 0) \ -SECTION_FUNCTION (darwin_eh_frame_section, \ - in_darwin_eh_frame, \ - ".section " EH_FRAME_SECTION_NAME ",__eh_frame" \ - EH_FRAME_SECTION_ATTR, 0) \ -\ -static void \ -objc_section_init (void) \ -{ \ - static int been_here = 0; \ - \ - if (been_here == 0) \ - { \ - been_here = 1; \ - /* written, cold -> hot */ \ - objc_cat_cls_meth_section (); \ - objc_cat_inst_meth_section (); \ - objc_string_object_section (); \ - objc_constant_string_object_section (); \ - objc_selector_refs_section (); \ - objc_selector_fixup_section (); \ - objc_cls_refs_section (); \ - objc_class_section (); \ - objc_meta_class_section (); \ - /* shared, hot -> cold */ \ - objc_cls_meth_section (); \ - objc_inst_meth_section (); \ - objc_protocol_section (); \ - objc_class_names_section (); \ - objc_meth_var_types_section (); \ - objc_meth_var_names_section (); \ - objc_category_section (); \ - objc_class_vars_section (); \ - objc_instance_vars_section (); \ - objc_module_info_section (); \ - objc_symbols_section (); \ - } \ -} - -#define READONLY_DATA_SECTION const_section +/* Declare the section variables. */ +#define DEF_SECTION(NAME, FLAGS, DIRECTIVE, OBJC) extern section *NAME; +#include "darwin-sections.def" +#undef DEF_SECTION #undef TARGET_ASM_SELECT_SECTION #define TARGET_ASM_SELECT_SECTION machopic_select_section @@ -986,10 +763,6 @@ enum machopic_addr_class { } \ } while (0) -#define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section - -#define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section - #define EH_FRAME_SECTION_NAME "__TEXT" #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support" @@ -1020,6 +793,7 @@ enum machopic_addr_class { #define TARGET_TERMINATE_DW2_EH_FRAME_INFO false +#define TARGET_ASM_INIT_SECTIONS darwin_init_sections #undef TARGET_ASM_NAMED_SECTION #define TARGET_ASM_NAMED_SECTION darwin_asm_named_section diff --git a/gcc/config/frv/frv-protos.h b/gcc/config/frv/frv-protos.h index b176ddf..91f2033 100644 --- a/gcc/config/frv/frv-protos.h +++ b/gcc/config/frv/frv-protos.h @@ -128,11 +128,6 @@ extern int frv_acc_group (rtx); extern int frv_adjust_field_align (tree, int); #endif -extern void fixup_section (void); -extern void sdata_section (void); -extern void sbss_section (void); -extern void data_section (void); - #ifdef RTX_CODE extern int integer_register_operand (rtx, enum machine_mode); extern int frv_load_operand (rtx, enum machine_mode); diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 4df467a..82b7cbf 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -9542,7 +9542,7 @@ frv_rtx_costs (rtx x, static void frv_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - ctors_section (); + switch_to_section (ctors_section); assemble_align (POINTER_SIZE); if (TARGET_FDPIC) { @@ -9557,7 +9557,7 @@ frv_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) static void frv_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - dtors_section (); + switch_to_section (dtors_section); assemble_align (POINTER_SIZE); if (TARGET_FDPIC) { diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h index d5586c0..f330f3c 100644 --- a/gcc/config/frv/frv.h +++ b/gcc/config/frv/frv.h @@ -2272,43 +2272,6 @@ do { \ program so they can be changed program startup time if the program is loaded at a different address than linked for. */ #define FIXUP_SECTION_ASM_OP "\t.section .rofixup,\"a\"" - -/* A list of names for sections other than the standard two, which are - `in_text' and `in_data'. You need not define this macro - on a system with no other sections (that GCC needs to use). */ -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_sdata, in_const, in_fixup - -/* One or more functions to be defined in "varasm.c". These - functions should do jobs analogous to those of `text_section' and - `data_section', for your additional sections. Do not define this - macro if you do not define `EXTRA_SECTIONS'. */ -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - SDATA_SECTION_FUNCTION \ - FIXUP_SECTION_FUNCTION - -#define SDATA_SECTION_FUNCTION \ -void \ -sdata_section (void) \ -{ \ - if (in_section != in_sdata) \ - { \ - fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \ - in_section = in_sdata; \ - } \ -} - -#define FIXUP_SECTION_FUNCTION \ -void \ -fixup_section (void) \ -{ \ - if (in_section != in_fixup) \ - { \ - fprintf (asm_out_file, "%s\n", FIXUP_SECTION_ASM_OP); \ - in_section = in_fixup; \ - } \ -} /* Position Independent Code. */ @@ -2394,9 +2357,9 @@ extern int size_directive_output; #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGN) \ do { \ if ((SIZE) > 0 && (SIZE) <= g_switch_value) \ - named_section (0, ".sbss", 0); \ + switch_to_section (get_named_section (NULL, ".sbss", 0)); \ else \ - bss_section (); \ + switch_to_section (bss_section); \ ASM_OUTPUT_ALIGN (STREAM, floor_log2 ((ALIGN) / BITS_PER_UNIT)); \ ASM_DECLARE_OBJECT_NAME (STREAM, NAME, DECL); \ ASM_OUTPUT_SKIP (STREAM, (SIZE) ? (SIZE) : 1); \ @@ -2652,8 +2615,8 @@ fprintf (STREAM, "\t.word .L%d\n", VALUE) #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \ do { \ if (flag_pic) \ - function_section (current_function_decl); \ - (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM); \ + switch_to_section (function_section (current_function_decl)); \ + (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM); \ } while (0) diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index 4005f1d..bb02b7b 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -108,53 +108,14 @@ Boston, MA 02110-1301, USA. */ union tree_node; #define TREE union tree_node * -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_drectve - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - DRECTVE_SECTION_FUNCTION \ - SWITCH_TO_SECTION_FUNCTION - -#define DRECTVE_SECTION_FUNCTION \ -void \ -drectve_section (void) \ -{ \ - if (in_section != in_drectve) \ - { \ - fprintf (asm_out_file, "%s\n", "\t.section .drectve\n"); \ - in_section = in_drectve; \ - } \ -} -void drectve_section (void); +#define drectve_section() \ + (fprintf (asm_out_file, "\t.section .drectve\n"), \ + in_section = NULL) /* Older versions of gas don't handle 'r' as data. Explicitly set data flag with 'd'. */ #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\"" -/* Switch to SECTION (an `enum in_section'). - - ??? This facility should be provided by GCC proper. - The problem is that we want to temporarily switch sections in - ASM_DECLARE_OBJECT_NAME and then switch back to the original section - afterwards. */ -#define SWITCH_TO_SECTION_FUNCTION \ -void switch_to_section (enum in_section, tree); \ -void \ -switch_to_section (enum in_section section, tree decl) \ -{ \ - switch (section) \ - { \ - case in_text: text_section (); break; \ - case in_unlikely_executed_text: unlikely_text_section (); break; \ - case in_data: data_section (); break; \ - case in_readonly_data: readonly_data_section (); break; \ - case in_named: named_section (decl, NULL, 0); break; \ - case in_drectve: drectve_section (); break; \ - default: abort (); break; \ - } \ -} - /* Don't allow flag_pic to propagate since gas may produce invalid code otherwise. */ diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index 8997233..b42ed3c 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -110,7 +110,7 @@ Boston, MA 02110-1301, USA. */ #define ASM_OUTPUT_ALIGN(FILE,LOG) \ do { if ((LOG) != 0) \ { \ - if (in_text_section ()) \ + if (in_section == text_section) \ fprintf (FILE, "\t%s %d,0x90\n", ALIGN_ASM_OP, (LOG)); \ else \ fprintf (FILE, "\t%s %d\n", ALIGN_ASM_OP, (LOG)); \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 476b47f..079ead8 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -956,9 +956,9 @@ static void init_ext_80387_constants (void); static bool ix86_in_large_data_p (tree) ATTRIBUTE_UNUSED; static void ix86_encode_section_info (tree, rtx, int) ATTRIBUTE_UNUSED; static void x86_64_elf_unique_section (tree decl, int reloc) ATTRIBUTE_UNUSED; -static void x86_64_elf_select_section (tree decl, int reloc, - unsigned HOST_WIDE_INT align) - ATTRIBUTE_UNUSED; +static section *x86_64_elf_select_section (tree decl, int reloc, + unsigned HOST_WIDE_INT align) + ATTRIBUTE_UNUSED; /* Initialize the GCC target structure. */ #undef TARGET_ATTRIBUTE_TABLE @@ -1695,9 +1695,9 @@ override_options (void) RELOC indicates whether forming the initial value of DECL requires link-time relocations. */ -static void +static section * x86_64_elf_select_section (tree decl, int reloc, - unsigned HOST_WIDE_INT align) + unsigned HOST_WIDE_INT align) { if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) && ix86_in_large_data_p (decl)) @@ -1741,12 +1741,9 @@ x86_64_elf_select_section (tree decl, int reloc, break; } if (sname) - { - named_section (decl, sname, reloc); - return; - } + return get_named_section (decl, sname, reloc); } - default_elf_select_section (decl, reloc, align); + return default_elf_select_section (decl, reloc, align); } /* Build up a unique section name, expressed as a @@ -1846,9 +1843,9 @@ x86_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, { if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) && size > (unsigned int)ix86_section_threshold) - named_section (decl, ".lbss", 0); + switch_to_section (get_named_section (decl, ".lbss", 0)); else - bss_section (); + switch_to_section (bss_section); ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT)); #ifdef ASM_DECLARE_OBJECT_NAME last_assemble_variable_decl = decl; @@ -4389,7 +4386,7 @@ ix86_file_end (void) DECL_ONE_ONLY (decl) = 1; (*targetm.asm_out.unique_section) (decl, 0); - named_section (decl, NULL, 0); + switch_to_section (get_named_section (decl, NULL, 0)); (*targetm.asm_out.globalize_label) (asm_out_file, name); fputs ("\t.hidden\t", asm_out_file); @@ -4399,7 +4396,7 @@ ix86_file_end (void) } else { - text_section (); + switch_to_section (text_section); ASM_OUTPUT_LABEL (asm_out_file, name); } @@ -16582,9 +16579,9 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub) sprintf (lazy_ptr_name, "L%d$lz", label); if (MACHOPIC_PURE) - machopic_picsymbol_stub_section (); + switch_to_section (machopic_picsymbol_stub_section); else - machopic_symbol_stub_section (); + switch_to_section (machopic_symbol_stub_section); fprintf (file, "%s:\n", stub); fprintf (file, "\t.indirect_symbol %s\n", symbol_name); @@ -16610,7 +16607,7 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub) fprintf (file, "\tjmp dyld_stub_binding_helper\n"); - machopic_lazy_symbol_ptr_section (); + switch_to_section (machopic_lazy_symbol_ptr_section); fprintf (file, "%s:\n", lazy_ptr_name); fprintf (file, "\t.indirect_symbol %s\n", symbol_name); fprintf (file, "\t.long %s\n", binder_name); @@ -18102,8 +18099,7 @@ void ix86_emit_i387_log1p (rtx op0, rtx op1) emit_label (label2); } -/* Solaris named-section hook. Parameters are as for - named_section_real. */ +/* Solaris implementation of TARGET_ASM_NAMED_SECTION. */ static void i386_solaris_elf_named_section (const char *name, unsigned int flags, diff --git a/gcc/config/i386/nwld.c b/gcc/config/i386/nwld.c index 962432e..4688ca0 100644 --- a/gcc/config/i386/nwld.c +++ b/gcc/config/i386/nwld.c @@ -48,7 +48,7 @@ nwld_named_section_asm_out_constructor (rtx symbol, int priority) MAX_INIT_PRIORITY - priority); #endif - named_section_flags (section, 0); + switch_to_section (get_section (section, 0, NULL)); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } @@ -68,7 +68,7 @@ nwld_named_section_asm_out_destructor (rtx symbol, int priority) MAX_INIT_PRIORITY - priority); #endif - named_section_flags (section, 0); + switch_to_section (get_section (section, 0, NULL)); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h index 6de20c8..b05cdab 100644 --- a/gcc/config/ia64/ia64-protos.h +++ b/gcc/config/ia64/ia64-protos.h @@ -102,14 +102,6 @@ extern int ia64_dbx_register_number (int); extern rtx ia64_return_addr_rtx (HOST_WIDE_INT, rtx); extern void ia64_split_return_addr_rtx (rtx); -#ifdef SDATA_SECTION_ASM_OP -extern void sdata_section (void); -#endif - -#ifdef SBSS_SECTION_ASM_OP -extern void sbss_section (void); -#endif - #ifdef ARGS_SIZE_RTX /* expr.h defines ARGS_SIZE_RTX and `enum direction'. */ extern enum direction ia64_hpux_function_arg_padding (enum machine_mode, tree); diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 7b9389b..2da3383 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -229,16 +229,16 @@ static void ia64_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); static void ia64_file_start (void); -static void ia64_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); +static section *ia64_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); static void ia64_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED; -static void ia64_rwreloc_select_section (tree, int, unsigned HOST_WIDE_INT) +static section *ia64_rwreloc_select_section (tree, int, unsigned HOST_WIDE_INT) ATTRIBUTE_UNUSED; static void ia64_rwreloc_unique_section (tree, int) ATTRIBUTE_UNUSED; -static void ia64_rwreloc_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT) +static section *ia64_rwreloc_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT) ATTRIBUTE_UNUSED; static unsigned int ia64_section_type_flags (tree, const char *, int); static void ia64_hpux_add_extern_decl (tree decl) @@ -8507,27 +8507,27 @@ ia64_sysv4_init_libfuncs (void) glibc doesn't have them. */ } -/* Switch to the section to which we should output X. The only thing - special we do here is to honor small data. */ +/* Return the section to use for X. The only special thing we do here + is to honor small data. */ -static void +static section * ia64_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) { if (GET_MODE_SIZE (mode) > 0 && GET_MODE_SIZE (mode) <= ia64_section_threshold) - sdata_section (); + return sdata_section; else - default_elf_select_rtx_section (mode, x, align); + return default_elf_select_rtx_section (mode, x, align); } /* It is illegal to have relocations in shared segments on AIX and HPUX. Pretend flag_pic is always set. */ -static void +static section * ia64_rwreloc_select_section (tree exp, int reloc, unsigned HOST_WIDE_INT align) { - default_elf_select_section_1 (exp, reloc, align, true); + return default_elf_select_section_1 (exp, reloc, align, true); } static void @@ -8536,14 +8536,16 @@ ia64_rwreloc_unique_section (tree decl, int reloc) default_unique_section_1 (decl, reloc, true); } -static void +static section * ia64_rwreloc_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) { + section *sect; int save_pic = flag_pic; flag_pic = 1; - ia64_select_rtx_section (mode, x, align); + sect = ia64_select_rtx_section (mode, x, align); flag_pic = save_pic; + return sect; } #ifndef TARGET_RWRELOC diff --git a/gcc/config/ia64/sysv4.h b/gcc/config/ia64/sysv4.h index 69c2424..bc85108 100644 --- a/gcc/config/ia64/sysv4.h +++ b/gcc/config/ia64/sysv4.h @@ -46,9 +46,9 @@ extern int size_directive_output; #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \ do { \ if ((DECL) && sdata_symbolic_operand (XEXP (DECL_RTL (DECL), 0), Pmode)) \ - sbss_section (); \ + switch_to_section (sbss_section); \ else \ - bss_section (); \ + switch_to_section (bss_section); \ ASM_OUTPUT_ALIGN (FILE, floor_log2 ((ALIGN) / BITS_PER_UNIT)); \ ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \ ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1); \ @@ -124,36 +124,5 @@ do { \ #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION ia64_select_rtx_section -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_sdata, in_sbss - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - SDATA_SECTION_FUNCTION \ - SBSS_SECTION_FUNCTION - #define SDATA_SECTION_ASM_OP "\t.sdata" - -#define SDATA_SECTION_FUNCTION \ -void \ -sdata_section (void) \ -{ \ - if (in_section != in_sdata) \ - { \ - fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \ - in_section = in_sdata; \ - } \ -} - #define SBSS_SECTION_ASM_OP "\t.sbss" - -#define SBSS_SECTION_FUNCTION \ -void \ -sbss_section (void) \ -{ \ - if (in_section != in_sbss) \ - { \ - fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP); \ - in_section = in_sbss; \ - } \ -} diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 2adf50a..dd42fe9 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -154,7 +154,8 @@ static enum machine_mode gpr_mode; /* Initialize the GCC target structure. */ static struct machine_function* iq2000_init_machine_status (void); static bool iq2000_handle_option (size_t, const char *, int); -static void iq2000_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT); +static section *iq2000_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); static void iq2000_init_builtins (void); static rtx iq2000_expand_builtin (tree, rtx, rtx, enum machine_mode, int); static bool iq2000_return_in_memory (tree, tree); @@ -163,7 +164,7 @@ static void iq2000_setup_incoming_varargs (CUMULATIVE_ARGS *, int); static bool iq2000_rtx_costs (rtx, int, int, int *); static int iq2000_address_cost (rtx); -static void iq2000_select_section (tree, int, unsigned HOST_WIDE_INT); +static section *iq2000_select_section (tree, int, unsigned HOST_WIDE_INT); static bool iq2000_return_in_memory (tree, tree); static bool iq2000_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, tree, bool); @@ -2146,15 +2147,13 @@ symbolic_expression_p (rtx x) /* Choose the section to use for the constant rtx expression X that has mode MODE. */ -static void +static section * iq2000_select_rtx_section (enum machine_mode mode, rtx x ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align) { /* For embedded applications, always put constants in read-only data, in order to reduce RAM usage. */ - /* For embedded applications, always put constants in read-only data, - in order to reduce RAM usage. */ - mergeable_constant_section (mode, align, 0); + return mergeable_constant_section (mode, align, 0); } /* Choose the section to use for DECL. RELOC is true if its value contains @@ -2164,7 +2163,7 @@ iq2000_select_rtx_section (enum machine_mode mode, rtx x ATTRIBUTE_UNUSED, ENCODE_SECTION_INFO in iq2000.h so that references to these symbols are done correctly. */ -static void +static section * iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { @@ -2179,9 +2178,9 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED, || TREE_CONSTANT (DECL_INITIAL (decl)))) /* Deal with calls from output_constant_def_contents. */ || TREE_CODE (decl) != VAR_DECL) - readonly_data_section (); + return readonly_data_section; else - data_section (); + return data_section; } else { @@ -2194,9 +2193,9 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED, || TREE_CONSTANT (DECL_INITIAL (decl)))) /* Deal with calls from output_constant_def_contents. */ || TREE_CODE (decl) != VAR_DECL) - readonly_data_section (); + return readonly_data_section; else - data_section (); + return data_section; } } /* Return register to use for a function return value with VALTYPE for function diff --git a/gcc/config/iq2000/iq2000.h b/gcc/config/iq2000/iq2000.h index f60b627..45c1c34 100644 --- a/gcc/config/iq2000/iq2000.h +++ b/gcc/config/iq2000/iq2000.h @@ -835,11 +835,6 @@ enum processor_type /* Recast the cpu class to be the cpu attribute. */ #define iq2000_cpu_attr ((enum attr_cpu) iq2000_tune) -/* Functions to change what output section we are using. */ -extern void rdata_section (void); -extern void sdata_section (void); -extern void sbss_section (void); - #define BITMASK_UPPER16 ((unsigned long) 0xffff << 16) /* 0xffff0000 */ #define BITMASK_LOWER16 ((unsigned long) 0xffff) /* 0x0000ffff */ diff --git a/gcc/config/m32r/m32r-protos.h b/gcc/config/m32r/m32r-protos.h index a847930..ee03a1e 100644 --- a/gcc/config/m32r/m32r-protos.h +++ b/gcc/config/m32r/m32r-protos.h @@ -23,8 +23,6 @@ complications. */ #define Mmode enum machine_mode -extern void sbss_section (void); -extern void sdata_section (void); extern void m32r_init (void); extern void m32r_init_expanders (void); extern unsigned m32r_compute_frame_size (int); diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index 7f82a1c..785896a 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -1529,9 +1529,9 @@ extern char m32r_punct_chars[256]; { \ if (! TARGET_SDATA_NONE \ && (SIZE) > 0 && (SIZE) <= g_switch_value) \ - named_section (0, ".sbss", 0); \ + switch_to_section (get_named_section (NULL, ".sbss", 0)); \ else \ - bss_section (); \ + switch_to_section (bss_section); \ ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \ last_assemble_variable_decl = DECL; \ ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL); \ diff --git a/gcc/config/mcore/mcore-elf.h b/gcc/config/mcore/mcore-elf.h index 75c15d8..4ec6d58 100644 --- a/gcc/config/mcore/mcore-elf.h +++ b/gcc/config/mcore/mcore-elf.h @@ -32,34 +32,13 @@ Boston, MA 02110-1301, USA. */ #undef PREFERRED_DEBUGGING_TYPE #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG -#define EXPORTS_SECTION_ASM_OP "\t.section .exports" - -#define SUBTARGET_EXTRA_SECTIONS in_exports - -#define SUBTARGET_EXTRA_SECTION_FUNCTIONS \ - EXPORT_SECTION_FUNCTION - -#define EXPORT_SECTION_FUNCTION \ -void \ -exports_section () \ -{ \ - if (in_section != in_exports) \ - { \ - fprintf (asm_out_file, "%s\n", EXPORTS_SECTION_ASM_OP); \ - in_section = in_exports; \ - } \ -} - -#define SUBTARGET_SWITCH_SECTIONS \ - case in_exports: exports_section (); break; - - #define MCORE_EXPORT_NAME(STREAM, NAME) \ do \ { \ - exports_section (); \ + fprintf (STREAM, "\t.section .exports\n"); \ fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \ (* targetm.strip_name_encoding) (NAME)); \ + in_section = NULL; \ } \ while (0); @@ -73,7 +52,7 @@ exports_section () \ if (mcore_dllexport_name_p (NAME)) \ { \ MCORE_EXPORT_NAME (FILE, NAME); \ - function_section (DECL); \ + switch_to_section (function_section (DECL)); \ } \ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ @@ -89,9 +68,9 @@ exports_section () \ HOST_WIDE_INT size; \ if (mcore_dllexport_name_p (NAME)) \ { \ - enum in_section save_section = in_section; \ + section *save_section = in_section; \ MCORE_EXPORT_NAME (FILE, NAME); \ - switch_to_section (save_section, (DECL)); \ + switch_to_section (save_section); \ } \ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ size_directive_output = 0; \ diff --git a/gcc/config/mcore/mcore-pe.h b/gcc/config/mcore/mcore-pe.h index f186805..5a3aba1 100644 --- a/gcc/config/mcore/mcore-pe.h +++ b/gcc/config/mcore/mcore-pe.h @@ -41,37 +41,15 @@ Boston, MA 02110-1301, USA. */ /* Computed in toplev.c. */ #undef PREFERRED_DEBUGGING_TYPE -/* Lay out additional 'sections' where we place things like code - and readonly data. This gets them out of default places. */ - -#define SUBTARGET_SWITCH_SECTIONS \ - case in_drectve: drectve_section (); break; - -#define DRECTVE_SECTION_ASM_OP "\t.section .drectve" #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata" -#define SUBTARGET_EXTRA_SECTIONS in_drectve - -#define SUBTARGET_EXTRA_SECTION_FUNCTIONS \ - DRECTVE_SECTION_FUNCTION - -#define DRECTVE_SECTION_FUNCTION \ -void \ -drectve_section () \ -{ \ - if (in_section != in_drectve) \ - { \ - fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP); \ - in_section = in_drectve; \ - } \ -} - #define MCORE_EXPORT_NAME(STREAM, NAME) \ do \ { \ - drectve_section (); \ + fprintf (STREAM, "\t.section .drectve\n"); \ fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \ (* targetm.strip_name_encoding) (NAME)); \ + in_section = NULL; \ } \ while (0); @@ -82,9 +60,9 @@ drectve_section () \ { \ if (mcore_dllexport_name_p (NAME)) \ { \ - enum in_section save_section = in_section; \ + section *save_section = in_section; \ MCORE_EXPORT_NAME (STREAM, NAME); \ - switch_to_section (save_section, (DECL)); \ + switch_to_section (save_section); \ } \ ASM_OUTPUT_LABEL ((STREAM), (NAME)); \ } \ @@ -97,7 +75,7 @@ drectve_section () \ if (mcore_dllexport_name_p (NAME)) \ { \ MCORE_EXPORT_NAME (STREAM, NAME); \ - function_section (DECL); \ + switch_to_section (function_section (DECL)); \ } \ ASM_OUTPUT_LABEL ((STREAM), (NAME)); \ } \ diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index d9960dc..fd1ba70 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -857,36 +857,6 @@ extern const enum reg_class reg_class_from_letter[]; #define TEXT_SECTION_ASM_OP "\t.text" #define DATA_SECTION_ASM_OP "\t.data" -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - SUBTARGET_EXTRA_SECTION_FUNCTIONS \ - SWITCH_SECTION_FUNCTION - -/* Switch to SECTION (an `enum in_section'). - - ??? This facility should be provided by GCC proper. - The problem is that we want to temporarily switch sections in - ASM_DECLARE_OBJECT_NAME and then switch back to the original section - afterwards. */ -#define SWITCH_SECTION_FUNCTION \ -static void switch_to_section (enum in_section, tree); \ -static void \ -switch_to_section (enum in_section section, tree decl) \ -{ \ - switch (section) \ - { \ - case in_text: text_section (); break; \ - case in_unlikely_executed_text: unlikely_text_section (); break; \ - case in_data: data_section (); break; \ - case in_named: named_section (decl, NULL, 0); break; \ - SUBTARGET_SWITCH_SECTIONS \ - default: gcc_unreachable (); \ - } \ -} - /* Switch into a generic section. */ #undef TARGET_ASM_NAMED_SECTION #define TARGET_ASM_NAMED_SECTION mcore_asm_named_section diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 733b9c6..3e7d0f0 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -328,9 +328,9 @@ static void mips_restore_reg (rtx, rtx); static void mips_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); static int symbolic_expression_p (rtx); -static void mips_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); -static void mips_function_rodata_section (tree); +static section *mips_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); +static section *mips_function_rodata_section (tree); static bool mips_in_small_data_p (tree); static int mips_fpr_return_fields (tree, tree *); static bool mips_return_in_msb (tree); @@ -5762,7 +5762,7 @@ mips_file_start (void) default: gcc_unreachable (); } - /* Note - we use fprintf directly rather than called named_section() + /* Note - we use fprintf directly rather than calling switch_to_section because in this way we can avoid creating an allocated section. We do not want this section to take up any space in the running executable. */ @@ -5804,9 +5804,9 @@ mips_output_aligned_bss (FILE *stream, tree decl, const char *name, extern tree last_assemble_variable_decl; if (mips_in_small_data_p (decl)) - named_section (0, ".sbss", 0); + switch_to_section (get_named_section (NULL, ".sbss", 0)); else - bss_section (); + switch_to_section (bss_section); ASM_OUTPUT_ALIGN (stream, floor_log2 (align / BITS_PER_UNIT)); last_assemble_variable_decl = decl; ASM_DECLARE_OBJECT_NAME (stream, name, decl); @@ -5875,7 +5875,7 @@ mips_output_aligned_decl_common (FILE *stream, tree decl, const char *name, if (TREE_PUBLIC (decl) && DECL_NAME (decl)) targetm.asm_out.globalize_label (stream, name); - readonly_data_section (); + switch_to_section (readonly_data_section); ASM_OUTPUT_ALIGN (stream, floor_log2 (align / BITS_PER_UNIT)); mips_declare_object (stream, name, "", ":\n\t.space\t" HOST_WIDE_INT_PRINT_UNSIGNED "\n", @@ -7110,7 +7110,7 @@ symbolic_expression_p (rtx x) /* Choose the section to use for the constant rtx expression X that has mode MODE. */ -static void +static section * mips_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) { @@ -7119,13 +7119,13 @@ mips_select_rtx_section (enum machine_mode mode, rtx x, /* In mips16 mode, the constant table always goes in the same section as the function, so that constants can be loaded using PC relative addressing. */ - function_section (current_function_decl); + return function_section (current_function_decl); } else if (TARGET_EMBEDDED_DATA) { /* For embedded applications, always put constants in read-only data, in order to reduce RAM usage. */ - mergeable_constant_section (mode, align, 0); + return mergeable_constant_section (mode, align, 0); } else { @@ -7135,11 +7135,11 @@ mips_select_rtx_section (enum machine_mode mode, rtx x, if (GET_MODE_SIZE (mode) <= (unsigned) mips_section_threshold && mips_section_threshold > 0) - named_section (0, ".sdata", 0); + return get_named_section (NULL, ".sdata", 0); else if (flag_pic && symbolic_expression_p (x)) - named_section (0, ".data.rel.ro", 3); + return get_named_section (NULL, ".data.rel.ro", 3); else - mergeable_constant_section (mode, align, 0); + return mergeable_constant_section (mode, align, 0); } } @@ -7151,32 +7151,30 @@ mips_select_rtx_section (enum machine_mode mode, rtx x, cases by selecting a normal data section instead of a read-only one. The logic apes that in default_function_rodata_section. */ -static void +static section * mips_function_rodata_section (tree decl) { if (!TARGET_ABICALLS || TARGET_GPWORD) - default_function_rodata_section (decl); - else if (decl && DECL_SECTION_NAME (decl)) + return default_function_rodata_section (decl); + + if (decl && DECL_SECTION_NAME (decl)) { const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0) { char *rname = ASTRDUP (name); rname[14] = 'd'; - named_section_real (rname, SECTION_LINKONCE | SECTION_WRITE, decl); + return get_section (rname, SECTION_LINKONCE | SECTION_WRITE, decl); } else if (flag_function_sections && flag_data_sections && strncmp (name, ".text.", 6) == 0) { char *rname = ASTRDUP (name); memcpy (rname + 1, "data", 4); - named_section_flags (rname, SECTION_WRITE); + return get_section (rname, SECTION_WRITE, decl); } - else - data_section (); } - else - data_section (); + return data_section; } /* Implement TARGET_IN_SMALL_DATA_P. Return true if it would be safe to @@ -7807,7 +7805,7 @@ build_mips16_function_stub (FILE *file) fprintf (file, ")\n"); fprintf (file, "\t.set\tnomips16\n"); - function_section (stubdecl); + switch_to_section (function_section (stubdecl)); ASM_OUTPUT_ALIGN (file, floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT)); /* ??? If FUNCTION_NAME_ALREADY_DECLARED is defined, then we are @@ -7852,7 +7850,7 @@ build_mips16_function_stub (FILE *file) fprintf (file, "\t.set\tmips16\n"); - function_section (current_function_decl); + switch_to_section (function_section (current_function_decl)); } /* We keep a list of functions for which we have already built stubs diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 2d11a88..7a1837f 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2698,7 +2698,7 @@ do { \ { \ const char *p = STRING; \ int size = strlen (p) + 1; \ - readonly_data_section (); \ + switch_to_section (readonly_data_section); \ assemble_string (p, size); \ } @@ -2710,7 +2710,6 @@ do { \ /* Define the strings to put out for each section in the object file. */ #define TEXT_SECTION_ASM_OP "\t.text" /* instructions */ #define DATA_SECTION_ASM_OP "\t.data" /* large data */ -#define SDATA_SECTION_ASM_OP "\t.sdata" /* small data */ #undef READONLY_DATA_SECTION_ASM_OP #define READONLY_DATA_SECTION_ASM_OP "\t.rdata" /* read-only data */ diff --git a/gcc/config/mips/vxworks.h b/gcc/config/mips/vxworks.h index 53a9ae4..bf37901 100644 --- a/gcc/config/mips/vxworks.h +++ b/gcc/config/mips/vxworks.h @@ -17,15 +17,6 @@ along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_sdata, in_sbss - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \ - SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) - - #undef TARGET_VERSION #define TARGET_VERSION fprintf (stderr, " (MIPS, VxWorks syntax)"); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index fc2a5c8..b57ed7a 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -1182,7 +1182,7 @@ mmix_file_start (void) fputs ("! mmixal:= 8H LOC Data_Section\n", asm_out_file); /* Make sure each file starts with the text section. */ - text_section (); + switch_to_section (text_section); } /* TARGET_ASM_FILE_END. */ @@ -1191,7 +1191,7 @@ static void mmix_file_end (void) { /* Make sure each file ends with the data section. */ - data_section (); + switch_to_section (data_section); } /* ASM_OUTPUT_SOURCE_FILENAME. */ @@ -1350,7 +1350,7 @@ mmix_asm_output_aligned_local (FILE *stream, int size, int align) { - data_section (); + switch_to_section (data_section); ASM_OUTPUT_ALIGN (stream, exact_log2 (align/BITS_PER_UNIT)); assemble_name (stream, name); diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h index 0963844..510ac07 100644 --- a/gcc/config/pa/pa-protos.h +++ b/gcc/config/pa/pa-protos.h @@ -138,7 +138,6 @@ extern int zdepi_cint_p (unsigned HOST_WIDE_INT); extern void override_options (void); extern void output_ascii (FILE *, const char *, int); -extern const char * som_text_section_asm_op (void); extern HOST_WIDE_INT compute_frame_size (HOST_WIDE_INT, int *); extern int and_mask_p (unsigned HOST_WIDE_INT); extern int cint_ok_for_move (HOST_WIDE_INT); @@ -179,9 +178,3 @@ extern void pa_hpux_asm_output_external (FILE *, tree, const char *); extern const int magic_milli[]; extern int shadd_constant_p (int); - -/* Functions in varasm.c used by pa.c. */ -extern void som_readonly_data_section (void); -extern void som_one_only_readonly_data_section (void); -extern void som_one_only_data_section (void); -extern void forget_section (void); diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index c9bac91..ea2a9fa 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -107,7 +107,8 @@ static void pa_output_function_epilogue (FILE *, HOST_WIDE_INT); static int pa_adjust_cost (rtx, rtx, rtx, int); static int pa_adjust_priority (rtx, int); static int pa_issue_rate (void); -static void pa_select_section (tree, int, unsigned HOST_WIDE_INT) +static void pa_som_asm_init_sections (void) ATTRIBUTE_UNUSED; +static section *pa_select_section (tree, int, unsigned HOST_WIDE_INT) ATTRIBUTE_UNUSED; static void pa_encode_section_info (tree, rtx, int); static const char *pa_strip_name_encoding (const char *); @@ -155,6 +156,11 @@ static enum reg_class pa_secondary_reload (bool, rtx, enum reg_class, secondary_reload_info *); +/* The following extra sections are only used for SOM. */ +static GTY(()) section *som_readonly_data_section; +static GTY(()) section *som_one_only_readonly_data_section; +static GTY(()) section *som_one_only_data_section; + /* Save the operands last given to a compare for use when we generate a scc or bcc insn. */ rtx hppa_compare_op0, hppa_compare_op1; @@ -3928,7 +3934,7 @@ pa_output_function_epilogue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED) /* We done with this subspace except possibly for some additional debug information. Forget that we are in this subspace to ensure that the next function is output in its own subspace. */ - forget_section (); + in_section = NULL; } if (INSN_ADDRESSES_SET_P ()) @@ -4149,7 +4155,7 @@ output_deferred_profile_counters (void) if (VEC_empty (int, funcdef_nos)) return; - data_section (); + switch_to_section (data_section); align = MIN (BIGGEST_ALIGNMENT, LONG_TYPE_SIZE); ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT)); @@ -5299,7 +5305,7 @@ output_deferred_plabels (void) deferred plabels. */ if (n_deferred_plabels) { - data_section (); + switch_to_section (data_section); ASM_OUTPUT_ALIGN (asm_out_file, TARGET_64BIT ? 3 : 2); } @@ -7795,13 +7801,13 @@ pa_asm_output_mi_thunk (FILE *file, tree thunk_fndecl, HOST_WIDE_INT delta, if (TARGET_SOM && flag_pic && TREE_PUBLIC (function)) { - data_section (); + switch_to_section (data_section); output_asm_insn (".align 4", xoperands); ASM_OUTPUT_LABEL (file, label); output_asm_insn (".word P'%0", xoperands); } else if (TARGET_SOM && TARGET_GAS) - forget_section (); + in_section = NULL; current_thunk_number++; nbytes = ((nbytes + FUNCTION_BOUNDARY / BITS_PER_UNIT - 1) @@ -7977,7 +7983,7 @@ pa_asm_output_aligned_bss (FILE *stream, unsigned HOST_WIDE_INT size, unsigned int align) { - bss_section (); + switch_to_section (bss_section); fprintf (stream, "\t.align %u\n", align / BITS_PER_UNIT); #ifdef ASM_OUTPUT_TYPE_DIRECTIVE @@ -8017,7 +8023,7 @@ pa_asm_output_aligned_common (FILE *stream, align = max_common_align; } - bss_section (); + switch_to_section (bss_section); assemble_name (stream, name); fprintf (stream, "\t.comm "HOST_WIDE_INT_PRINT_UNSIGNED"\n", @@ -8037,7 +8043,7 @@ pa_asm_output_aligned_local (FILE *stream, unsigned HOST_WIDE_INT size, unsigned int align) { - bss_section (); + switch_to_section (bss_section); fprintf (stream, "\t.align %u\n", align / BITS_PER_UNIT); #ifdef LOCAL_ASM_OP @@ -9029,17 +9035,16 @@ pa_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode, } -/* Return a string to output before text in the current function. +/* A get_unnamed_section callback for switching to the text section. This function is only used with SOM. Because we don't support named subspaces, we can only create a new subspace or switch back to the default text subspace. */ -const char * -som_text_section_asm_op (void) -{ - if (!TARGET_SOM) - return ""; +static void +som_output_text_section_asm_op (const void *data ATTRIBUTE_UNUSED) +{ + gcc_assert (TARGET_SOM); if (TARGET_GAS) { if (cfun && !cfun->machine->in_nsubspa) @@ -9053,10 +9058,12 @@ som_text_section_asm_op (void) if (cfun->decl && DECL_ONE_ONLY (cfun->decl) && !DECL_WEAK (cfun->decl)) - return - "\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,SORT=24,COMDAT"; - - return "\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$"; + output_section_asm_op ("\t.SPACE $TEXT$\n" + "\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8," + "ACCESS=44,SORT=24,COMDAT"); + else + output_section_asm_op ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$"); + return; } else { @@ -9064,13 +9071,66 @@ som_text_section_asm_op (void) function has been completed. So, we are changing to the text section to output debugging information. Do this in the default text section. We need to forget that we are - in the text section so that the function text_section in - varasm.c will call us the next time around. */ - forget_section (); + in the text section so that varasm.c will call us when + text_section is selected again. */ + in_section = NULL; } } + output_section_asm_op ("\t.SPACE $TEXT$\n\t.SUBSPA $CODE$"); +} + +/* Implement TARGET_ASM_INITIALIZE_SECTIONS */ - return "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$"; +static void +pa_som_asm_init_sections (void) +{ + text_section + = get_unnamed_section (0, som_output_text_section_asm_op, NULL); + + /* SOM puts readonly data in the default $LIT$ subspace when PIC code + is not being generated. */ + som_readonly_data_section + = get_unnamed_section (0, output_section_asm_op, + "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$"); + + /* When secondary definitions are not supported, SOM makes readonly + data one-only by creating a new $LIT$ subspace in $TEXT$ with + the comdat flag. */ + som_one_only_readonly_data_section + = get_unnamed_section (0, output_section_asm_op, + "\t.SPACE $TEXT$\n" + "\t.NSUBSPA $LIT$,QUAD=0,ALIGN=8," + "ACCESS=0x2c,SORT=16,COMDAT"); + + + /* When secondary definitions are not supported, SOM makes data one-only + by creating a new $DATA$ subspace in $PRIVATE$ with the comdat flag. */ + som_one_only_data_section + = get_unnamed_section (SECTION_WRITE, output_section_asm_op, + "\t.SPACE $PRIVATE$\n" + "\t.NSUBSPA $DATA$,QUAD=1,ALIGN=8," + "ACCESS=31,SORT=24,COMDAT"); + + /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups + which reference data within the $TEXT$ space (for example constant + strings in the $LIT$ subspace). + + The assemblers (GAS and HP as) both have problems with handling + the difference of two symbols which is the other correct way to + reference constant data during PIC code generation. + + So, there's no way to reference constant data which is in the + $TEXT$ space during PIC generation. Instead place all constant + data into the $PRIVATE$ subspace (this reduces sharing, but it + works correctly). */ + readonly_data_section = flag_pic ? data_section : som_readonly_data_section; + + /* We must not have a reference to an external symbol defined in a + shared library in a readonly section, else the SOM linker will + complain. + + So, we force exception information into the data section. */ + exception_section = data_section; } /* On hpux10, the linker will give an error if we have a reference @@ -9078,7 +9138,7 @@ som_text_section_asm_op (void) library. Therefore, expressions that might require a reloc can not be placed in the read-only data section. */ -static void +static section * pa_select_section (tree exp, int reloc, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { @@ -9093,19 +9153,19 @@ pa_select_section (tree exp, int reloc, if (TARGET_SOM && DECL_ONE_ONLY (exp) && !DECL_WEAK (exp)) - som_one_only_readonly_data_section (); + return som_one_only_readonly_data_section; else - readonly_data_section (); + return readonly_data_section; } else if (CONSTANT_CLASS_P (exp) && !reloc) - readonly_data_section (); + return readonly_data_section; else if (TARGET_SOM && TREE_CODE (exp) == VAR_DECL && DECL_ONE_ONLY (exp) && !DECL_WEAK (exp)) - som_one_only_data_section (); + return som_one_only_data_section; else - data_section (); + return data_section; } static void diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 6fc265e..a98d1cd 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -1568,72 +1568,6 @@ do { \ ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \ && DECL_SECTION_NAME (DECL) != NULL_TREE) -/* The following extra sections and extra section functions are only used - for SOM, but they must be provided unconditionally because pa.c's calls - to the functions might not get optimized out when other object formats - are in use. */ - -#define EXTRA_SECTIONS \ - in_som_readonly_data, \ - in_som_one_only_readonly_data, \ - in_som_one_only_data - -#define EXTRA_SECTION_FUNCTIONS \ - SOM_READONLY_DATA_SECTION_FUNCTION \ - SOM_ONE_ONLY_READONLY_DATA_SECTION_FUNCTION \ - SOM_ONE_ONLY_DATA_SECTION_FUNCTION \ - FORGET_SECTION_FUNCTION - -/* SOM puts readonly data in the default $LIT$ subspace when PIC code - is not being generated. */ -#define SOM_READONLY_DATA_SECTION_FUNCTION \ -void \ -som_readonly_data_section (void) \ -{ \ - if (!TARGET_SOM) \ - return; \ - if (in_section != in_som_readonly_data) \ - { \ - in_section = in_som_readonly_data; \ - fputs ("\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n", asm_out_file); \ - } \ -} - -/* When secondary definitions are not supported, SOM makes readonly data one - only by creating a new $LIT$ subspace in $TEXT$ with the comdat flag. */ -#define SOM_ONE_ONLY_READONLY_DATA_SECTION_FUNCTION \ -void \ -som_one_only_readonly_data_section (void) \ -{ \ - if (!TARGET_SOM) \ - return; \ - in_section = in_som_one_only_readonly_data; \ - fputs ("\t.SPACE $TEXT$\n" \ - "\t.NSUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=16,COMDAT\n",\ - asm_out_file); \ -} - -/* When secondary definitions are not supported, SOM makes data one only by - creating a new $DATA$ subspace in $PRIVATE$ with the comdat flag. */ -#define SOM_ONE_ONLY_DATA_SECTION_FUNCTION \ -void \ -som_one_only_data_section (void) \ -{ \ - if (!TARGET_SOM) \ - return; \ - in_section = in_som_one_only_data; \ - fputs ("\t.SPACE $PRIVATE$\n" \ - "\t.NSUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=24,COMDAT\n", \ - asm_out_file); \ -} - -#define FORGET_SECTION_FUNCTION \ -void \ -forget_section (void) \ -{ \ - in_section = no_section; \ -} - /* Define this macro if references to a symbol must be treated differently depending on something about the variable or function named by the symbol (such as what section it is in). diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h index e397b9d..abeafbe 100644 --- a/gcc/config/pa/som.h +++ b/gcc/config/pa/som.h @@ -175,9 +175,7 @@ do { \ }} while (0) #define TARGET_ASM_FILE_START pa_som_file_start - -/* String to output before text. */ -#define TEXT_SECTION_ASM_OP som_text_section_asm_op () +#define TARGET_ASM_INIT_SECTIONS pa_som_asm_init_sections /* String to output before writable data. */ #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n" @@ -185,28 +183,6 @@ do { \ /* String to output before uninitialized data. */ #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n" -/* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups - which reference data within the $TEXT$ space (for example constant - strings in the $LIT$ subspace). - - The assemblers (GAS and HP as) both have problems with handling - the difference of two symbols which is the other correct way to - reference constant data during PIC code generation. - - So, there's no way to reference constant data which is in the - $TEXT$ space during PIC generation. Instead place all constant - data into the $PRIVATE$ subspace (this reduces sharing, but it - works correctly). */ -#define READONLY_DATA_SECTION \ - (flag_pic ? data_section : som_readonly_data_section) - -/* We must not have a reference to an external symbol defined in a - shared library in a readonly section, else the SOM linker will - complain. - - So, we force exception information into the data section. */ -#define TARGET_ASM_EXCEPTION_SECTION data_section - /* This is how to output a command to make the user-level label named NAME defined for reference from other files. We use assemble_name_raw instead of assemble_name since a symbol in diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index 65cb79d..dbde3d5 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -141,13 +141,6 @@ extern void rs6000_gen_section_name (char **, const char *, const char *); extern void output_function_profiler (FILE *, int); extern void output_profile_hook (int); extern int rs6000_trampoline_size (void); -extern void toc_section (void); -extern void sdata_section (void); -extern void sdata2_section (void); -extern void sbss_section (void); -extern void private_data_section (void); -extern void read_only_data_section (void); -extern void read_only_private_data_section (void); extern int get_TOC_alias_set (void); extern void rs6000_emit_prologue (void); extern void rs6000_emit_load_toc_table (int); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 3000753..52312a7 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -230,6 +230,12 @@ static enum { int toc_initialized; char toc_label_name[10]; +static GTY(()) section *read_only_data_section; +static GTY(()) section *private_data_section; +static GTY(()) section *read_only_private_data_section; +static GTY(()) section *sdata2_section; +static GTY(()) section *toc_section; + /* Control alignment for fields within structures. */ /* String from -malign-XXXXX. */ int rs6000_alignment_flags; @@ -605,20 +611,23 @@ static unsigned int rs6000_elf_section_type_flags (tree, const char *, int); static void rs6000_elf_asm_out_constructor (rtx, int); static void rs6000_elf_asm_out_destructor (rtx, int); static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED; -static void rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT); +static void rs6000_elf_asm_init_sections (void); +static section *rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT); static void rs6000_elf_unique_section (tree, int); -static void rs6000_elf_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); +static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); static void rs6000_elf_encode_section_info (tree, rtx, int) ATTRIBUTE_UNUSED; #endif #if TARGET_XCOFF static void rs6000_xcoff_asm_globalize_label (FILE *, const char *); +static void rs6000_xcoff_asm_init_sections (void); static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree); -static void rs6000_xcoff_select_section (tree, int, unsigned HOST_WIDE_INT); -static void rs6000_xcoff_unique_section (tree, int); -static void rs6000_xcoff_select_rtx_section (enum machine_mode, rtx, +static section *rs6000_xcoff_select_section (tree, int, unsigned HOST_WIDE_INT); +static void rs6000_xcoff_unique_section (tree, int); +static section *rs6000_xcoff_select_rtx_section + (enum machine_mode, rtx, unsigned HOST_WIDE_INT); static const char * rs6000_xcoff_strip_name_encoding (const char *); static unsigned int rs6000_xcoff_section_type_flags (tree, const char *, int); static void rs6000_xcoff_file_start (void); @@ -1903,8 +1912,8 @@ rs6000_file_start (void) if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2)) { - toc_section (); - text_section (); + switch_to_section (toc_section); + switch_to_section (text_section); } } @@ -10806,15 +10815,14 @@ rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p) /* Special handling for SI values. */ if (RELOCATABLE_NEEDS_FIXUP && size == 4 && aligned_p) { - extern int in_toc_section (void); static int recurse = 0; /* For -mrelocatable, we mark all addresses that need to be fixed up in the .fixup section. */ if (TARGET_RELOCATABLE - && !in_toc_section () - && !in_text_section () - && !in_unlikely_text_section () + && in_section != toc_section + && in_section != text_section + && unlikely_text_section_p (in_section) && !recurse && GET_CODE (x) != CONST_INT && GET_CODE (x) != CONST_DOUBLE @@ -17323,31 +17331,74 @@ rs6000_longcall_ref (rtx call_ref) #ifdef USING_ELFOS_H -/* A C statement or statements to switch to the appropriate section - for output of RTX in mode MODE. You can assume that RTX is some - kind of constant in RTL. The argument MODE is redundant except in - the case of a `const_int' rtx. Select the section by calling - `text_section' or one of the alternatives for other sections. +/* A get_unnamed_section callback, used for switching to toc_section. */ + +static void +rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED) +{ + if (DEFAULT_ABI == ABI_AIX + && TARGET_MINIMAL_TOC + && !TARGET_RELOCATABLE) + { + if (!toc_initialized) + { + toc_initialized = 1; + fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP); + (*targetm.asm_out.internal_label) (asm_out_file, "LCTOC", 0); + fprintf (asm_out_file, "\t.tc "); + ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); + ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); + fprintf (asm_out_file, "\n"); + + fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); + ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); + fprintf (asm_out_file, " = .+32768\n"); + } + else + fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); + } + else if (DEFAULT_ABI == ABI_AIX && !TARGET_RELOCATABLE) + fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP); + else + { + fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); + if (!toc_initialized) + { + ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); + fprintf (asm_out_file, " = .+32768\n"); + toc_initialized = 1; + } + } +} - Do not define this macro if you put all constants in the read-only - data section. */ +/* Implement TARGET_ASM_INIT_SECTIONS. */ static void +rs6000_elf_asm_init_sections (void) +{ + toc_section + = get_unnamed_section (0, rs6000_elf_output_toc_section_asm_op, NULL); + + sdata2_section + = get_unnamed_section (SECTION_WRITE, output_section_asm_op, + SDATA2_SECTION_ASM_OP); +} + +/* Implement TARGET_SELECT_RTX_SECTION. */ + +static section * rs6000_elf_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode)) - toc_section (); + return toc_section; else - default_elf_select_rtx_section (mode, x, align); + return default_elf_select_rtx_section (mode, x, align); } -/* A C statement or statements to switch to the appropriate - section for output of DECL. DECL is either a `VAR_DECL' node - or a constant of some sort. RELOC indicates whether forming - the initial value of DECL requires link-time relocations. */ +/* Implement TARGET_ASM_SELECT_SECTION for ELF targets. */ -static void +static section * rs6000_elf_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align) { @@ -17355,8 +17406,8 @@ rs6000_elf_select_section (tree decl, int reloc, ABI_AIX, because otherwise we end up with dynamic relocations in read-only sections. This happens for function pointers, references to vtables in typeinfo, and probably other cases. */ - default_elf_select_section_1 (decl, reloc, align, - flag_pic || DEFAULT_ABI == ABI_AIX); + return default_elf_select_section_1 (decl, reloc, align, + flag_pic || DEFAULT_ABI == ABI_AIX); } /* A C statement to build up a unique section name, expressed as a @@ -17678,9 +17729,9 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub) GEN_LAZY_PTR_NAME_FOR_SYMBOL (lazy_ptr_name, symb, length); if (flag_pic == 2) - machopic_picsymbol_stub1_section (); + switch_to_section (machopic_picsymbol_stub1_section); else - machopic_symbol_stub1_section (); + switch_to_section (machopic_symbol_stub1_section); if (flag_pic == 2) { @@ -17720,7 +17771,7 @@ machopic_output_stub (FILE *file, const char *symb, const char *stub) fprintf (file, "\tbctr\n"); } - machopic_lazy_symbol_ptr_section (); + switch_to_section (machopic_lazy_symbol_ptr_section); fprintf (file, "%s:\n", lazy_ptr_name); fprintf (file, "\t.indirect_symbol %s\n", symbol_name); fprintf (file, "%sdyld_stub_binding_helper\n", @@ -17781,16 +17832,6 @@ rs6000_machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, return machopic_legitimize_pic_address (orig, mode, reg); } -/* This is just a placeholder to make linking work without having to - add this to the generic Darwin EXTRA_SECTIONS. If -mcall-aix is - ever needed for Darwin (not too likely!) this would have to get a - real definition. */ - -void -toc_section (void) -{ -} - /* Output a .machine directive for the Darwin assembler, and call the generic start_file routine. */ @@ -17876,7 +17917,7 @@ rs6000_elf_asm_out_constructor (rtx symbol, int priority) section = buf; } - named_section_flags (section, SECTION_WRITE); + switch_to_section (get_section (section, SECTION_WRITE, NULL)); assemble_align (POINTER_SIZE); if (TARGET_RELOCATABLE) @@ -17905,7 +17946,7 @@ rs6000_elf_asm_out_destructor (rtx symbol, int priority) section = buf; } - named_section_flags (section, SECTION_WRITE); + switch_to_section (get_section (section, SECTION_WRITE, NULL)); assemble_align (POINTER_SIZE); if (TARGET_RELOCATABLE) @@ -18011,6 +18052,73 @@ rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name) putc ('\n', stream); } +/* A get_unnamed_decl callback, used for read-only sections. PTR + points to the section string variable. */ + +static void +rs6000_xcoff_output_readonly_section_asm_op (const void *directive) +{ + fprintf (asm_out_file, "\t.csect %s[RO],3\n", + *(const char *const *) directive); +} + +/* Likewise for read-write sections. */ + +static void +rs6000_xcoff_output_readwrite_section_asm_op (const void *directive) +{ + fprintf (asm_out_file, "\t.csect %s[RW],3\n", + *(const char *const *) directive); +} + +/* A get_unnamed_section callback, used for switching to toc_section. */ + +static void +rs6000_xcoff_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED) +{ + if (TARGET_MINIMAL_TOC) + { + /* toc_section is always selected at least once from + rs6000_xcoff_file_start, so this is guaranteed to + always be defined once and only once in each file. */ + if (!toc_initialized) + { + fputs ("\t.toc\nLCTOC..1:\n", asm_out_file); + fputs ("\t.tc toc_table[TC],toc_table[RW]\n", asm_out_file); + toc_initialized = 1; + } + fprintf (asm_out_file, "\t.csect toc_table[RW]%s\n", + (TARGET_32BIT ? "" : ",3")); + } + else + fputs ("\t.toc\n", asm_out_file); +} + +/* Implement TARGET_ASM_INIT_SECTIONS. */ + +static void +rs6000_xcoff_asm_init_sections (void) +{ + read_only_data_section + = get_unnamed_section (0, rs6000_xcoff_output_readonly_section_asm_op, + &xcoff_read_only_section_name); + + private_data_section + = get_unnamed_section (SECTION_WRITE, + rs6000_xcoff_output_readwrite_section_asm_op, + &xcoff_private_data_section_name); + + read_only_private_data_section + = get_unnamed_section (0, rs6000_xcoff_output_readonly_section_asm_op, + &xcoff_private_data_section_name); + + toc_section + = get_unnamed_section (0, rs6000_xcoff_output_toc_section_asm_op, NULL); + + readonly_data_section = read_only_data_section; + exception_section = data_section; +} + static void rs6000_xcoff_asm_named_section (const char *name, unsigned int flags, tree decl ATTRIBUTE_UNUSED) @@ -18030,23 +18138,23 @@ rs6000_xcoff_asm_named_section (const char *name, unsigned int flags, name, suffix[smclass], flags & SECTION_ENTSIZE); } -static void +static section * rs6000_xcoff_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { if (decl_readonly_section_1 (decl, reloc, 1)) { if (TREE_PUBLIC (decl)) - read_only_data_section (); + return read_only_data_section; else - read_only_private_data_section (); + return read_only_private_data_section; } else { if (TREE_PUBLIC (decl)) - data_section (); + return data_section; else - private_data_section (); + return private_data_section; } } @@ -18075,14 +18183,14 @@ rs6000_xcoff_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED) However, if this is being placed in the TOC it must be output as a toc entry. */ -static void +static section * rs6000_xcoff_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode)) - toc_section (); + return toc_section; else - read_only_private_data_section (); + return read_only_private_data_section; } /* Remove any trailing [DS] or the like from the symbol name. */ @@ -18146,8 +18254,8 @@ rs6000_xcoff_file_start (void) output_quoted_string (asm_out_file, main_input_filename); fputc ('\n', asm_out_file); if (write_symbols != NO_DEBUG) - private_data_section (); - text_section (); + switch_to_section (private_data_section); + switch_to_section (text_section); if (profile_flag) fprintf (asm_out_file, "\t.extern %s\n", RS6000_MCOUNT); rs6000_file_start (); @@ -18159,9 +18267,9 @@ rs6000_xcoff_file_start (void) static void rs6000_xcoff_file_end (void) { - text_section (); + switch_to_section (text_section); fputs ("_section_.text:\n", asm_out_file); - data_section (); + switch_to_section (data_section); fputs (TARGET_32BIT ? "\t.long _section_.text\n" : "\t.llong _section_.text\n", asm_out_file); diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 3077776..62690f4 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -359,126 +359,8 @@ do { \ #define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\"" #define SBSS_SECTION_ASM_OP "\t.section\t\".sbss\",\"aw\",@nobits" -/* Besides the usual ELF sections, we need a toc section. */ -/* Override elfos.h definition. */ -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_toc, in_sdata, in_sdata2, in_sbss, in_init, in_fini - -/* Override elfos.h definition. */ -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - TOC_SECTION_FUNCTION \ - SDATA_SECTION_FUNCTION \ - SDATA2_SECTION_FUNCTION \ - SBSS_SECTION_FUNCTION \ - INIT_SECTION_FUNCTION \ - FINI_SECTION_FUNCTION - -#define TOC_SECTION_FUNCTION \ -void \ -toc_section (void) \ -{ \ - if (in_section != in_toc) \ - { \ - in_section = in_toc; \ - if (DEFAULT_ABI == ABI_AIX \ - && TARGET_MINIMAL_TOC \ - && !TARGET_RELOCATABLE) \ - { \ - if (! toc_initialized) \ - { \ - toc_initialized = 1; \ - fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP); \ - (*targetm.asm_out.internal_label) (asm_out_file, "LCTOC", 0); \ - fprintf (asm_out_file, "\t.tc "); \ - ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1[TC],"); \ - ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \ - fprintf (asm_out_file, "\n"); \ - \ - fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \ - ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \ - fprintf (asm_out_file, " = .+32768\n"); \ - } \ - else \ - fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \ - } \ - else if (DEFAULT_ABI == ABI_AIX && !TARGET_RELOCATABLE) \ - fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP); \ - else \ - { \ - fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP); \ - if (! toc_initialized) \ - { \ - ASM_OUTPUT_INTERNAL_LABEL_PREFIX (asm_out_file, "LCTOC1"); \ - fprintf (asm_out_file, " = .+32768\n"); \ - toc_initialized = 1; \ - } \ - } \ - } \ -} \ - \ -extern int in_toc_section (void); \ -int in_toc_section (void) \ -{ \ - return in_section == in_toc; \ -} - -#define SDATA_SECTION_FUNCTION \ -void \ -sdata_section (void) \ -{ \ - if (in_section != in_sdata) \ - { \ - in_section = in_sdata; \ - fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \ - } \ -} - -#define SDATA2_SECTION_FUNCTION \ -void \ -sdata2_section (void) \ -{ \ - if (in_section != in_sdata2) \ - { \ - in_section = in_sdata2; \ - fprintf (asm_out_file, "%s\n", SDATA2_SECTION_ASM_OP); \ - } \ -} - -#define SBSS_SECTION_FUNCTION \ -void \ -sbss_section (void) \ -{ \ - if (in_section != in_sbss) \ - { \ - in_section = in_sbss; \ - fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP); \ - } \ -} - -#define INIT_SECTION_FUNCTION \ -void \ -init_section (void) \ -{ \ - if (in_section != in_init) \ - { \ - in_section = in_init; \ - fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP); \ - } \ -} - -#define FINI_SECTION_FUNCTION \ -void \ -fini_section (void) \ -{ \ - if (in_section != in_fini) \ - { \ - in_section = in_fini; \ - fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP); \ - } \ -} - /* Override default elf definitions. */ +#define TARGET_ASM_INIT_SECTIONS rs6000_elf_asm_init_sections #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION rs6000_elf_select_rtx_section #undef TARGET_ASM_SELECT_SECTION @@ -555,7 +437,7 @@ extern int rs6000_pic_labelno; do { \ if ((DECL) && rs6000_elf_in_small_data_p (DECL)) \ { \ - sbss_section (); \ + switch_to_section (sbss_section); \ ASM_OUTPUT_ALIGN (FILE, exact_log2 (ALIGN / BITS_PER_UNIT)); \ ASM_OUTPUT_LABEL (FILE, NAME); \ ASM_OUTPUT_SKIP (FILE, SIZE); \ diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 822b5a0..e7560a8 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -56,93 +56,6 @@ #define DOLLARS_IN_IDENTIFIERS 0 -/* Define the extra sections we need. We define three: one is the read-only - data section which is used for constants. This is a csect whose name is - derived from the name of the input file. The second is for initialized - global variables. This is a csect whose name is that of the variable. - The third is the TOC. */ - -#define EXTRA_SECTIONS \ - read_only_data, private_data, read_only_private_data, toc, bss - -/* Define the routines to implement these extra sections. - BIGGEST_ALIGNMENT is 64, so align the sections that much. */ - -#define EXTRA_SECTION_FUNCTIONS \ - READ_ONLY_DATA_SECTION_FUNCTION \ - PRIVATE_DATA_SECTION_FUNCTION \ - READ_ONLY_PRIVATE_DATA_SECTION_FUNCTION \ - TOC_SECTION_FUNCTION - -#define READ_ONLY_DATA_SECTION_FUNCTION \ -void \ -read_only_data_section (void) \ -{ \ - if (in_section != read_only_data) \ - { \ - fprintf (asm_out_file, "\t.csect %s[RO],3\n", \ - xcoff_read_only_section_name); \ - in_section = read_only_data; \ - } \ -} - -#define PRIVATE_DATA_SECTION_FUNCTION \ -void \ -private_data_section (void) \ -{ \ - if (in_section != private_data) \ - { \ - fprintf (asm_out_file, "\t.csect %s[RW],3\n", \ - xcoff_private_data_section_name); \ - in_section = private_data; \ - } \ -} - -#define READ_ONLY_PRIVATE_DATA_SECTION_FUNCTION \ -void \ -read_only_private_data_section (void) \ -{ \ - if (in_section != read_only_private_data) \ - { \ - fprintf (asm_out_file, "\t.csect %s[RO],3\n", \ - xcoff_private_data_section_name); \ - in_section = read_only_private_data; \ - } \ -} - -#define TOC_SECTION_FUNCTION \ -void \ -toc_section (void) \ -{ \ - if (TARGET_MINIMAL_TOC) \ - { \ - /* toc_section is always called at least once \ - from rs6000_xcoff_file_start, so this is \ - guaranteed to always be defined once and \ - only once in each file. */ \ - if (! toc_initialized) \ - { \ - fputs ("\t.toc\nLCTOC..1:\n", asm_out_file); \ - fputs ("\t.tc toc_table[TC],toc_table[RW]\n", asm_out_file); \ - toc_initialized = 1; \ - } \ - \ - if (in_section != toc) \ - fprintf (asm_out_file, "\t.csect toc_table[RW]%s\n", \ - (TARGET_32BIT ? "" : ",3")); \ - } \ - else \ - { \ - if (in_section != toc) \ - fputs ("\t.toc\n", asm_out_file); \ - } \ - in_section = toc; \ -} - -/* Define the name of our readonly data section. */ - -#define READONLY_DATA_SECTION read_only_data_section - /* Return nonzero if this entry is to be written into the constant pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST containing one of them. If -mfp-in-toc (the default), @@ -168,6 +81,7 @@ toc_section (void) \ && ! TARGET_NO_FP_IN_TOC))))) #define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label +#define TARGET_ASM_INIT_SECTIONS rs6000_xcoff_asm_init_sections #define TARGET_ASM_NAMED_SECTION rs6000_xcoff_asm_named_section #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section @@ -213,9 +127,8 @@ toc_section (void) \ On the RS/6000, we need to place an extra '.' in the function name and output the function descriptor. - The csect for the function will have already been created by the - `text_section' call previously done. We do have to go back to that - csect, however. + The csect for the function will have already been created when + text_section was selected. We do have to go back to that csect, however. The third and fourth parameters to the .function pseudo-op (16 and 044) are placeholders which no longer have any use. */ @@ -244,8 +157,8 @@ toc_section (void) \ fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE); \ RS6000_OUTPUT_BASENAME (FILE, NAME); \ fputs (", TOC[tc0], 0\n", FILE); \ - in_section = no_section; \ - function_section(DECL); \ + in_section = NULL; \ + switch_to_section (function_section (DECL)); \ putc ('.', FILE); \ RS6000_OUTPUT_BASENAME (FILE, NAME); \ fputs (":\n", FILE); \ @@ -362,10 +275,6 @@ toc_section (void) \ Align entire section to BIGGEST_ALIGNMENT. */ #define DATA_SECTION_ASM_OP "\t.csect .data[RW],3" -/* Define the name of the section to use for the EH language specific - data areas (.gcc_except_table on most other systems). */ -#define TARGET_ASM_EXCEPTION_SECTION data_section - /* Define to prevent DWARF2 unwind info in the data section rather than in the .eh_frame section. We do this because the AIX linker would otherwise garbage collect these sections. */ diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 1cbdd99..81c7872 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -1785,7 +1785,7 @@ sh_file_start (void) else /* Switch to the data section so that the coffsem symbol isn't in the text section. */ - data_section (); + switch_to_section (data_section); if (TARGET_LITTLE_ENDIAN) fputs ("\t.little\n", asm_out_file); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 7047af3..52d2695 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -3287,7 +3287,7 @@ emit_pic_helper (void) const char *pic_name = reg_names[REGNO (pic_offset_table_rtx)]; int align; - text_section (); + switch_to_section (text_section); align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); if (align > 0) @@ -7477,7 +7477,7 @@ sparc_output_deferred_case_vectors (void) return; /* Align to cache line in the function's code section. */ - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT); if (align > 0) diff --git a/gcc/config/stormy16/stormy16-protos.h b/gcc/config/stormy16/stormy16-protos.h index 1cc9c4f..32c5ea6 100644 --- a/gcc/config/stormy16/stormy16-protos.h +++ b/gcc/config/stormy16/stormy16-protos.h @@ -29,7 +29,6 @@ extern int direct_return (void); extern int xstormy16_interrupt_function_p (void); extern int xstormy16_epilogue_uses (int); extern void xstormy16_function_profiler (void); -extern void bss100_section (void); #if defined (TREE_CODE) extern void xstormy16_asm_output_aligned_common (FILE *, tree, const char *, diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 3e77924..76becfc 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -47,6 +47,7 @@ Boston, MA 02110-1301, USA. */ #include "tm_p.h" #include "langhooks.h" #include "tree-gimple.h" +#include "ggc.h" static rtx emit_addhi3_postreload (rtx, rtx, rtx); static void xstormy16_asm_out_constructor (rtx, int); @@ -65,6 +66,8 @@ static bool xstormy16_return_in_memory (tree, tree); struct rtx_def * xstormy16_compare_op0; struct rtx_def * xstormy16_compare_op1; +static GTY(()) section *bss100_section; + /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. */ @@ -1593,7 +1596,7 @@ xstormy16_asm_output_aligned_common (FILE *stream, const char *name2; int p2align = 0; - bss100_section (); + switch_to_section (bss100_section); while (align > 8) { @@ -1623,6 +1626,17 @@ xstormy16_asm_output_aligned_common (FILE *stream, fprintf (stream, ",%u,%u\n", size, align / BITS_PER_UNIT); } +/* Implement TARGET_ASM_INIT_SECTIONS. */ + +static void +xstormy16_asm_init_sections (void) +{ + bss100_section + = get_unnamed_section (SECTION_WRITE | SECTION_BSS, + output_section_asm_op, + "\t.section \".bss_below100\",\"aw\",@nobits"); +} + /* Mark symbols with the "below100" attribute so that we can use the special addressing modes for them. */ @@ -1666,7 +1680,7 @@ xstormy16_asm_out_destructor (rtx symbol, int priority) section = buf; } - named_section_flags (section, 0); + switch_to_section (get_section (section, 0, NULL)); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } @@ -1688,7 +1702,7 @@ xstormy16_asm_out_constructor (rtx symbol, int priority) section = buf; } - named_section_flags (section, 0); + switch_to_section (get_section (section, 0, NULL)); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } @@ -1917,7 +1931,7 @@ xstormy16_output_addr_vec (FILE *file, rtx label ATTRIBUTE_UNUSED, rtx table) { int vlen, idx; - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); vlen = XVECLEN (table, 0); for (idx = 0; idx < vlen; idx++) @@ -2668,3 +2682,5 @@ xstormy16_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED) #define TARGET_MACHINE_DEPENDENT_REORG xstormy16_reorg struct gcc_target targetm = TARGET_INITIALIZER; + +#include "gt-stormy16.h" diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index e37d19a..faf0472 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -618,29 +618,10 @@ do { \ #undef DTORS_SECTION_ASM_OP #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"a\"" #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"a\"" -#define EXTRA_SECTIONS in_bss100 - -/* We define the function body in a separate macro so that if we ever - add another section, we can just add an entry to - EXTRA_SECTION_FUNCTIONS without making it difficult to read. It is - not used anywhere else. */ -#define XSTORMY16_SECTION_FUNCTION(name, in, string, bits) \ - void \ - name () \ - { \ - if (in_section != in) \ - { \ - fprintf (asm_out_file, "\t.section %s,\"aw\",@%sbits\n", string, bits); \ - in_section = in; \ - } \ - } - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - XSTORMY16_SECTION_FUNCTION (bss100_section, in_bss100, ".bss_below100", "no") -#define JUMP_TABLES_IN_TEXT_SECTION 1 +#define TARGET_ASM_INIT_SECTIONS xstormy16_asm_init_sections +#define JUMP_TABLES_IN_TEXT_SECTION 1 /* The Overall Framework of an Assembler File. */ diff --git a/gcc/config/svr3.h b/gcc/config/svr3.h index ffdac98..283ebf0 100644 --- a/gcc/config/svr3.h +++ b/gcc/config/svr3.h @@ -54,7 +54,7 @@ Boston, MA 02110-1301, USA. */ do { \ int align = exact_log2 (ROUNDED); \ if (align > 2) align = 2; \ - data_section (); \ + switch_to_section (data_section); \ ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \ ASM_OUTPUT_LABEL ((FILE), (NAME)); \ fprintf ((FILE), "\t.set .,.+%u\n", (int)(ROUNDED)); \ @@ -159,33 +159,3 @@ do { \ } while (0) #endif /* STACK_GROWS_DOWNWARD */ - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_init, in_fini - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - INIT_SECTION_FUNCTION \ - FINI_SECTION_FUNCTION - -#define INIT_SECTION_FUNCTION \ -void \ -init_section () \ -{ \ - if (in_section != in_init) \ - { \ - fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP); \ - in_section = in_init; \ - } \ -} - -#define FINI_SECTION_FUNCTION \ -void \ -fini_section () \ -{ \ - if (in_section != in_fini) \ - { \ - fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP); \ - in_section = in_fini; \ - } \ -} diff --git a/gcc/config/t-darwin b/gcc/config/t-darwin index d59f0b7..7fe3220 100644 --- a/gcc/config/t-darwin +++ b/gcc/config/t-darwin @@ -1,7 +1,8 @@ darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h $(REAL_H) insn-config.h \ conditions.h insn-flags.h output.h insn-attr.h flags.h $(TREE_H) expr.h \ - reload.h function.h $(GGC_H) langhooks.h $(TARGET_H) $(TM_P_H) gt-darwin.h + reload.h function.h $(GGC_H) langhooks.h $(TARGET_H) $(TM_P_H) gt-darwin.h \ + config/darwin-sections.def $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/darwin.c darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ diff --git a/gcc/config/v850/v850-protos.h b/gcc/config/v850/v850-protos.h index aff1241..8374b53 100644 --- a/gcc/config/v850/v850-protos.h +++ b/gcc/config/v850/v850-protos.h @@ -27,13 +27,6 @@ extern void expand_prologue (void); extern void expand_epilogue (void); -extern void sdata_section (void); -extern void rosdata_section (void); -extern void sbss_section (void); -extern void tdata_section (void); -extern void zdata_section (void); -extern void rozdata_section (void); -extern void zbss_section (void); extern int v850_handle_pragma (int (*)(void), void (*)(int), char *); extern int compute_register_save_size (long *); extern int compute_frame_size (int, long *); diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index e77d56a..7629a7a 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -62,7 +62,8 @@ const struct attribute_spec v850_attribute_table[]; static tree v850_handle_interrupt_attribute (tree *, tree, tree, int, bool *); static tree v850_handle_data_area_attribute (tree *, tree, tree, int, bool *); static void v850_insert_attributes (tree, tree *); -static void v850_select_section (tree, int, unsigned HOST_WIDE_INT); +static void v850_asm_init_sections (void); +static section *v850_select_section (tree, int, unsigned HOST_WIDE_INT); static void v850_encode_data_area (tree, rtx); static void v850_encode_section_info (tree, rtx, int); static bool v850_return_in_memory (tree, tree); @@ -96,6 +97,12 @@ static int v850_interrupt_cache_p = FALSE; /* Whether current function is an interrupt handler. */ static int v850_interrupt_p = FALSE; + +static GTY(()) section *rosdata_section; +static GTY(()) section *rozdata_section; +static GTY(()) section *tdata_section; +static GTY(()) section *zdata_section; +static GTY(()) section *zbss_section; /* Initialize the GCC target structure. */ #undef TARGET_ASM_ALIGNED_HI_OP @@ -2498,18 +2505,18 @@ v850_output_aligned_bss (FILE * file, switch (v850_get_data_area (decl)) { case DATA_AREA_ZDA: - zbss_section (); + switch_to_section (zbss_section); break; case DATA_AREA_SDA: - sbss_section (); + switch_to_section (sbss_section); break; case DATA_AREA_TDA: - tdata_section (); + switch_to_section (tdata_section); default: - bss_section (); + switch_to_section (bss_section); break; } @@ -2927,7 +2934,34 @@ v850_return_addr (int count) return get_hard_reg_initial_val (Pmode, LINK_POINTER_REGNUM); } +/* Implement TARGET_ASM_INIT_SECTIONS. */ + static void +v850_asm_init_sections (void) +{ + rosdata_section + = get_unnamed_section (0, output_section_asm_op, + "\t.section .rosdata,\"a\""); + + rozdata_section + = get_unnamed_section (0, output_section_asm_op, + "\t.section .rozdata,\"a\""); + + tdata_section + = get_unnamed_section (SECTION_WRITE, output_section_asm_op, + "\t.section .tdata,\"aw\""); + + zdata_section + = get_unnamed_section (SECTION_WRITE, output_section_asm_op, + "\t.section .zdata,\"aw\""); + + zbss_section + = get_unnamed_section (SECTION_WRITE | SECTION_BSS, + output_section_asm_op, + "\t.section .zbss,\"aw\""); +} + +static section * v850_select_section (tree exp, int reloc ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) @@ -2947,33 +2981,19 @@ v850_select_section (tree exp, switch (v850_get_data_area (exp)) { case DATA_AREA_ZDA: - if (is_const) - rozdata_section (); - else - zdata_section (); - break; + return is_const ? rozdata_section : zdata_section; case DATA_AREA_TDA: - tdata_section (); - break; + return tdata_section; case DATA_AREA_SDA: - if (is_const) - rosdata_section (); - else - sdata_section (); - break; + return is_const ? rosdata_section : sdata_section; default: - if (is_const) - readonly_data_section (); - else - data_section (); - break; + return is_const ? readonly_data_section : data_section; } } - else - readonly_data_section (); + return readonly_data_section; } /* Worker function for TARGET_RETURN_IN_MEMORY. */ @@ -2996,3 +3016,5 @@ v850_setup_incoming_varargs (CUMULATIVE_ARGS *ca, { ca->anonymous_args = (!TARGET_GHS ? 1 : 0); } + +#include "gt-v850.h" diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index c43c802..c1dbd78 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -876,101 +876,11 @@ typedef enum DATA_AREA_ZDA } v850_data_area; -/* A list of names for sections other than the standard two, which are - `in_text' and `in_data'. You need not define this macro on a - system with no other sections (that GCC needs to use). */ -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_tdata, in_sdata, in_zdata, \ - in_rozdata, in_rosdata, in_sbss, in_zbss, in_zcommon, in_scommon - -/* One or more functions to be defined in `varasm.c'. These - functions should do jobs analogous to those of `text_section' and - `data_section', for your additional sections. Do not define this - macro if you do not define `EXTRA_SECTIONS'. */ -#undef EXTRA_SECTION_FUNCTIONS - -/* This could be done a lot more cleanly using ANSI C.... */ -#define EXTRA_SECTION_FUNCTIONS \ -void \ -sdata_section () \ -{ \ - if (in_section != in_sdata) \ - { \ - fprintf (asm_out_file, "%s\n", SDATA_SECTION_ASM_OP); \ - in_section = in_sdata; \ - } \ -} \ - \ -void \ -rosdata_section () \ -{ \ - if (in_section != in_rosdata) \ - { \ - fprintf (asm_out_file, "%s\n", ROSDATA_SECTION_ASM_OP); \ - in_section = in_sdata; \ - } \ -} \ - \ -void \ -sbss_section () \ -{ \ - if (in_section != in_sbss) \ - { \ - fprintf (asm_out_file, "%s\n", SBSS_SECTION_ASM_OP); \ - in_section = in_sbss; \ - } \ -} \ - \ -void \ -tdata_section () \ -{ \ - if (in_section != in_tdata) \ - { \ - fprintf (asm_out_file, "%s\n", TDATA_SECTION_ASM_OP); \ - in_section = in_tdata; \ - } \ -} \ - \ -void \ -zdata_section () \ -{ \ - if (in_section != in_zdata) \ - { \ - fprintf (asm_out_file, "%s\n", ZDATA_SECTION_ASM_OP); \ - in_section = in_zdata; \ - } \ -} \ - \ -void \ -rozdata_section () \ -{ \ - if (in_section != in_rozdata) \ - { \ - fprintf (asm_out_file, "%s\n", ROZDATA_SECTION_ASM_OP); \ - in_section = in_rozdata; \ - } \ -} \ - \ -void \ -zbss_section () \ -{ \ - if (in_section != in_zbss) \ - { \ - fprintf (asm_out_file, "%s\n", ZBSS_SECTION_ASM_OP); \ - in_section = in_zbss; \ - } \ -} - #define TEXT_SECTION_ASM_OP "\t.section .text" #define DATA_SECTION_ASM_OP "\t.section .data" #define BSS_SECTION_ASM_OP "\t.section .bss" #define SDATA_SECTION_ASM_OP "\t.section .sdata,\"aw\"" #define SBSS_SECTION_ASM_OP "\t.section .sbss,\"aw\"" -#define ZDATA_SECTION_ASM_OP "\t.section .zdata,\"aw\"" -#define ZBSS_SECTION_ASM_OP "\t.section .zbss,\"aw\"" -#define TDATA_SECTION_ASM_OP "\t.section .tdata,\"aw\"" -#define ROSDATA_SECTION_ASM_OP "\t.section .rosdata,\"a\"" -#define ROZDATA_SECTION_ASM_OP "\t.section .rozdata,\"a\"" #define SCOMMON_ASM_OP "\t.scomm\t" #define ZCOMMON_ASM_OP "\t.zcomm\t" @@ -1230,4 +1140,6 @@ extern union tree_node * GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_K #define SYMBOL_REF_TDA_P(X) ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_TDA) != 0) #define SYMBOL_REF_SDA_P(X) ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_SDA) != 0) +#define TARGET_ASM_INIT_SECTIONS v850_asm_init_sections + #endif /* ! GCC_V850_H */ diff --git a/gcc/config/vax/vaxv.h b/gcc/config/vax/vaxv.h index 8394c64..83870a0 100644 --- a/gcc/config/vax/vaxv.h +++ b/gcc/config/vax/vaxv.h @@ -48,7 +48,7 @@ Boston, MA 02110-1301, USA. */ #undef ASM_OUTPUT_LOCAL #define ASM_OUTPUT_LOCAL(FILE,NAME,SIZE,ROUNDED) \ -( data_section (), \ +( switch_to_section (data_section), \ assemble_name ((FILE), (NAME)), \ fprintf ((FILE), ":\n\t.space %u\n", (int)(ROUNDED))) diff --git a/gcc/config/vx-common.h b/gcc/config/vx-common.h index baa37f0..cb8d7a0 100644 --- a/gcc/config/vx-common.h +++ b/gcc/config/vx-common.h @@ -83,17 +83,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA sorry ("profiler support for VxWorks"); \ } while (0) -/* This section either contains dynamic relocations, or contains - PC-rel indirections to stubs in the data section which contain dynamic - relocations. General dynamic relocations are not processed - for shared libraries' text segments, and PC-relative displacements - from the text segment to the data segment don't work. So force - it to .gcc_except_section, which the linker will place in .data. */ - -void vxworks_exception_section (void); -#undef TARGET_ASM_EXCEPTION_SECTION -#define TARGET_ASM_EXCEPTION_SECTION default_exception_section - /* We occasionally need to distinguish between the VxWorks variants. */ #define VXWORKS_KIND_NORMAL 1 #define VXWORKS_KIND_AE 2 diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 9dfa302..d05d97e 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -204,8 +204,8 @@ static void xtensa_function_epilogue (FILE *, HOST_WIDE_INT); static rtx xtensa_builtin_saveregs (void); static unsigned int xtensa_multibss_section_type_flags (tree, const char *, int) ATTRIBUTE_UNUSED; -static void xtensa_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); +static section *xtensa_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); static bool xtensa_rtx_costs (rtx, int, int, int *); static tree xtensa_build_builtin_va_list (void); static bool xtensa_return_in_memory (tree, tree); @@ -2421,12 +2421,12 @@ xtensa_multibss_section_type_flags (tree decl, const char *name, int reloc) /* The literal pool stays with the function. */ -static void +static section * xtensa_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { - function_section (current_function_decl); + return function_section (current_function_decl); } diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index 8434d19..e541e2a 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -1210,7 +1210,7 @@ typedef struct xtensa_args } \ if ((SIZE) > 0) \ { \ - function_section (FUNDECL); \ + switch_to_section (function_section (FUNDECL)); \ fprintf (FILE, "\t.literal_position\n"); \ } \ } while (0) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 935f660..7942459 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -43,6 +43,8 @@ struct rtvec_def; typedef struct rtvec_def *rtvec; union tree_node; typedef union tree_node *tree; +union section; +typedef union section section; /* Provide forward struct declaration so that we don't have to include all of cpplib.h whenever a random prototype includes a pointer. diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 9ffced0..cb7df88 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -269,7 +269,7 @@ static int pending_bincls = 0; static const char *base_input_file; #ifdef DEBUG_SYMS_TEXT -#define FORCE_TEXT current_function_section (current_function_decl); +#define FORCE_TEXT switch_to_section (current_function_section ()) #else #define FORCE_TEXT #endif @@ -907,7 +907,7 @@ dbxout_function_end (tree decl) /* The Lscope label must be emitted even if we aren't doing anything else; dbxout_block needs it. */ - function_section (current_function_decl); + switch_to_section (function_section (current_function_decl)); /* Convert Lscope into the appropriate format for local labels in case the system doesn't insert underscores in front of user generated @@ -1033,7 +1033,7 @@ dbxout_init (const char *input_file_name) if (used_ltext_label_name) { - text_section (); + switch_to_section (text_section); targetm.asm_out.internal_label (asm_out_file, "Ltext", 0); } @@ -1232,7 +1232,7 @@ dbxout_source_file (const char *filename) { /* Don't change section amid function. */ if (current_function_decl == NULL_TREE) - text_section (); + switch_to_section (text_section); dbxout_begin_simple_stabs (filename, N_SOL); dbxout_stab_value_internal_label ("Ltext", &source_label_number); @@ -1347,7 +1347,7 @@ dbxout_finish (const char *filename ATTRIBUTE_UNUSED) DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file, filename); #elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END { - text_section (); + switch_to_section (text_section); dbxout_begin_empty_stabs (N_SO); dbxout_stab_value_internal_label ("Letext", 0); } @@ -2838,7 +2838,7 @@ dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home) { /* Ultrix `as' seems to need this. */ #ifdef DBX_STATIC_STAB_DATA_SECTION - data_section (); + switch_to_section (data_section); #endif code = N_STSYM; } diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 35bd5c3..53f405b 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4688,10 +4688,8 @@ to generate it on the spot. @end defmac @defmac TRAMPOLINE_SECTION -The name of a subroutine to switch to the section in which the -trampoline template is to be placed (@pxref{Sections}). The default is -a value of @samp{readonly_data_section}, which places the trampoline in -the section containing read-only data. +Return the section into which the trampoline template is to be placed +(@pxref{Sections}). The default value is @code{readonly_data_section}. @end defmac @defmac TRAMPOLINE_SIZE @@ -5914,9 +5912,32 @@ section}, which holds initialized writable data; and the @dfn{bss section}, which holds uninitialized data. Some systems have other kinds of sections. -The compiler must tell the assembler when to switch sections. These -macros control what commands to output to tell the assembler this. You -can also define additional sections. +@file{varasm.c} provides several well-known sections, such as +@code{text_section}, @code{data_section} and @code{bss_section}. +The normal way of controlling a @code{@var{foo}_section} variable +is to define the associated @code{@var{FOO}_SECTION_ASM_OP} macro, +as described below. The macros are only read once, when @file{varasm.c} +initializes itself, so their values must be run-time constants. +They may however depend on command-line flags. + +@emph{Note:} Some run-time files, such @file{crtstuff.c}, also make +use of the @code{@var{FOO}_SECTION_ASM_OP} macros, and expect them +to be string literals. + +Some assemblers require a different string to be written every time a +section is selected. If your assembler falls into this category, you +should define the @code{TARGET_ASM_INIT_SECTIONS} hook and use +@code{get_unnamed_section} to set up the sections. + +You must always create a @code{text_section}, either by defining +@code{TEXT_SECTION_ASM_OP} or by initializing @code{text_section} +in @code{TARGET_ASM_INIT_SECTIONS}. The same is true of +@code{data_section} and @code{DATA_SECTION_ASM_OP}. If you do not +create a distinct @code{readonly_data_section}, the default is to +reuse @code{text_section}. + +All the other @file{varasm.c} sections are optional, and are null +if the target does not provide them. @defmac TEXT_SECTION_ASM_OP A C expression whose value is a string, including spacing, containing the @@ -5941,22 +5962,18 @@ assembler operation to identify the following data as writable initialized data. Normally @code{"\t.data"} is right. @end defmac +@defmac SDATA_SECTION_ASM_OP +If defined, a C expression whose value is a string, including spacing, +containing the assembler operation to identify the following data as +initialized, writable small data. +@end defmac + @defmac READONLY_DATA_SECTION_ASM_OP A C expression whose value is a string, including spacing, containing the assembler operation to identify the following data as read-only initialized data. @end defmac -@defmac READONLY_DATA_SECTION -A macro naming a function to call to switch to the proper section for -read-only data. The default is to use @code{READONLY_DATA_SECTION_ASM_OP} -if defined, else fall back to @code{text_section}. - -The most common definition will be @code{data_section}, if the target -does not have a special read-only data section, and does not put data -in the text section. -@end defmac - @defmac BSS_SECTION_ASM_OP If defined, a C expression whose value is a string, including spacing, containing the assembler operation to identify the following data as @@ -5967,6 +5984,12 @@ uninitialized global data will be output in the data section if used. @end defmac +@defmac SBSS_SECTION_ASM_OP +If defined, a C expression whose value is a string, including spacing, +containing the assembler operation to identify the following data as +uninitialized, writable small data. +@end defmac + @defmac INIT_SECTION_ASM_OP If defined, a C expression whose value is a string, including spacing, containing the assembler operation to identify the following data as @@ -6016,23 +6039,6 @@ arbitrary boundary. This is used to force all fragments of the and thus prevent the linker from having to add any padding. @end defmac -@findex in_text -@findex in_data -@defmac EXTRA_SECTIONS -A list of names for sections other than the standard two, which are -@code{in_text} and @code{in_data}. You need not define this macro -on a system with no other sections (that GCC needs to use). -@end defmac - -@findex text_section -@findex data_section -@defmac EXTRA_SECTION_FUNCTIONS -One or more functions to be defined in @file{varasm.c}. These -functions should do jobs analogous to those of @code{text_section} and -@code{data_section}, for your additional sections. Do not define this -macro if you do not define @code{EXTRA_SECTIONS}. -@end defmac - @defmac JUMP_TABLES_IN_TEXT_SECTION Define this macro to be an expression with a nonzero value if jump tables (for @code{tablejump} insns) should be output in the text @@ -6042,15 +6048,23 @@ readonly data section is used. This macro is irrelevant if there is no separate readonly data section. @end defmac -@deftypefn {Target Hook} void TARGET_ASM_SELECT_SECTION (tree @var{exp}, int @var{reloc}, unsigned HOST_WIDE_INT @var{align}) -Switches to the appropriate section for output of @var{exp}. You can +@deftypefn {Target Hook} void TARGET_ASM_INIT_SECTIONS (void) +Define this hook if you need to do something special to set up the +@file{varasm.c} sections, or if your target has some special sections +of its own that you need to create. + +GCC calls this hook after processing the command line, but before writing +any assembly code, and before calling any of the section-returning hooks +described below. +@end deftypefn + +@deftypefn {Target Hook} {section *} TARGET_ASM_SELECT_SECTION (tree @var{exp}, int @var{reloc}, unsigned HOST_WIDE_INT @var{align}) +Return the section into which @var{exp} should be placed. You can assume that @var{exp} is either a @code{VAR_DECL} node or a constant of some sort. @var{reloc} indicates whether the initial value of @var{exp} requires link-time relocations. Bit 0 is set when variable contains local relocations only, while bit 1 is set for global relocations. -Select the section by calling @code{data_section} or one of the -alternatives for other sections. @var{align} is the constant alignment -in bits. +@var{align} is the constant alignment in bits. The default version of this function takes care of putting read-only variables in @code{readonly_data_section}. @@ -6079,22 +6093,21 @@ example, the function @code{foo} would be placed in @code{.text.foo}. Whatever the actual target object format, this is often good enough. @end deftypefn -@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_RODATA_SECTION (tree @var{decl}) -Switches to a readonly data section associated with +@deftypefn {Target Hook} {section *} TARGET_ASM_FUNCTION_RODATA_SECTION (tree @var{decl}) +Return the readonly data section associated with @samp{DECL_SECTION_NAME (@var{decl})}. -The default version of this function switches to @code{.gnu.linkonce.r.name} -section if function's section is @code{.gnu.linkonce.t.name}, to -@code{.rodata.name} if function is in @code{.text.name} section -and otherwise switches to the normal readonly data section. +The default version of this function selects @code{.gnu.linkonce.r.name} if +the function's section is @code{.gnu.linkonce.t.name}, @code{.rodata.name} +if function is in @code{.text.name}, and the normal readonly-data section +otherwise. @end deftypefn -@deftypefn {Target Hook} void TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode @var{mode}, rtx @var{x}, unsigned HOST_WIDE_INT @var{align}) -Switches to the appropriate section for output of constant pool entry -@var{x} in @var{mode}. You can assume that @var{x} is some kind of +@deftypefn {Target Hook} {section *} TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode @var{mode}, rtx @var{x}, unsigned HOST_WIDE_INT @var{align}) +Return the section into which a constant @var{x}, of mode @var{mode}, +should be placed. You can assume that @var{x} is some kind of constant in RTL@. The argument @var{mode} is redundant except in the -case of a @code{const_int} rtx. Select the section by calling -@code{readonly_data_section} or one of the alternatives for other -sections. @var{align} is the constant alignment in bits. +case of a @code{const_int} rtx. @var{align} is the constant alignment +in bits. The default version of this function takes care of putting symbolic constants in @code{flag_pic} mode in @code{data_section} and everything @@ -7742,24 +7755,6 @@ minimum alignment otherwise. @xref{SDB and DWARF}. Only applicable if the target supports DWARF 2 frame unwind information. @end defmac -@deftypefn {Target Hook} void TARGET_ASM_EXCEPTION_SECTION () -If defined, a function that switches to the section in which the main -exception table is to be placed (@pxref{Sections}). The default is a -function that switches to a section named @code{.gcc_except_table} on -machines that support named 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}. -@end deftypefn - -@deftypefn {Target Hook} void TARGET_ASM_EH_FRAME_SECTION () -If defined, a function that switches to the section in which the DWARF 2 -frame unwind information to be placed (@pxref{Sections}). The default -is a function that outputs a standard GAS section directive, if -@code{EH_FRAME_SECTION_NAME} is defined, or else a data section -directive followed by a synthetic label. -@end deftypefn - @deftypevar {Target Hook} bool TARGET_TERMINATE_DW2_EH_FRAME_INFO Contains the value true if the target should add a zero word onto the end of a Dwarf-2 frame info section when used for exception handling. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index ad7154e..3752fa6 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -113,12 +113,12 @@ dwarf2out_do_frame (void) #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT) #endif -/* Various versions of targetm.eh_frame_section. Note these must appear - outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO macro guards. */ +/* Return the default value of eh_frame_section. Note that this function + must appear outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO + macro guards. */ -/* Version of targetm.eh_frame_section for systems with named sections. */ -void -named_section_eh_frame_section (void) +section * +default_eh_frame_section (void) { #ifdef EH_FRAME_SECTION_NAME int flags; @@ -143,30 +143,9 @@ named_section_eh_frame_section (void) } else flags = SECTION_WRITE; - named_section_flags (EH_FRAME_SECTION_NAME, flags); -#endif -} - -/* Version of targetm.eh_frame_section for systems using collect2. */ -void -collect2_eh_frame_section (void) -{ - tree label = get_file_function_name ('F'); - - data_section (); - ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE)); - targetm.asm_out.globalize_label (asm_out_file, IDENTIFIER_POINTER (label)); - ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); -} - -/* Default version of targetm.eh_frame_section. */ -void -default_eh_frame_section (void) -{ -#ifdef EH_FRAME_SECTION_NAME - named_section_eh_frame_section (); + return get_section (EH_FRAME_SECTION_NAME, flags, NULL); #else - collect2_eh_frame_section (); + return NULL; #endif } @@ -190,6 +169,17 @@ static GTY(()) VEC(tree,gc) *incomplete_types; define type declaration DIE's. */ static GTY(()) VEC(tree,gc) *decl_scope_table; +/* Pointers to various DWARF2 sections. */ +static GTY(()) section *debug_info_section; +static GTY(()) section *debug_abbrev_section; +static GTY(()) section *debug_aranges_section; +static GTY(()) section *debug_macinfo_section; +static GTY(()) section *debug_line_section; +static GTY(()) section *debug_loc_section; +static GTY(()) section *debug_pubnames_section; +static GTY(()) section *debug_str_section; +static GTY(()) section *debug_ranges_section; + /* How to start an assembler comment. */ #ifndef ASM_COMMENT_START #define ASM_COMMENT_START ";#" @@ -1994,6 +1984,28 @@ dw_cfi_oprnd2_desc (enum dwarf_call_frame_info cfi) #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO) +/* Switch to eh_frame_section. If we don't have an eh_frame_section, + switch to the data section instead, and write out a synthetic label + for collect2. */ + +static void +switch_to_eh_frame_section (void) +{ + tree label; + + if (eh_frame_section) + switch_to_section (eh_frame_section); + else + { + switch_to_section (data_section); + label = get_file_function_name ('F'); + ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE)); + targetm.asm_out.globalize_label (asm_out_file, + IDENTIFIER_POINTER (label)); + ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label)); + } +} + /* Map register numbers held in the call frame info that gcc has collected using DWARF_FRAME_REGNUM to those that should be output in .debug_frame and .eh_frame. */ @@ -2188,9 +2200,9 @@ output_call_frame_info (int for_eh) app_enable (); if (for_eh) - targetm.asm_out.eh_frame_section (); + switch_to_eh_frame_section (); else - named_section_flags (DEBUG_FRAME_SECTION, SECTION_DEBUG); + switch_to_section (get_section (DEBUG_FRAME_SECTION, SECTION_DEBUG, NULL)); ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh); ASM_OUTPUT_LABEL (asm_out_file, section_start_label); @@ -2492,7 +2504,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED, return; #endif - function_section (current_function_decl); + switch_to_section (function_section (current_function_decl)); ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL, current_function_funcdef_no); ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL, @@ -4988,7 +5000,7 @@ AT_string_form (dw_attr_ref a) /* If we cannot expect the linker to merge strings in .debug_str section, only put it into .debug_str if it is worth even in this single module. */ - if ((DEBUG_STR_SECTION_FLAGS & SECTION_MERGE) == 0 + if ((debug_str_section->common.flags & SECTION_MERGE) == 0 && (len - DWARF_OFFSET_SIZE) * node->refcount <= len) return node->form = DW_FORM_string; @@ -7196,12 +7208,12 @@ output_comp_unit (dw_die_ref die, int output_if_empty) sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym); secname = tmp; die->die_symbol = NULL; + switch_to_section (get_section (secname, SECTION_DEBUG, NULL)); } else - secname = (const char *) DEBUG_INFO_SECTION; + switch_to_section (debug_info_section); /* Output debugging information. */ - named_section_flags (secname, SECTION_DEBUG); output_compilation_unit_header (); output_die (die); @@ -7828,10 +7840,7 @@ output_line_info (void) current_file = 1; current_line = 1; - if (cfun - && (last_text_section == in_unlikely_executed_text - || (last_text_section == in_named - && last_text_section_name == cfun->unlikely_text_section_name))) + if (cfun && unlikely_text_section_p (last_text_section)) strcpy (prev_line_label, cfun->cold_section_label); else strcpy (prev_line_label, text_section_label); @@ -10176,11 +10185,7 @@ secname_for_decl (tree decl) tree sectree = DECL_SECTION_NAME (current_function_decl); secname = TREE_STRING_POINTER (sectree); } - else if (cfun - && (last_text_section == in_unlikely_executed_text - || (last_text_section == in_named - && last_text_section_name - == cfun->unlikely_text_section_name))) + else if (cfun && unlikely_text_section_p (last_text_section)) secname = cfun->cold_section_label; else secname = text_section_label; @@ -13383,7 +13388,7 @@ static void dwarf2out_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int blocknum) { - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_BEGIN_LABEL, blocknum); } @@ -13393,7 +13398,7 @@ dwarf2out_begin_block (unsigned int line ATTRIBUTE_UNUSED, static void dwarf2out_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int blocknum) { - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); ASM_OUTPUT_DEBUG_LABEL (asm_out_file, BLOCK_END_LABEL, blocknum); } @@ -13550,10 +13555,7 @@ dwarf2out_var_location (rtx loc_note) newloc->var_loc_note = loc_note; newloc->next = NULL; - if (cfun - && (last_text_section == in_unlikely_executed_text - || (last_text_section == in_named - && last_text_section_name == cfun->unlikely_text_section_name))) + if (cfun && unlikely_text_section_p (last_text_section)) newloc->section_label = cfun->cold_section_label; else newloc->section_label = text_section_label; @@ -13588,7 +13590,7 @@ dwarf2out_source_line (unsigned int line, const char *filename) if (debug_info_level >= DINFO_LEVEL_NORMAL && line != 0) { - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); /* If requested, emit something human-readable. */ if (flag_debug_asm) @@ -13685,7 +13687,7 @@ dwarf2out_start_source_file (unsigned int lineno, const char *filename) { int fileno; - named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_macinfo_section); dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file"); dw2_asm_output_data_uleb128 (lineno, "Included from line number %d", lineno); @@ -13706,7 +13708,7 @@ dwarf2out_end_source_file (unsigned int lineno ATTRIBUTE_UNUSED) if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_macinfo_section); dw2_asm_output_data (1, DW_MACINFO_end_file, "End file"); } } @@ -13721,7 +13723,7 @@ dwarf2out_define (unsigned int lineno ATTRIBUTE_UNUSED, { if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_macinfo_section); 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"); @@ -13738,7 +13740,7 @@ dwarf2out_undef (unsigned int lineno ATTRIBUTE_UNUSED, { if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_macinfo_section); 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"); @@ -13790,6 +13792,25 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) used_rtx_array = VEC_alloc (rtx, gc, 32); + debug_info_section = get_section (DEBUG_INFO_SECTION, + SECTION_DEBUG, NULL); + debug_abbrev_section = get_section (DEBUG_ABBREV_SECTION, + SECTION_DEBUG, NULL); + debug_aranges_section = get_section (DEBUG_ARANGES_SECTION, + SECTION_DEBUG, NULL); + debug_macinfo_section = get_section (DEBUG_MACINFO_SECTION, + SECTION_DEBUG, NULL); + debug_line_section = get_section (DEBUG_LINE_SECTION, + SECTION_DEBUG, NULL); + debug_loc_section = get_section (DEBUG_LOC_SECTION, + SECTION_DEBUG, NULL); + debug_pubnames_section = get_section (DEBUG_PUBNAMES_SECTION, + SECTION_DEBUG, NULL); + debug_str_section = get_section (DEBUG_STR_SECTION, + DEBUG_STR_SECTION_FLAGS, NULL); + debug_ranges_section = get_section (DEBUG_RANGES_SECTION, + SECTION_DEBUG, NULL); + ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0); ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label, DEBUG_ABBREV_SECTION_LABEL, 0); @@ -13804,22 +13825,22 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED) DEBUG_LINE_SECTION_LABEL, 0); ASM_GENERATE_INTERNAL_LABEL (ranges_section_label, DEBUG_RANGES_SECTION_LABEL, 0); - named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG); + switch_to_section (debug_abbrev_section); ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label); - named_section_flags (DEBUG_INFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_info_section); ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label); - named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG); + switch_to_section (debug_line_section); ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label); if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_macinfo_section); ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label, DEBUG_MACINFO_SECTION_LABEL, 0); ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label); } - text_section (); + switch_to_section (text_section); ASM_OUTPUT_LABEL (asm_out_file, text_section_label); if (flag_reorder_blocks_and_partition) { @@ -13838,7 +13859,7 @@ output_indirect_string (void **h, void *v ATTRIBUTE_UNUSED) if (node->form == DW_FORM_strp) { - named_section_flags (DEBUG_STR_SECTION, DEBUG_STR_SECTION_FLAGS); + switch_to_section (debug_str_section); ASM_OUTPUT_LABEL (asm_out_file, node->label); assemble_string (node->str, strlen (node->str) + 1); } @@ -14155,7 +14176,7 @@ dwarf2out_finish (const char *filename) add_sibling_attributes (node->die); /* Output a terminator label for the .text section. */ - text_section (); + switch_to_section (text_section); targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0); if (flag_reorder_blocks_and_partition) { @@ -14170,7 +14191,7 @@ dwarf2out_finish (const char *filename) examining the file. */ if (! DWARF2_ASM_LINE_DEBUG_INFO) { - named_section_flags (DEBUG_LINE_SECTION, SECTION_DEBUG); + switch_to_section (debug_line_section); output_line_info (); } @@ -14178,7 +14199,7 @@ dwarf2out_finish (const char *filename) if (have_location_lists) { /* Output the location lists info. */ - named_section_flags (DEBUG_LOC_SECTION, SECTION_DEBUG); + switch_to_section (debug_loc_section); ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL, 0); ASM_OUTPUT_LABEL (asm_out_file, loc_section_label); @@ -14214,13 +14235,13 @@ dwarf2out_finish (const char *filename) output_comp_unit (comp_unit_die, 0); /* Output the abbreviation table. */ - named_section_flags (DEBUG_ABBREV_SECTION, SECTION_DEBUG); + switch_to_section (debug_abbrev_section); output_abbrev_section (); /* Output public names table if necessary. */ if (pubname_table_in_use) { - named_section_flags (DEBUG_PUBNAMES_SECTION, SECTION_DEBUG); + switch_to_section (debug_pubnames_section); output_pubnames (); } @@ -14228,14 +14249,14 @@ dwarf2out_finish (const char *filename) table, so don't write it out if we don't have any. */ if (fde_table_in_use) { - named_section_flags (DEBUG_ARANGES_SECTION, SECTION_DEBUG); + switch_to_section (debug_aranges_section); output_aranges (); } /* Output ranges section if necessary. */ if (ranges_table_in_use) { - named_section_flags (DEBUG_RANGES_SECTION, SECTION_DEBUG); + switch_to_section (debug_ranges_section); ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label); output_ranges (); } @@ -14243,7 +14264,7 @@ dwarf2out_finish (const char *filename) /* Have to end the macro section. */ if (debug_info_level >= DINFO_LEVEL_VERBOSE) { - named_section_flags (DEBUG_MACINFO_SECTION, SECTION_DEBUG); + switch_to_section (debug_macinfo_section); dw2_asm_output_data (1, 0, "End compilation unit"); } diff --git a/gcc/except.c b/gcc/except.c index 34dddfe..0ace54d 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -3425,10 +3425,9 @@ sjlj_output_call_site_table (void) call_site_base += n; } -/* Tell assembler to switch to the section for the exception handling - table. */ +/* Return the default value of exception_section. */ -void +section * default_exception_section (void) { if (targetm.have_named_sections) @@ -3446,12 +3445,10 @@ default_exception_section (void) } else flags = SECTION_WRITE; - named_section_flags (".gcc_except_table", flags); + return get_section (".gcc_except_table", flags, NULL); } - else if (flag_pic) - data_section (); else - readonly_data_section (); + return flag_pic ? data_section : readonly_data_section; } @@ -3533,7 +3530,7 @@ output_function_exception_table (void) /* Note that varasm still thinks we're in the function's code section. The ".endp" directive that will immediately follow will take us back. */ #else - targetm.asm_out.exception_section (); + switch_to_section (exception_section); #endif have_tt_data = (VEC_length (tree, cfun->eh->ttype_data) > 0 @@ -3687,7 +3684,7 @@ output_function_exception_table (void) (i ? NULL : "Exception specification table")); } - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); } void diff --git a/gcc/final.c b/gcc/final.c index ed1327d..7ccc8f5 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -114,12 +114,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #define JUMP_TABLES_IN_TEXT_SECTION 0 #endif -#if defined(READONLY_DATA_SECTION) || defined(READONLY_DATA_SECTION_ASM_OP) -#define HAVE_READONLY_DATA_SECTION 1 -#else -#define HAVE_READONLY_DATA_SECTION 0 -#endif - /* Bitflags used by final_scan_insn. */ #define SEEN_BB 1 #define SEEN_NOTE 2 @@ -887,7 +881,8 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) next = next_nonnote_insn (insn); /* ADDR_VECs only take room if read-only data goes into the text section. */ - if (JUMP_TABLES_IN_TEXT_SECTION || !HAVE_READONLY_DATA_SECTION) + if (JUMP_TABLES_IN_TEXT_SECTION + || readonly_data_section == text_section) if (next && JUMP_P (next)) { rtx nextbody = PATTERN (next); @@ -1050,7 +1045,8 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) { /* This only takes room if read-only data goes into the text section. */ - if (JUMP_TABLES_IN_TEXT_SECTION || !HAVE_READONLY_DATA_SECTION) + if (JUMP_TABLES_IN_TEXT_SECTION + || readonly_data_section == text_section) insn_lengths[uid] = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC) * GET_MODE_SIZE (GET_MODE (body))); @@ -1251,7 +1247,8 @@ shorten_branches (rtx first ATTRIBUTE_UNUSED) PUT_MODE (body, CASE_VECTOR_SHORTEN_MODE (min_addr - rel_addr, max_addr - rel_addr, body)); - if (JUMP_TABLES_IN_TEXT_SECTION || !HAVE_READONLY_DATA_SECTION) + if (JUMP_TABLES_IN_TEXT_SECTION + || readonly_data_section == text_section) { insn_lengths[uid] = (XVECLEN (body, 1) * GET_MODE_SIZE (GET_MODE (body))); @@ -1468,13 +1465,13 @@ profile_function (FILE *file ATTRIBUTE_UNUSED) if (! NO_PROFILE_COUNTERS) { int align = MIN (BIGGEST_ALIGNMENT, LONG_TYPE_SIZE); - data_section (); + switch_to_section (data_section); ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT)); targetm.asm_out.internal_label (file, "LP", current_function_funcdef_no); assemble_integer (const0_rtx, LONG_TYPE_SIZE / BITS_PER_UNIT, align, 1); } - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); #if defined(ASM_OUTPUT_REG_PUSH) if (sval && svrtx != NULL_RTX && REG_P (svrtx)) @@ -1717,15 +1714,15 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, not already writing to the cold section we need to change to it. */ - if (last_text_section == in_text) + if (last_text_section == text_section) { (*debug_hooks->switch_text_section) (); - unlikely_text_section (); + switch_to_section (unlikely_text_section ()); } else { (*debug_hooks->switch_text_section) (); - text_section (); + switch_to_section (text_section); } break; @@ -1939,7 +1936,8 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, { int log_align; - targetm.asm_out.function_rodata_section (current_function_decl); + switch_to_section (targetm.asm_out.function_rodata_section + (current_function_decl)); #ifdef ADDR_VEC_ALIGN log_align = ADDR_VEC_ALIGN (next); @@ -1949,7 +1947,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, ASM_OUTPUT_ALIGN (file, log_align); } else - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); #ifdef ASM_OUTPUT_CASE_LABEL ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn), @@ -2006,9 +2004,10 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, #endif if (! JUMP_TABLES_IN_TEXT_SECTION) - targetm.asm_out.function_rodata_section (current_function_decl); + switch_to_section (targetm.asm_out.function_rodata_section + (current_function_decl)); else - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); if (app_on) { @@ -2066,7 +2065,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, #endif #endif - current_function_section (current_function_decl); + switch_to_section (current_function_section ()); break; } diff --git a/gcc/gengtype.c b/gcc/gengtype.c index eb3c0c1..704f773 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -1080,7 +1080,7 @@ open_base_files (void) "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h", "tree-flow.h", "reload.h", "cpp-id-data.h", "tree-chrec.h", - "except.h", NULL + "except.h", "output.h", NULL }; const char *const *ifp; outf_p gtype_desc_c; diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 08075ac..cdcf6ee 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2005-12-07 Richard Sandiford + + * class.c (build_utf8_ref, emit_register_classes): Use + switch_to_section and get_section. + 2005-12-06 Tom Tromey PR java/25283: diff --git a/gcc/java/class.c b/gcc/java/class.c index 6f724f4..fbf5ed2 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -915,7 +915,7 @@ build_utf8_ref (tree name) int flags = (SECTION_OVERRIDE | SECTION_MERGE | (SECTION_ENTSIZE & decl_size)); sprintf (buf, ".rodata.jutf8.%d", decl_size); - named_section_flags (buf, flags); + switch_to_section (get_section (buf, flags, NULL)); DECL_SECTION_NAME (decl) = build_string (strlen (buf), buf); } } @@ -2434,7 +2434,7 @@ emit_register_classes (tree *list_p) int i; #ifdef JCR_SECTION_NAME - named_section_flags (JCR_SECTION_NAME, SECTION_WRITE); + switch_to_section (get_section (JCR_SECTION_NAME, SECTION_WRITE, NULL)); #else /* A target has defined TARGET_USE_JCR_SECTION, but doesn't have a JCR_SECTION_NAME. */ diff --git a/gcc/output.h b/gcc/output.h index 3cb091f..47989e9 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -153,77 +153,6 @@ extern int regno_clobbered_at_setjmp (int); /* Functions in varasm.c. */ -/* Tell assembler to switch to text section. */ -extern void text_section (void); - -/* Tell assembler to switch to unlikely-to-be-executed text section. */ -extern void unlikely_text_section (void); - -/* Tell assembler to switch to data section. */ -extern void data_section (void); - -/* Tell assembler to switch to read-only data section. This is normally - the text section. */ -extern void readonly_data_section (void); - -/* Determine if we're in the text section. */ -extern int in_text_section (void); - -/* Determine if we're in the unlikely-to-be-executed text section. */ -extern int in_unlikely_text_section (void); - -#ifdef CTORS_SECTION_ASM_OP -extern void ctors_section (void); -#endif - -#ifdef DTORS_SECTION_ASM_OP -extern void dtors_section (void); -#endif - -#ifdef BSS_SECTION_ASM_OP -extern void bss_section (void); -#endif - -#ifdef INIT_SECTION_ASM_OP -extern void init_section (void); -#endif - -#ifdef FINI_SECTION_ASM_OP -extern void fini_section (void); -#endif - -#ifdef EXPORTS_SECTION_ASM_OP -extern void exports_section (void); -#endif - -#ifdef DRECTVE_SECTION_ASM_OP -extern void drectve_section (void); -#endif - -#ifdef SDATA_SECTION_ASM_OP -extern void sdata_section (void); -#endif - -/* 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. - If RELOC is 1, the initializer for DECL contains relocs. */ -extern void named_section (tree, const char *, int); - -/* Tell assembler to switch to the section for function DECL. */ -extern void function_section (tree); - -/* Tell assembler to switch to the most recently used text section. */ -extern void current_function_section (tree); - -/* Tell assembler to switch to the section for string merging. */ -extern void mergeable_string_section (tree, unsigned HOST_WIDE_INT, - unsigned int); - -/* Tell assembler to switch to the section for constant merging. */ -extern void mergeable_constant_section (enum machine_mode, - unsigned HOST_WIDE_INT, unsigned int); - /* Declare DECL to be a weak symbol. */ extern void declare_weak (tree); /* Merge weak status. */ @@ -438,27 +367,6 @@ extern rtx this_is_asm_operands; extern int size_directive_output; extern tree last_assemble_variable_decl; -enum in_section { no_section, in_text, in_unlikely_executed_text, in_data, - in_named -#ifdef BSS_SECTION_ASM_OP - , in_bss -#endif -#ifdef CTORS_SECTION_ASM_OP - , in_ctors -#endif -#ifdef DTORS_SECTION_ASM_OP - , in_dtors -#endif -#ifdef READONLY_DATA_SECTION_ASM_OP - , in_readonly_data -#endif -#ifdef EXTRA_SECTIONS - , EXTRA_SECTIONS -#endif -}; - -extern const char *last_text_section_name; -extern enum in_section last_text_section; extern bool first_function_block_is_cold; /* Decide whether DECL needs to be in a writable section. @@ -476,13 +384,11 @@ extern const char *user_label_prefix; /* Default target function prologue and epilogue assembler output. */ extern void default_function_pro_epilogue (FILE *, HOST_WIDE_INT); -/* Tell assembler to switch to the section for the exception table. */ -extern void default_exception_section (void); +/* Return the default value of exception_section. */ +extern section *default_exception_section (void); -/* Tell assembler to switch to the section for the EH frames. */ -extern void named_section_eh_frame_section (void); -extern void collect2_eh_frame_section (void); -extern void default_eh_frame_section (void); +/* Return the default value of eh_frame_section. */ +extern section *default_eh_frame_section (void); /* Default target hook that outputs nothing to a stream. */ extern void no_asm_to_stream (FILE *); @@ -502,7 +408,9 @@ extern void no_asm_to_stream (FILE *); #define SECTION_OVERRIDE 0x20000 /* allow override of default flags */ #define SECTION_TLS 0x40000 /* contains thread-local storage */ #define SECTION_NOTYPE 0x80000 /* don't output @progbits */ -#define SECTION_MACH_DEP 0x100000 /* subsequent bits reserved for target */ +#define SECTION_DECLARED 0x100000 /* section has been used */ +#define SECTION_NAMED 0x200000 /* section has a name */ +#define SECTION_MACH_DEP 0x400000 /* subsequent bits reserved for target */ /* A helper function for default_elf_select_section and default_elf_unique_section. Categorizes the DECL. */ @@ -541,12 +449,81 @@ enum section_category SECCAT_TBSS }; +/* Information that is provided by all instances of the section type. */ +struct section_common GTY(()) { + /* The set of SECTION_* flags that apply to this section. */ + unsigned int flags; +}; + +/* Information that is provided by named sections. */ +struct named_section GTY(()) { + struct section_common common; + + /* The name of the section. */ + const char *name; + + /* If nonnull, the VAR_DECL or FUNCTION_DECL with which the + section is associated. */ + tree decl; +}; + +/* A callback that writes the assembly code for switching to an unnamed + section. The argument provides callback-specific data. */ +typedef void (*unnamed_section_callback) (const void *); + +/* Information that is provided by unnamed sections. */ +struct unnamed_section GTY(()) { + struct section_common common; + + /* The callback used to switch to the section, and the data that + should be passed to the callback. */ + unnamed_section_callback GTY ((skip)) callback; + const void *GTY ((skip)) data; + + /* The next entry in the chain of unnamed sections. */ + section *next; +}; + +/* Information about a section, which may be named or unnamed. */ +union section GTY ((desc ("(%h).common.flags & SECTION_NAMED"))) +{ + struct section_common GTY ((skip)) common; + struct named_section GTY ((tag ("SECTION_NAMED"))) named; + struct unnamed_section GTY ((tag ("0"))) unnamed; +}; + +/* Special well-known sections. */ +extern GTY(()) section *text_section; +extern GTY(()) section *data_section; +extern GTY(()) section *readonly_data_section; +extern GTY(()) section *sdata_section; +extern GTY(()) section *ctors_section; +extern GTY(()) section *dtors_section; +extern GTY(()) section *bss_section; +extern GTY(()) section *sbss_section; +extern GTY(()) section *init_section; +extern GTY(()) section *fini_section; +extern GTY(()) section *exception_section; +extern GTY(()) section *eh_frame_section; + +extern GTY(()) section *in_section; +extern GTY(()) section *last_text_section; + +extern section *get_unnamed_section (unsigned int, void (*) (const void *), + const void *); +extern section *get_section (const char *, unsigned int, tree); +extern section *get_named_section (tree, const char *, int); +extern section *mergeable_constant_section (enum machine_mode, + unsigned HOST_WIDE_INT, + unsigned int); +extern section *function_section (tree); +extern section *unlikely_text_section (void); +extern section *current_function_section (void); + +extern bool unlikely_text_section_p (section *); +extern void switch_to_section (section *); +extern void output_section_asm_op (const void *); -extern bool set_named_section_flags (const char *, unsigned int); -#define named_section_flags(NAME, FLAGS) \ - named_section_real((NAME), (FLAGS), /*decl=*/NULL_TREE) -extern void named_section_real (const char *, unsigned int, tree); -extern bool named_section_first_declaration (const char *); extern unsigned int default_section_type_flags (tree, const char *, int); extern unsigned int default_section_type_flags_1 (tree, const char *, int, int); @@ -563,18 +540,21 @@ extern void default_stabs_asm_out_constructor (rtx, int); extern void default_named_section_asm_out_constructor (rtx, int); extern void default_ctor_section_asm_out_constructor (rtx, int); -extern void default_select_section (tree, int, unsigned HOST_WIDE_INT); -extern void default_elf_select_section (tree, int, unsigned HOST_WIDE_INT); -extern void default_elf_select_section_1 (tree, int, - unsigned HOST_WIDE_INT, int); +extern section *default_select_section (tree, int, + unsigned HOST_WIDE_INT); +extern section *default_elf_select_section (tree, int, + unsigned HOST_WIDE_INT); +extern section *default_elf_select_section_1 (tree, int, + unsigned HOST_WIDE_INT, + int); extern void default_unique_section (tree, int); extern void default_unique_section_1 (tree, int, int); -extern void default_function_rodata_section (tree); -extern void default_no_function_rodata_section (tree); -extern void default_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); -extern void default_elf_select_rtx_section (enum machine_mode, rtx, +extern section *default_function_rodata_section (tree); +extern section *default_no_function_rodata_section (tree); +extern section *default_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT); +extern section *default_elf_select_rtx_section (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); extern void default_encode_section_info (tree, rtx, int); extern const char *default_strip_name_encoding (const char *); extern bool default_binds_local_p (tree); diff --git a/gcc/rtl.h b/gcc/rtl.h index ceb2394..9ac8a88 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2114,7 +2114,6 @@ extern rtx emit_library_call_value (rtx, rtx, enum libcall_type, enum machine_mode, int, ...); /* In varasm.c */ -extern int in_data_section (void); extern void init_varasm_once (void); extern enum tls_model decl_default_tls_model (tree); diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 8dd6026..1868a81 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -1050,7 +1050,7 @@ sdbout_one_type (tree type) && DECL_SECTION_NAME (current_function_decl) != NULL_TREE) ; /* Don't change section amid function. */ else - text_section (); + switch_to_section (text_section); switch (TREE_CODE (type)) { diff --git a/gcc/system.h b/gcc/system.h index 34c9009..65d6e04 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -728,7 +728,9 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT \ LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE \ TARGET_OPTIONS TARGET_SWITCHES EXTRA_CC_MODES FINALIZE_PIC \ - PREDICATE_CODES SPECIAL_MODE_PREDICATES HOST_PTR_PRINTF + PREDICATE_CODES SPECIAL_MODE_PREDICATES HOST_PTR_PRINTF \ + EXTRA_SECTIONS EXTRA_SECTION_FUNCTIONS READONLY_DATA_SECTION \ + TARGET_ASM_EXCEPTION_SECTION TARGET_ASM_EH_FRAME_SECTION /* Hooks that are no longer used. */ #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \ diff --git a/gcc/target-def.h b/gcc/target-def.h index 90dc55c..c15c798 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -136,6 +136,10 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # endif #endif +#ifndef TARGET_ASM_INIT_SECTIONS +#define TARGET_ASM_INIT_SECTIONS hook_void_void +#endif + #ifdef TARGET_ASM_NAMED_SECTION #define TARGET_HAVE_NAMED_SECTIONS true #else @@ -169,14 +173,6 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define TARGET_DWARF_REGISTER_SPAN hook_rtx_rtx_null -#ifndef TARGET_ASM_EXCEPTION_SECTION -#define TARGET_ASM_EXCEPTION_SECTION default_exception_section -#endif - -#ifndef TARGET_ASM_EH_FRAME_SECTION -#define TARGET_ASM_EH_FRAME_SECTION default_eh_frame_section -#endif - #ifndef TARGET_ASM_FILE_START #define TARGET_ASM_FILE_START default_file_start #endif @@ -233,9 +229,8 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. TARGET_ASM_FUNCTION_END_PROLOGUE, \ TARGET_ASM_FUNCTION_BEGIN_EPILOGUE, \ TARGET_ASM_FUNCTION_EPILOGUE, \ + TARGET_ASM_INIT_SECTIONS, \ TARGET_ASM_NAMED_SECTION, \ - TARGET_ASM_EXCEPTION_SECTION, \ - TARGET_ASM_EH_FRAME_SECTION, \ TARGET_ASM_SELECT_SECTION, \ TARGET_ASM_SELECT_RTX_SECTION, \ TARGET_ASM_UNIQUE_SECTION, \ diff --git a/gcc/target.h b/gcc/target.h index 8d679d3..96dc425 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -127,35 +127,31 @@ struct gcc_target /* Output the assembler code for function exit. */ void (* function_epilogue) (FILE *, HOST_WIDE_INT); + /* Initialize target-specific sections. */ + void (* init_sections) (void); + /* Tell assembler to change to section NAME with attributes FLAGS. If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with which this section is associated. */ void (* named_section) (const char *name, unsigned int flags, tree decl); - /* Switch to the section that holds the exception table. */ - void (* exception_section) (void); - - /* Switch to the section that holds the exception frames. */ - void (* eh_frame_section) (void); - - /* Select and switch to a section for EXP. It may be a DECL or a - constant. RELOC is nonzero if runtime relocations must be applied; - bit 1 will be set if the runtime relocations require non-local - name resolution. ALIGN is the required alignment of the data. */ - void (* select_section) (tree, int, unsigned HOST_WIDE_INT); + /* Return a section for EXP. It may be a DECL or a constant. RELOC + is nonzero if runtime relocations must be applied; bit 1 will be + set if the runtime relocations require non-local name resolution. + ALIGN is the required alignment of the data. */ + section *(* select_section) (tree, int, unsigned HOST_WIDE_INT); - /* Select and switch to a section for X with MODE. ALIGN is - the desired alignment of the data. */ - void (* select_rtx_section) (enum machine_mode, rtx, - unsigned HOST_WIDE_INT); + /* Return a section for X. MODE is X's mode and ALIGN is its + alignment in bits. */ + section *(* select_rtx_section) (enum machine_mode, rtx, + unsigned HOST_WIDE_INT); /* Select a unique section name for DECL. RELOC is the same as for SELECT_SECTION. */ void (* unique_section) (tree, int); - /* Tell assembler to switch to the readonly data section associated - with function DECL. */ - void (* function_rodata_section) (tree); + /* Return the readonly data section associated with function DECL. */ + section *(* function_rodata_section) (tree); /* Output a constructor for a symbol with a given priority. */ void (* constructor) (rtx, int); diff --git a/gcc/varasm.c b/gcc/varasm.c index 5e59f3a..4285d15 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -127,9 +127,6 @@ static unsigned min_align (unsigned, unsigned); static void output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int); static void globalize_decl (tree); static void maybe_assemble_visibility (tree); -static int in_named_entry_eq (const void *, const void *); -static hashval_t in_named_entry_hash (const void *); -static void initialize_cold_section_name (void); #ifdef BSS_SECTION_ASM_OP #ifdef ASM_OUTPUT_BSS static void asm_output_bss (FILE *, tree, const char *, @@ -146,8 +143,35 @@ static bool asm_emit_uninitialised (tree, const char*, unsigned HOST_WIDE_INT); static void mark_weak (tree); -static GTY(()) enum in_section in_section = no_section; -enum in_section last_text_section; +/* Well-known sections, each one associated with some sort of *_ASM_OP. */ +section *text_section; +section *data_section; +section *readonly_data_section; +section *sdata_section; +section *ctors_section; +section *dtors_section; +section *bss_section; +section *sbss_section; +section *init_section; +section *fini_section; + +/* The section that holds the main exception table. */ +section *exception_section; + +/* The section that holds the DWARF2 frame unwind information. If it + is null, we will place the unwind information in the data section + and emit special labels to guide collect2. */ +section *eh_frame_section; + +/* asm_out_file's current section. This is NULL if no section has yet + been selected or if we lose track of what the current section is. */ +section *in_section; + +/* The last text section used by asm_out_file. */ +section *last_text_section; + +/* A linked list of all the unnamed sections. */ +static GTY(()) section *unnamed_sections; /* Return a nonzero value if DECL has a section attribute. */ #ifndef IN_NAMED_SECTION @@ -156,25 +180,81 @@ enum in_section last_text_section; && DECL_SECTION_NAME (DECL) != NULL_TREE) #endif -/* Text of section name when in_section == in_named. */ -static GTY(()) const char *in_named_name; -const char *last_text_section_name; +/* Hash table of named sections. */ +static GTY((param_is (section))) htab_t section_htab; -/* Hash table of flags that have been used for a particular named section. */ +/* Helper routines for maintaining section_htab. */ -struct in_named_entry GTY(()) +static int +section_entry_eq (const void *p1, const void *p2) { - const char *name; - unsigned int flags; - bool declared; -}; + const section *old = p1; + const char *new = p2; -static GTY((param_is (struct in_named_entry))) htab_t in_named_htab; + return strcmp (old->named.name, new) == 0; +} -/* Define functions like text_section for any extra sections. */ -#ifdef EXTRA_SECTION_FUNCTIONS -EXTRA_SECTION_FUNCTIONS -#endif +static hashval_t +section_entry_hash (const void *p) +{ + const section *old = p; + return htab_hash_string (old->named.name); +} + +/* Return a new unnamed section with the given fields. */ + +section * +get_unnamed_section (unsigned int flags, void (*callback) (const void *), + const void *data) +{ + section *sect; + + sect = ggc_alloc (sizeof (struct unnamed_section)); + sect->unnamed.common.flags = flags; + sect->unnamed.callback = callback; + sect->unnamed.data = data; + sect->unnamed.next = unnamed_sections; + + unnamed_sections = sect; + return sect; +} + +/* Return the named section structure associated with NAME. Create + a new section with the given fields if no such structure exists. */ + +section * +get_section (const char *name, unsigned int flags, tree decl) +{ + section *sect, **slot; + + slot = (section **) + htab_find_slot_with_hash (section_htab, name, + htab_hash_string (name), INSERT); + if (*slot == NULL) + { + sect = ggc_alloc (sizeof (struct named_section)); + sect->named.common.flags = flags | SECTION_NAMED; + sect->named.name = ggc_strdup (name); + sect->named.decl = decl; + *slot = sect; + } + else + { + sect = *slot; + if ((sect->common.flags & ~(SECTION_DECLARED | SECTION_NAMED)) != flags + && ((sect->common.flags | flags) & SECTION_OVERRIDE) == 0) + { + /* Sanity check user variables for flag changes. */ + if (decl == 0) + decl = sect->named.decl; + if (decl) + error ("%+D causes a section type conflict", decl); + else + gcc_unreachable (); + } + } + return sect; +} static void initialize_cold_section_name (void) @@ -202,22 +282,9 @@ initialize_cold_section_name (void) cfun->unlikely_text_section_name = UNLIKELY_EXECUTED_TEXT_SECTION_NAME; } -/* Tell assembler to switch to text section. */ - -void -text_section (void) -{ - if (in_section != in_text) - { - in_section = in_text; - last_text_section = in_text; - fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP); - } -} - /* Tell assembler to switch to unlikely-to-be-executed text section. */ -void +section * unlikely_text_section (void) { if (cfun) @@ -225,225 +292,42 @@ unlikely_text_section (void) if (!cfun->unlikely_text_section_name) initialize_cold_section_name (); - if (flag_function_sections - || ((in_section != in_unlikely_executed_text) - && (in_section != in_named - || (strcmp (in_named_name, cfun->unlikely_text_section_name) - != 0)))) - { - named_section (NULL_TREE, cfun->unlikely_text_section_name, 0); - in_section = in_unlikely_executed_text; - last_text_section = in_unlikely_executed_text; - } - } - else - { - named_section (NULL_TREE, UNLIKELY_EXECUTED_TEXT_SECTION_NAME, 0); - in_section = in_unlikely_executed_text; - last_text_section = in_unlikely_executed_text; - } -} - -/* Tell assembler to switch to data section. */ - -void -data_section (void) -{ - if (in_section != in_data) - { - in_section = in_data; - fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP); - } -} - -/* Tell assembler to switch to read-only data section. This is normally - the text section. */ - -void -readonly_data_section (void) -{ -#ifdef READONLY_DATA_SECTION - READONLY_DATA_SECTION (); /* Note this can call data_section. */ -#else -#ifdef READONLY_DATA_SECTION_ASM_OP - if (in_section != in_readonly_data) - { - in_section = in_readonly_data; - fputs (READONLY_DATA_SECTION_ASM_OP, asm_out_file); - fputc ('\n', asm_out_file); - } -#else - text_section (); -#endif -#endif -} - -/* Determine if we're in the text section. */ - -int -in_text_section (void) -{ - return in_section == in_text; -} - -/* Determine if we're in the unlikely-to-be-executed text section. */ - -int -in_unlikely_text_section (void) -{ - bool ret_val; - - if (cfun) - { - ret_val = ((in_section == in_unlikely_executed_text) - || (in_section == in_named - && cfun->unlikely_text_section_name - && strcmp (in_named_name, - cfun->unlikely_text_section_name) == 0)); + return get_named_section (NULL, cfun->unlikely_text_section_name, 0); } else - { - ret_val = ((in_section == in_unlikely_executed_text) - || (in_section == in_named - && strcmp (in_named_name, - UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0)); - } - - return ret_val; -} - -/* Determine if we're in the data section. */ - -int -in_data_section (void) -{ - return in_section == in_data; + return get_named_section (NULL, UNLIKELY_EXECUTED_TEXT_SECTION_NAME, 0); } -/* Helper routines for maintaining in_named_htab. */ - -static int -in_named_entry_eq (const void *p1, const void *p2) -{ - const struct in_named_entry *old = p1; - const char *new = p2; - - return strcmp (old->name, new) == 0; -} - -static hashval_t -in_named_entry_hash (const void *p) -{ - const struct in_named_entry *old = p; - return htab_hash_string (old->name); -} - -/* If SECTION has been seen before as a named section, return the flags - that were used. Otherwise, return 0. Note, that 0 is a perfectly valid - set of flags for a section to have, so 0 does not mean that the section - has not been seen. */ - -static unsigned int -get_named_section_flags (const char *section) -{ - struct in_named_entry **slot; - - slot = (struct in_named_entry **) - htab_find_slot_with_hash (in_named_htab, section, - htab_hash_string (section), NO_INSERT); - - return slot ? (*slot)->flags : 0; -} - -/* Returns true if the section has been declared before. Sets internal - flag on this section in in_named_hash so subsequent calls on this - section will return false. */ +/* When called within a function context, return true if the function + has been assigned a cold text section and if SECT is that section. + When called outside a function context, return true if SECT is the + default cold section. */ bool -named_section_first_declaration (const char *name) +unlikely_text_section_p (section *sect) { - struct in_named_entry **slot; + const char *name; - slot = (struct in_named_entry **) - htab_find_slot_with_hash (in_named_htab, name, - htab_hash_string (name), NO_INSERT); - if (! (*slot)->declared) - { - (*slot)->declared = true; - return true; - } + if (cfun) + name = cfun->unlikely_text_section_name; else - { - return false; - } -} - - -/* Record FLAGS for SECTION. If SECTION was previously recorded with a - different set of flags, return false. */ - -bool -set_named_section_flags (const char *section, unsigned int flags) -{ - struct in_named_entry **slot, *entry; + name = UNLIKELY_EXECUTED_TEXT_SECTION_NAME; - slot = (struct in_named_entry **) - htab_find_slot_with_hash (in_named_htab, section, - htab_hash_string (section), INSERT); - entry = *slot; - - if (!entry) - { - entry = ggc_alloc (sizeof (*entry)); - *slot = entry; - entry->name = ggc_strdup (section); - entry->flags = flags; - entry->declared = false; - } - else if (entry->flags != flags) - return false; - - return true; + return (name + && sect + && (sect->common.flags & SECTION_NAMED) != 0 + && strcmp (name, sect->named.name) == 0); } -/* Tell assembler to change to section NAME with attributes FLAGS. If - DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with which - this section is associated. */ +/* Return a section with a particular name and with whatever SECTION_* + flags section_type_flags deems appropriate. The name of the section + is taken from NAME if nonnull, otherwise it is taken from DECL's + DECL_SECTION_NAME. DECL is the decl associated with the section + (see the section comment for details) and RELOC is as for + section_type_flags. */ -void -named_section_real (const char *name, unsigned int flags, tree decl) -{ - if (in_section != in_named || strcmp (name, in_named_name) != 0) - { - bool unchanged = set_named_section_flags (name, flags); - - gcc_assert (unchanged); - - targetm.asm_out.named_section (name, flags, decl); - - if (flags & SECTION_FORGET) - in_section = no_section; - else - { - in_named_name = ggc_strdup (name); - in_section = in_named; - } - } - - if (in_text_section () || in_unlikely_text_section ()) - { - last_text_section = in_section; - last_text_section_name = name; - } -} - -/* 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. - If RELOC is 1, the initializer for DECL contains relocs. */ - -void -named_section (tree decl, const char *name, int reloc) +section * +get_named_section (tree decl, const char *name, int reloc) { unsigned int flags; @@ -451,26 +335,9 @@ named_section (tree decl, const char *name, int reloc) if (name == NULL) name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); - if (strcmp (name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0 - && cfun - && ! cfun->unlikely_text_section_name) - cfun->unlikely_text_section_name = UNLIKELY_EXECUTED_TEXT_SECTION_NAME; - flags = targetm.section_type_flags (decl, name, reloc); - /* Sanity check user variables for flag changes. Non-user - section flag changes will die in named_section_flags. - However, don't complain if SECTION_OVERRIDE is set. - We trust that the setter knows that it is safe to ignore - the default flags for this decl. */ - if (decl && ! set_named_section_flags (name, flags)) - { - flags = get_named_section_flags (name); - if ((flags & SECTION_OVERRIDE) == 0) - error ("%+D causes a section type conflict", decl); - } - - named_section_real (name, flags, decl); + return get_section (name, flags, decl); } /* If required, set DECL_SECTION_NAME to a unique name. */ @@ -488,18 +355,6 @@ resolve_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED, #ifdef BSS_SECTION_ASM_OP -/* Tell the assembler to switch to the bss section. */ - -void -bss_section (void) -{ - if (in_section != in_bss) - { - fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP); - in_section = in_bss; - } -} - #ifdef ASM_OUTPUT_BSS /* Utility function for ASM_OUTPUT_BSS for targets to use if @@ -514,7 +369,7 @@ asm_output_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT rounded) { targetm.asm_out.globalize_label (file, name); - bss_section (); + switch_to_section (bss_section); #ifdef ASM_DECLARE_OBJECT_NAME last_assemble_variable_decl = decl; ASM_DECLARE_OBJECT_NAME (file, name, decl); @@ -539,7 +394,7 @@ asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, const char *name, unsigned HOST_WIDE_INT size, int align) { - bss_section (); + switch_to_section (bss_section); ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT)); #ifdef ASM_DECLARE_OBJECT_NAME last_assemble_variable_decl = decl; @@ -555,12 +410,12 @@ asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED, #endif /* BSS_SECTION_ASM_OP */ -/* Switch to the section for function DECL. +/* Return the section for function DECL. - If DECL is NULL_TREE, switch to the text section. We can be passed + If DECL is NULL_TREE, return the text section. We can be passed NULL_TREE under some circumstances by dbxout.c at least. */ -void +section * function_section (tree decl) { int reloc = 0; @@ -569,44 +424,38 @@ function_section (tree decl) reloc = 1; #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS - targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl)); + return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl)); #else if (decl != NULL_TREE && DECL_SECTION_NAME (decl) != NULL_TREE && targetm.have_named_sections) - named_section (decl, (char *) 0, 0); + return get_named_section (decl, NULL, 0); else - text_section (); + return text_section; #endif } -void -current_function_section (tree decl) +section * +current_function_section (void) { #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS int reloc = 0; - if (in_unlikely_text_section () - || last_text_section == in_unlikely_executed_text) + if (unlikely_text_section_p (last_text_section)) reloc = 1; - targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl)); + return targetm.asm_out.select_section (current_function_decl, reloc, + DECL_ALIGN (current_function_decl)); #else - if (last_text_section == in_unlikely_executed_text) - unlikely_text_section (); - else if (last_text_section == in_text) - text_section (); - else if (last_text_section == in_named - && targetm.have_named_sections) - named_section (NULL_TREE, last_text_section_name, 0); - else - function_section (decl); + if (last_text_section) + return last_text_section; + return function_section (current_function_decl); #endif } -/* Switch to read-only data section associated with function DECL. */ +/* Return the read-only data section associated with function DECL. */ -void +section * default_function_rodata_section (tree decl) { if (decl != NULL_TREE && DECL_SECTION_NAME (decl)) @@ -619,9 +468,8 @@ default_function_rodata_section (tree decl) char* rname = alloca (len); strcpy (rname, ".rodata"); - strcat (rname, name + 5); - named_section_real (rname, SECTION_LINKONCE, decl); - return; + strcat (rname, name + 5); + return get_section (rname, SECTION_LINKONCE, decl); } /* For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo. */ else if (DECL_ONE_ONLY (decl) @@ -632,8 +480,7 @@ default_function_rodata_section (tree decl) memcpy (rname, name, len); rname[14] = 'r'; - named_section_real (rname, SECTION_LINKONCE, decl); - return; + return get_section (rname, SECTION_LINKONCE, decl); } /* For .text.foo we want to use .rodata.foo. */ else if (flag_function_sections && flag_data_sections @@ -644,22 +491,21 @@ default_function_rodata_section (tree decl) memcpy (rname, ".rodata", 7); memcpy (rname + 7, name + 5, len - 5); - named_section_flags (rname, 0); - return; + return get_section (rname, 0, decl); } } - readonly_data_section (); + return readonly_data_section; } -/* Switch to read-only data section associated with function DECL +/* Return the read-only data section associated with function DECL for targets where that section should be always the single readonly data section. */ -void +section * default_no_function_rodata_section (tree decl ATTRIBUTE_UNUSED) { - readonly_data_section (); + return readonly_data_section; } /* Switch to section for variable DECL. RELOC is the same as the @@ -669,14 +515,15 @@ void variable_section (tree decl, int reloc) { if (IN_NAMED_SECTION (decl)) - named_section (decl, NULL, reloc); + switch_to_section (get_named_section (decl, NULL, reloc)); else - targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl)); + switch_to_section (targetm.asm_out.select_section (decl, reloc, + DECL_ALIGN (decl))); } -/* Tell assembler to switch to the section for string merging. */ +/* Return the section to use for string merging. */ -void +static section * mergeable_string_section (tree decl ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED, unsigned int flags ATTRIBUTE_UNUSED) @@ -719,37 +566,17 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED, sprintf (name, ".rodata.str%d.%d", modesize / 8, (int) (align / 8)); flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS; - if (!i && modesize < align) - { - /* A "" string with requested alignment greater than - character size might cause a problem: - if some other string required even bigger - alignment than "", then linker might think the - "" is just part of padding after some other string - and not put it into the hash table initially. - But this means "" could have smaller alignment - than requested. */ -#ifdef ASM_OUTPUT_SECTION_START - named_section_flags (name, flags); - ASM_OUTPUT_SECTION_START (asm_out_file); -#else - readonly_data_section (); -#endif - return; - } - - named_section_flags (name, flags); - return; + return get_section (name, flags, NULL); } } } - readonly_data_section (); + return readonly_data_section; } -/* Tell assembler to switch to the section for constant merging. */ +/* Return the section to use for constant merging. */ -void +section * mergeable_constant_section (enum machine_mode mode ATTRIBUTE_UNUSED, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED, unsigned int flags ATTRIBUTE_UNUSED) @@ -768,11 +595,9 @@ mergeable_constant_section (enum machine_mode mode ATTRIBUTE_UNUSED, sprintf (name, ".rodata.cst%d", (int) (align / 8)); flags |= (align / 8) | SECTION_MERGE; - named_section_flags (name, flags); - return; + return get_section (name, flags, NULL); } - - readonly_data_section (); + return readonly_data_section; } /* Given NAME, a putative register name, discard any customary prefixes. */ @@ -1092,28 +917,17 @@ default_named_section_asm_out_destructor (rtx symbol, int priority) section = buf; } - named_section_flags (section, SECTION_WRITE); + switch_to_section (get_section (section, SECTION_WRITE, NULL)); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } #ifdef DTORS_SECTION_ASM_OP void -dtors_section (void) -{ - if (in_section != in_dtors) - { - in_section = in_dtors; - fputs (DTORS_SECTION_ASM_OP, asm_out_file); - fputc ('\n', asm_out_file); - } -} - -void default_dtor_section_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - dtors_section (); + switch_to_section (dtors_section); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } @@ -1153,28 +967,17 @@ default_named_section_asm_out_constructor (rtx symbol, int priority) section = buf; } - named_section_flags (section, SECTION_WRITE); + switch_to_section (get_section (section, SECTION_WRITE, NULL)); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } #ifdef CTORS_SECTION_ASM_OP void -ctors_section (void) -{ - if (in_section != in_ctors) - { - in_section = in_ctors; - fputs (CTORS_SECTION_ASM_OP, asm_out_file); - fputc ('\n', asm_out_file); - } -} - -void default_ctor_section_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED) { - ctors_section (); + switch_to_section (ctors_section); assemble_align (POINTER_SIZE); assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); } @@ -1289,7 +1092,7 @@ assemble_start_function (tree decl, const char *fnname) if (!current_function_is_thunk && BB_PARTITION (ENTRY_BLOCK_PTR->next_bb) == BB_COLD_PARTITION) { - text_section (); + switch_to_section (text_section); assemble_align (FUNCTION_BOUNDARY); ASM_OUTPUT_LABEL (asm_out_file, cfun->hot_section_label); hot_label_written = true; @@ -1311,11 +1114,11 @@ assemble_start_function (tree decl, const char *fnname) first_function_block_is_cold = true; } - last_text_section = no_section; + last_text_section = NULL; /* Switch to the correct text section for the start of the function. */ - function_section (decl); + switch_to_section (function_section (decl)); if (flag_reorder_blocks_and_partition && !hot_label_written) ASM_OUTPUT_LABEL (asm_out_file, cfun->hot_section_label); @@ -1381,30 +1184,29 @@ assemble_end_function (tree decl, const char *fnname) #ifdef ASM_DECLARE_FUNCTION_SIZE /* We could have switched section in the middle of the function. */ if (flag_reorder_blocks_and_partition) - function_section (decl); + switch_to_section (function_section (decl)); ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl); #endif if (! CONSTANT_POOL_BEFORE_FUNCTION) { output_constant_pool (fnname, decl); - function_section (decl); /* need to switch back */ + switch_to_section (function_section (decl)); /* need to switch back */ } /* Output labels for end of hot/cold text sections (to be used by debug info.) */ if (flag_reorder_blocks_and_partition) { - enum in_section save_text_section; + section *save_text_section; save_text_section = in_section; unlikely_text_section (); ASM_OUTPUT_LABEL (asm_out_file, cfun->cold_section_end_label); if (first_function_block_is_cold) - text_section (); + switch_to_section (text_section); else - function_section (decl); + switch_to_section (function_section (decl)); ASM_OUTPUT_LABEL (asm_out_file, cfun->hot_section_end_label); - if (save_text_section == in_unlikely_executed_text) - unlikely_text_section (); + switch_to_section (save_text_section); } } @@ -1420,8 +1222,7 @@ assemble_zeros (unsigned HOST_WIDE_INT size) #ifdef ASM_NO_SKIP_IN_TEXT /* The `space' pseudo in the text section outputs nop insns rather than 0s, so we must output 0s explicitly in the text section. */ - if ((ASM_NO_SKIP_IN_TEXT && in_text_section ()) - || (ASM_NO_SKIP_IN_TEXT && in_unlikely_text_section ())) + if (ASM_NO_SKIP_IN_TEXT && (in_section->common.flags & SECTION_CODE) != 0) { unsigned HOST_WIDE_INT i; for (i = 0; i < size; i++) @@ -1790,7 +1591,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, variable_section (decl, reloc); /* dbxout.c needs to know this. */ - if (in_text_section () || in_unlikely_text_section ()) + if (in_section && (in_section->common.flags & SECTION_CODE) != 0) DECL_IN_TEXT_SECTION (decl) = 1; /* Output the alignment of this data. */ @@ -2075,7 +1876,7 @@ assemble_static_space (unsigned HOST_WIDE_INT size) #if 0 if (flag_shared_data) - data_section (); + switch_to_section (data_section); #endif ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno); @@ -2128,9 +1929,9 @@ assemble_trampoline_template (void) /* By default, put trampoline templates in read-only data section. */ #ifdef TRAMPOLINE_SECTION - TRAMPOLINE_SECTION (); + switch_to_section (TRAMPOLINE_SECTION); #else - readonly_data_section (); + switch_to_section (readonly_data_section); #endif /* Write the assembler code to define one. */ @@ -2873,9 +2674,9 @@ output_constant_def_contents (rtx symbol) TREE_ASM_WRITTEN (exp) = 1; if (IN_NAMED_SECTION (exp)) - named_section (exp, NULL, reloc); + switch_to_section (get_named_section (exp, NULL, reloc)); else - targetm.asm_out.select_section (exp, reloc, align); + switch_to_section (targetm.asm_out.select_section (exp, reloc, align)); if (align > BITS_PER_UNIT) { @@ -3346,7 +3147,8 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc) } /* First switch to correct section. */ - targetm.asm_out.select_rtx_section (desc->mode, x, desc->align); + switch_to_section (targetm.asm_out.select_rtx_section (desc->mode, x, + desc->align)); #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, desc->mode, @@ -3364,8 +3166,8 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc) /* Make sure all constants in SECTION_MERGE and not SECTION_STRINGS sections have proper size. */ if (desc->align > GET_MODE_BITSIZE (desc->mode) - && in_section == in_named - && get_named_section_flags (in_named_name) & SECTION_MERGE) + && in_section + && (in_section->common.flags & SECTION_MERGE)) assemble_align (desc->align); #ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY @@ -5003,12 +4805,73 @@ make_decl_one_only (tree decl) void init_varasm_once (void) { - in_named_htab = htab_create_ggc (31, in_named_entry_hash, - in_named_entry_eq, NULL); + section_htab = htab_create_ggc (31, section_entry_hash, + section_entry_eq, NULL); const_desc_htab = htab_create_ggc (1009, const_desc_hash, const_desc_eq, NULL); const_alias_set = new_alias_set (); + +#ifdef TEXT_SECTION_ASM_OP + text_section = get_unnamed_section (SECTION_CODE, output_section_asm_op, + TEXT_SECTION_ASM_OP); +#endif + +#ifdef DATA_SECTION_ASM_OP + data_section = get_unnamed_section (SECTION_WRITE, output_section_asm_op, + DATA_SECTION_ASM_OP); +#endif + +#ifdef SDATA_SECTION_ASM_OP + sdata_section = get_unnamed_section (SECTION_WRITE, output_section_asm_op, + SDATA_SECTION_ASM_OP); +#endif + +#ifdef READONLY_DATA_SECTION_ASM_OP + readonly_data_section = get_unnamed_section (0, output_section_asm_op, + READONLY_DATA_SECTION_ASM_OP); +#endif + +#ifdef CTORS_SECTION_ASM_OP + ctors_section = get_unnamed_section (0, output_section_asm_op, + CTORS_SECTION_ASM_OP); +#endif + +#ifdef DTORS_SECTION_ASM_OP + dtors_section = get_unnamed_section (0, output_section_asm_op, + DTORS_SECTION_ASM_OP); +#endif + +#ifdef BSS_SECTION_ASM_OP + bss_section = get_unnamed_section (SECTION_WRITE | SECTION_BSS, + output_section_asm_op, + BSS_SECTION_ASM_OP); +#endif + +#ifdef SBSS_SECTION_ASM_OP + sbss_section = get_unnamed_section (SECTION_WRITE | SECTION_BSS, + output_section_asm_op, + SBSS_SECTION_ASM_OP); +#endif + +#ifdef INIT_SECTION_ASM_OP + init_section = get_unnamed_section (SECTION_CODE, output_section_asm_op, + INIT_SECTION_ASM_OP); +#endif + +#ifdef FINI_SECTION_ASM_OP + fini_section = get_unnamed_section (SECTION_CODE, output_section_asm_op, + FINI_SECTION_ASM_OP); +#endif + + targetm.asm_out.init_sections (); + + if (readonly_data_section == NULL) + readonly_data_section = text_section; + if (exception_section == NULL) + exception_section = default_exception_section (); + if (eh_frame_section == NULL) + eh_frame_section = default_eh_frame_section (); } enum tls_model @@ -5135,7 +4998,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags, part of a COMDAT groups, in which case GAS requires the full declaration every time. */ if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) - && ! named_section_first_declaration (name)) + && (flags & SECTION_DECLARED)) { fprintf (asm_out_file, "\t.section\t%s\n", name); return; @@ -5223,16 +5086,14 @@ default_pe_asm_named_section (const char *name, unsigned int flags, /* The lame default section selector. */ -void +section * default_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { - bool readonly = false; - if (DECL_P (decl)) { if (decl_readonly_section (decl, reloc)) - readonly = true; + return readonly_data_section; } else if (TREE_CODE (decl) == CONSTRUCTOR) { @@ -5240,17 +5101,14 @@ default_select_section (tree decl, int reloc, || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) || !TREE_CONSTANT (decl))) - readonly = true; + return readonly_data_section; } else if (TREE_CODE (decl) == STRING_CST) - readonly = true; + return readonly_data_section; else if (! (flag_pic && reloc)) - readonly = true; + return readonly_data_section; - if (readonly) - readonly_data_section (); - else - data_section (); + return data_section; } enum section_category @@ -5366,14 +5224,14 @@ decl_readonly_section_1 (tree decl, int reloc, int shlib) /* Select a section based on the above categorization. */ -void +section * default_elf_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align) { - default_elf_select_section_1 (decl, reloc, align, flag_pic); + return default_elf_select_section_1 (decl, reloc, align, flag_pic); } -void +section * default_elf_select_section_1 (tree decl, int reloc, unsigned HOST_WIDE_INT align, int shlib) { @@ -5384,23 +5242,18 @@ default_elf_select_section_1 (tree decl, int reloc, /* We're not supposed to be called on FUNCTION_DECLs. */ gcc_unreachable (); case SECCAT_RODATA: - readonly_data_section (); - return; + return readonly_data_section; case SECCAT_RODATA_MERGE_STR: - mergeable_string_section (decl, align, 0); - return; + return mergeable_string_section (decl, align, 0); case SECCAT_RODATA_MERGE_STR_INIT: - mergeable_string_section (DECL_INITIAL (decl), align, 0); - return; + return mergeable_string_section (DECL_INITIAL (decl), align, 0); case SECCAT_RODATA_MERGE_CONST: - mergeable_constant_section (DECL_MODE (decl), align, 0); - return; + return mergeable_constant_section (DECL_MODE (decl), align, 0); case SECCAT_SRODATA: sname = ".sdata2"; break; case SECCAT_DATA: - data_section (); - return; + return data_section; case SECCAT_DATA_REL: sname = ".data.rel"; break; @@ -5420,13 +5273,10 @@ default_elf_select_section_1 (tree decl, int reloc, sname = ".tdata"; break; case SECCAT_BSS: -#ifdef BSS_SECTION_ASM_OP - bss_section (); - return; -#else + if (bss_section) + return bss_section; sname = ".bss"; break; -#endif case SECCAT_SBSS: sname = ".sbss"; break; @@ -5439,7 +5289,7 @@ default_elf_select_section_1 (tree decl, int reloc, if (!DECL_P (decl)) decl = NULL_TREE; - named_section (decl, sname, reloc); + return get_named_section (decl, sname, reloc); } /* Construct a unique section name based on the decl name and the @@ -5512,7 +5362,7 @@ default_unique_section_1 (tree decl, int reloc, int shlib) DECL_SECTION_NAME (decl) = build_string (nlen + plen, string); } -void +section * default_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) @@ -5523,17 +5373,16 @@ default_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED, case CONST: case SYMBOL_REF: case LABEL_REF: - data_section (); - return; + return data_section; default: break; } - readonly_data_section (); + return readonly_data_section; } -void +section * default_elf_select_rtx_section (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) { @@ -5544,18 +5393,16 @@ default_elf_select_rtx_section (enum machine_mode mode, rtx x, { case CONST: case SYMBOL_REF: - named_section (NULL_TREE, ".data.rel.ro", 3); - return; + return get_named_section (NULL, ".data.rel.ro", 3); case LABEL_REF: - named_section (NULL_TREE, ".data.rel.ro.local", 1); - return; + return get_named_section (NULL, ".data.rel.ro.local", 1); default: break; } - mergeable_constant_section (mode, align, 0); + return mergeable_constant_section (mode, align, 0); } /* Set the generally applicable flags on the SYMBOL_REF for EXP. */ @@ -5728,7 +5575,52 @@ file_end_indicate_exec_stack (void) if (trampolines_created) flags |= SECTION_CODE; - named_section_flags (".note.GNU-stack", flags); + switch_to_section (get_section (".note.GNU-stack", flags, NULL)); +} + +/* Output DIRECTIVE (a C string) followed by a newline. This is used as + a get_unnamed_section callback. */ + +void +output_section_asm_op (const void *directive) +{ + fprintf (asm_out_file, "%s\n", (const char *) directive); +} + +/* Emit assembly code to switch to section NEW_SECTION. Do nothing if + the current section is NEW_SECTION. */ + +void +switch_to_section (section *new_section) +{ + if (in_section == new_section) + return; + + if (new_section->common.flags & SECTION_FORGET) + in_section = NULL; + else + { + in_section = new_section; + if (new_section->common.flags & SECTION_CODE) + last_text_section = in_section; + } + + if (new_section->common.flags & SECTION_NAMED) + { + if (cfun + && !cfun->unlikely_text_section_name + && strcmp (new_section->named.name, + UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0) + cfun->unlikely_text_section_name = UNLIKELY_EXECUTED_TEXT_SECTION_NAME; + + targetm.asm_out.named_section (new_section->named.name, + new_section->named.common.flags, + new_section->named.decl); + } + else + new_section->unnamed.callback (new_section->unnamed.data); + + new_section->common.flags |= SECTION_DECLARED; } #include "gt-varasm.h" diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c index 0965794..d8ed683 100644 --- a/gcc/vmsdbgout.c +++ b/gcc/vmsdbgout.c @@ -1697,13 +1697,13 @@ vmsdbgout_finish (const char *main_input_filename ATTRIBUTE_UNUSED) return; /* Output a terminator label for the .text section. */ - text_section (); + switch_to_section (text_section); targetm.asm_out.internal_label (asm_out_file, TEXT_END_LABEL, 0); /* Output debugging information. Warning! Do not change the name of the .vmsdebug section without changing it in the assembler also. */ - named_section (NULL_TREE, ".vmsdebug", 0); + switch_to_section (get_named_section (NULL, ".vmsdebug", 0)); ASM_OUTPUT_ALIGN (asm_out_file, 0); totsize = write_modbeg (1);