From ae46c4e08a8cbb8359203a90e172a78e3263174b Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 17 May 2002 00:43:41 -0700 Subject: [PATCH] hooks.c (hook_tree_bool_false): New. * hooks.c (hook_tree_bool_false): New. * hooks.h: Declare it. * target-def.h (TARGET_ASM_SELECT_SECTION): New. (TARGET_ASM_UNIQUE_SECTION, TARGET_IN_SMALL_DATA_P): New. * target.h (select_section, unique_section): New. (in_small_data_p): New. * varasm.c (resolve_unique_section): Use hooks instead of macros. (variable_section, output_constant_def_contents): Likewise. (default_select_section, default_unique_section): New. (categorize_decl_for_section, default_elf_select_section): New. * output.h: Declare them. * config/darwin.h (ALIAS_SECTION, try_section_alias): Remove. (TARGET_ASM_SELECT_SECTION): New. (SELECT_SECTION): Move ... * config/darwin.c (machopic_select_section): ... here. * config/darwin-protos.h: Update. * config/nextstep.h (TARGET_ASM_SELECT_SECTION): New. (SELECT_SECTION): Move ... * config/nextstep.c (nextstep_select_section): ... here. * config/nextstep-protos.h: Update. * config/elfos.h (UNIQUE_SECTION, SELECT_SECTION): Remove. (TARGET_ASM_SELECT_SECTION): New. * config/svr3.h (SELECT_SECTION): Remove. * config/alpha/alpha.c (unicosmk_unique_section): Make static. (TARGET_ASM_UNIQUE_SECTION) [UNICOS]: New. (TARGET_IN_SMALL_DATA_P, alpha_in_small_data_p): New. (alpha_encode_section_info): Use it. * config/alpha/alpha-protos.h: Update. * config/alpha/elf.h (DO_SELECT_SECTION): Remove. (SELECT_SECTION, UNIQUE_SECTION): Remove. (TARGET_ASM_SELECT_SECTION): New. * config/alpha/unicosmk.h (UNIQUE_SECTION): Remove. * config/arm/pe.h (UNIQUE_SECTION): Remove. (TARGET_ASM_UNIQUE_SECTION): New. * config/avr/avr.c (TARGET_ASM_UNIQUE_SECTION): New. (avr_unique_section): Rename from unique_section; make static. * config/avr/avr-protos.h: Update. * config/avr/avr.h (UNIQUE_SECTION): Remove. * config/c4x/c4x.h (SELECT_SECTION): Remove. * config/i386/cygwin.h (UNIQUE_SECTION): Remove. (TARGET_ASM_UNIQUE_SECTION): New. * config/i386/i386-interix.h: Likewise. * config/i386/win32.h: Likewise. * config/i386/djgpp.h (UNIQUE_SECTION): Remove. * config/i386/i386.c (ix86_asm_file_end): Use target hook not macro. * config/i386/sco5.h (SELECT_SECTION): Remove. (TARGET_ASM_SELECT_SECTION): New. * config/i386/svr3gas.h (SELECT_SECTION): Remove. * config/i860/paragon.h: Undef TARGET_ASM_SELECT_SECTION instead of SELECT_SECTION. * config/m68k/dpx2.h: Likewise. * config/rs6000/lynx.h: Likewise. * config/ia64/aix.h (SELECT_SECTION, UNIQUE_SECTION): Remove. (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New. * config/ia64/ia64.c (TARGET_IN_SMALL_DATA_P): New. (ia64_in_small_data_p): New. (ia64_encode_section_info): Use it. Reorganize overlarge conditional. (ia64_aix_select_section, ia64_aix_unique_section): New. * config/ia64/sysv4.h (DO_SELECT_SECTION): Remove. (SELECT_SECTION, UNIQUE_SECTION): Remove. * config/m32r/m32r.h (SELECT_SECTION): Remove. (TARGET_ASM_SELECT_SECTION): New. * config/m32r/m32r.c (m32r_select_section): Take align argument. * config/m32r/m32r-protos.h: Update. * config/m88k/m88k.h (TARGET_ASM_SELECT_SECTION): New. (SELECT_SECTION): Move ... * config/m88k/m88k.c (m88k_select_section): ... here. * config/mcore/mcore-pe.h (SELECT_SECTION): Remove. * config/mcore/mcore.h (UNIQUE_SECTION): Remove. * config/mcore/mcore.c (TARGET_ASM_UNIQUE_SECTION): New. (mcore_unique_section): Make static. * config/mcore/mcore-protos.h: Update. * config/mips/elf.h (UNIQUE_SECTION): Remove. (TARGET_ASM_UNIQUE_SECTION): New. * config/mips/elf64.h: Likewise. * config/mips/iris6gld.h: Likewise. * config/mips/linux.h: Likewise. * config/mips/mips-protos.h: Update. * config/mips/mips.c (mips_select_section): Add align argument. * config/mips/mips.h (SELECT_SECTION): Remove. (TARGET_ASM_SELECT_SECTION): New. * config/mmix/mmix.h (SELECT_SECTION, UNIQUE_SECTION): Remove. * config/mmix/mmix.c (mmix_select_section): Remove. (mmix_unique_section): Remove. * config/mmix/mmix-protos.h: Update. * config/pa/pa.h (TARGET_ASM_SELECT_SECTION): New. (SELECT_SECTION): Move ... * config/pa/pa.c (pa_select_section): ... here. * config/pa/pa64-hpux.h (UNIQUE_SECTION): Remove. * config/rs6000/rs6000.c (rs6000_elf_select_section): Rename from rs6000_select_section and make static. (rs6000_elf_unique_section): Similarly. (rs6000_xcoff_select_section): From xcoff.h. (rs6000_xcoff_unique_section): Likewise. * config/rs6000/rs6000-protos.h: Update. * config/rs6000/sysv4.h (SELECT_SECTION, UNIQUE_SECTION): Remove. (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New. * config/rs6000/xcoff.h: Likewise. * config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): New. (SELECT_SECTION): Move ... * config/sparc/sparc.c (sparc_aout_select_section): ... here. * config/v850/v850.h (SELECT_SECTION): Move ... * config/v850/v850.c (v850_select_section): ... here. (TARGET_ASM_SELECT_SECTION): New. * config/vax/vms.h (SELECT_SECTION): Move ... * config/vax/vax.c (vms_select_section): ... here. (TARGET_ASM_SELECT_SECTION): New. * doc/tm.texi: Update SELECT_SECTION and UNIQUE_SECTION docs for the target hooks. From-SVN: r53550 --- gcc/ChangeLog | 133 +++++++++++++ gcc/config/alpha/alpha-interix.h | 10 +- gcc/config/alpha/alpha-protos.h | 5 +- gcc/config/alpha/alpha.c | 67 ++++--- gcc/config/alpha/elf.h | 161 +-------------- gcc/config/alpha/unicosmk.h | 12 +- gcc/config/arm/pe.c | 4 +- gcc/config/arm/pe.h | 4 +- gcc/config/avr/avr-protos.h | 3 +- gcc/config/avr/avr.c | 7 +- gcc/config/avr/avr.h | 19 -- gcc/config/c4x/c4x.h | 29 --- gcc/config/d30v/d30v.h | 22 --- gcc/config/darwin-protos.h | 4 +- gcc/config/darwin.c | 130 ++++++++++++- gcc/config/darwin.h | 153 +-------------- gcc/config/elfos.h | 125 +----------- gcc/config/i386/cygwin.h | 2 +- gcc/config/i386/djgpp.h | 34 ---- gcc/config/i386/i386-interix.h | 11 +- gcc/config/i386/i386.c | 2 +- gcc/config/i386/sco5.h | 25 +-- gcc/config/i386/svr3gas.h | 40 +--- gcc/config/i386/win32.h | 6 +- gcc/config/i386/winnt.c | 5 +- gcc/config/i860/paragon.h | 4 +- gcc/config/ia64/aix.h | 88 +-------- gcc/config/ia64/ia64.c | 188 +++++++++++------- gcc/config/ia64/sysv4.h | 129 ------------ gcc/config/m32r/m32r-protos.h | 4 +- gcc/config/m32r/m32r.c | 7 +- gcc/config/m32r/m32r.h | 9 +- gcc/config/m68k/dpx2.h | 5 +- gcc/config/m88k/m88k.c | 36 +++- gcc/config/m88k/m88k.h | 35 +--- gcc/config/mcore/mcore-pe.h | 31 +-- gcc/config/mcore/mcore-protos.h | 3 +- gcc/config/mcore/mcore.c | 10 +- gcc/config/mcore/mcore.h | 3 - gcc/config/mips/elf.h | 7 +- gcc/config/mips/elf64.h | 8 +- gcc/config/mips/iris6gld.h | 42 +--- gcc/config/mips/linux.h | 4 +- gcc/config/mips/mips-protos.h | 4 +- gcc/config/mips/mips.c | 17 +- gcc/config/mips/mips.h | 6 +- gcc/config/mmix/mmix-protos.h | 2 - gcc/config/mmix/mmix.c | 83 -------- gcc/config/mmix/mmix.h | 6 - gcc/config/netware.h | 10 +- gcc/config/nextstep-protos.h | 4 +- gcc/config/nextstep.c | 122 +++++++++++- gcc/config/nextstep.h | 121 +----------- gcc/config/pa/pa.c | 29 +++ gcc/config/pa/pa.h | 20 +- gcc/config/pa/pa64-hpux.h | 30 --- gcc/config/rs6000/lynx.h | 4 +- gcc/config/rs6000/rs6000-protos.h | 4 +- gcc/config/rs6000/rs6000.c | 63 +++++- gcc/config/rs6000/sysv4.h | 11 +- gcc/config/rs6000/xcoff.h | 40 +--- gcc/config/sparc/aout.h | 33 +--- gcc/config/sparc/sparc.c | 18 +- gcc/config/stormy16/stormy16.h | 22 --- gcc/config/svr3.h | 43 +--- gcc/config/v850/v850.c | 61 ++++++ gcc/config/v850/v850.h | 65 ------- gcc/config/vax/vax.c | 36 ++++ gcc/config/vax/vms.h | 37 +--- gcc/doc/tm.texi | 51 ++--- gcc/hooks.c | 8 + gcc/hooks.h | 1 + gcc/output.h | 6 + gcc/target-def.h | 14 +- gcc/target.h | 14 ++ gcc/varasm.c | 312 ++++++++++++++++++++++++++---- 76 files changed, 1228 insertions(+), 1695 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76fde3d778cb..e995d626dcf4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,136 @@ +2002-05-17 Richard Henderson + + * hooks.c (hook_tree_bool_false): New. + * hooks.h: Declare it. + * target-def.h (TARGET_ASM_SELECT_SECTION): New. + (TARGET_ASM_UNIQUE_SECTION, TARGET_IN_SMALL_DATA_P): New. + * target.h (select_section, unique_section): New. + (in_small_data_p): New. + * varasm.c (resolve_unique_section): Use hooks instead of macros. + (variable_section, output_constant_def_contents): Likewise. + (default_select_section, default_unique_section): New. + (categorize_decl_for_section, default_elf_select_section): New. + * output.h: Declare them. + + * config/darwin.h (ALIAS_SECTION, try_section_alias): Remove. + (TARGET_ASM_SELECT_SECTION): New. + (SELECT_SECTION): Move ... + * config/darwin.c (machopic_select_section): ... here. + * config/darwin-protos.h: Update. + + * config/nextstep.h (TARGET_ASM_SELECT_SECTION): New. + (SELECT_SECTION): Move ... + * config/nextstep.c (nextstep_select_section): ... here. + * config/nextstep-protos.h: Update. + + * config/elfos.h (UNIQUE_SECTION, SELECT_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION): New. + * config/svr3.h (SELECT_SECTION): Remove. + + * config/alpha/alpha.c (unicosmk_unique_section): Make static. + (TARGET_ASM_UNIQUE_SECTION) [UNICOS]: New. + (TARGET_IN_SMALL_DATA_P, alpha_in_small_data_p): New. + (alpha_encode_section_info): Use it. + * config/alpha/alpha-protos.h: Update. + * config/alpha/elf.h (DO_SELECT_SECTION): Remove. + (SELECT_SECTION, UNIQUE_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION): New. + * config/alpha/unicosmk.h (UNIQUE_SECTION): Remove. + + * config/arm/pe.h (UNIQUE_SECTION): Remove. + (TARGET_ASM_UNIQUE_SECTION): New. + + * config/avr/avr.c (TARGET_ASM_UNIQUE_SECTION): New. + (avr_unique_section): Rename from unique_section; make static. + * config/avr/avr-protos.h: Update. + * config/avr/avr.h (UNIQUE_SECTION): Remove. + + * config/c4x/c4x.h (SELECT_SECTION): Remove. + + * config/i386/cygwin.h (UNIQUE_SECTION): Remove. + (TARGET_ASM_UNIQUE_SECTION): New. + * config/i386/i386-interix.h: Likewise. + * config/i386/win32.h: Likewise. + * config/i386/djgpp.h (UNIQUE_SECTION): Remove. + * config/i386/i386.c (ix86_asm_file_end): Use target hook not macro. + * config/i386/sco5.h (SELECT_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION): New. + * config/i386/svr3gas.h (SELECT_SECTION): Remove. + + * config/i860/paragon.h: Undef TARGET_ASM_SELECT_SECTION + instead of SELECT_SECTION. + * config/m68k/dpx2.h: Likewise. + * config/rs6000/lynx.h: Likewise. + + * config/ia64/aix.h (SELECT_SECTION, UNIQUE_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New. + * config/ia64/ia64.c (TARGET_IN_SMALL_DATA_P): New. + (ia64_in_small_data_p): New. + (ia64_encode_section_info): Use it. Reorganize overlarge conditional. + (ia64_aix_select_section, ia64_aix_unique_section): New. + * config/ia64/sysv4.h (DO_SELECT_SECTION): Remove. + (SELECT_SECTION, UNIQUE_SECTION): Remove. + + * config/m32r/m32r.h (SELECT_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION): New. + * config/m32r/m32r.c (m32r_select_section): Take align argument. + * config/m32r/m32r-protos.h: Update. + + * config/m88k/m88k.h (TARGET_ASM_SELECT_SECTION): New. + (SELECT_SECTION): Move ... + * config/m88k/m88k.c (m88k_select_section): ... here. + + * config/mcore/mcore-pe.h (SELECT_SECTION): Remove. + * config/mcore/mcore.h (UNIQUE_SECTION): Remove. + * config/mcore/mcore.c (TARGET_ASM_UNIQUE_SECTION): New. + (mcore_unique_section): Make static. + * config/mcore/mcore-protos.h: Update. + + * config/mips/elf.h (UNIQUE_SECTION): Remove. + (TARGET_ASM_UNIQUE_SECTION): New. + * config/mips/elf64.h: Likewise. + * config/mips/iris6gld.h: Likewise. + * config/mips/linux.h: Likewise. + * config/mips/mips-protos.h: Update. + * config/mips/mips.c (mips_select_section): Add align argument. + * config/mips/mips.h (SELECT_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION): New. + + * config/mmix/mmix.h (SELECT_SECTION, UNIQUE_SECTION): Remove. + * config/mmix/mmix.c (mmix_select_section): Remove. + (mmix_unique_section): Remove. + * config/mmix/mmix-protos.h: Update. + + * config/pa/pa.h (TARGET_ASM_SELECT_SECTION): New. + (SELECT_SECTION): Move ... + * config/pa/pa.c (pa_select_section): ... here. + * config/pa/pa64-hpux.h (UNIQUE_SECTION): Remove. + + * config/rs6000/rs6000.c (rs6000_elf_select_section): Rename + from rs6000_select_section and make static. + (rs6000_elf_unique_section): Similarly. + (rs6000_xcoff_select_section): From xcoff.h. + (rs6000_xcoff_unique_section): Likewise. + * config/rs6000/rs6000-protos.h: Update. + * config/rs6000/sysv4.h (SELECT_SECTION, UNIQUE_SECTION): Remove. + (TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): New. + * config/rs6000/xcoff.h: Likewise. + + * config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): New. + (SELECT_SECTION): Move ... + * config/sparc/sparc.c (sparc_aout_select_section): ... here. + + * config/v850/v850.h (SELECT_SECTION): Move ... + * config/v850/v850.c (v850_select_section): ... here. + (TARGET_ASM_SELECT_SECTION): New. + + * config/vax/vms.h (SELECT_SECTION): Move ... + * config/vax/vax.c (vms_select_section): ... here. + (TARGET_ASM_SELECT_SECTION): New. + + * doc/tm.texi: Update SELECT_SECTION and UNIQUE_SECTION docs + for the target hooks. + 2002-05-17 Nick Clifton * config/arm/arm.c (emit_multi_reg_push): Do not set diff --git a/gcc/config/alpha/alpha-interix.h b/gcc/config/alpha/alpha-interix.h index e7874b0a0112..a1c8cfc3ed01 100644 --- a/gcc/config/alpha/alpha-interix.h +++ b/gcc/config/alpha/alpha-interix.h @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler, for DEC Alpha running Windows/NT. - Copyright (C) 1995, 1996, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1999, 2000, 2002 Free Software Foundation, Inc. Donn Terry, Softway Systems, Inc. From code @@ -67,13 +67,7 @@ Boston, MA 02111-1307, USA. */ /* The following are needed for C++, but also needed for profiling */ -/* Support const sections and the ctors and dtors sections for g++. - Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. */ +/* Support const sections and the ctors and dtors sections for g++. */ #define USE_CONST_SECTION 1 diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h index 0ccdaaa0a1c9..f7745a1859d1 100644 --- a/gcc/config/alpha/alpha-protos.h +++ b/gcc/config/alpha/alpha-protos.h @@ -1,5 +1,5 @@ /* Prototypes for alpha.c functions used in the md file & elsewhere. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -176,9 +176,6 @@ extern rtx unicosmk_add_call_info_word PARAMS ((rtx)); #ifdef RTX_CODE extern void unicosmk_defer_case_vector PARAMS ((rtx, rtx)); #endif -#ifdef TREE_CODE -extern void unicosmk_unique_section PARAMS ((tree, int)); -#endif extern void unicosmk_add_extern PARAMS ((const char *)); extern void unicosmk_output_align PARAMS ((FILE *, int)); extern char * unicosmk_text_section PARAMS ((void)); diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 281e526cfe6a..2fb51a218873 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -1,6 +1,6 @@ /* Subroutines used for code generation on the DEC Alpha. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001 Free Software Foundation, Inc. + 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) This file is part of GNU CC. @@ -115,6 +115,8 @@ int alpha_this_gpdisp_sequence_number; /* Declarations of static functions. */ static bool decl_in_text_section PARAMS ((tree)); +static bool alpha_in_small_data_p + PARAMS ((tree)); static int some_small_symbolic_operand_1 PARAMS ((rtx *, void *)); static int split_small_symbolic_operand_1 @@ -199,15 +201,21 @@ static void vms_asm_out_destructor PARAMS ((rtx, int)); # define TARGET_SECTION_TYPE_FLAGS vms_section_type_flags #endif +#undef TARGET_IN_SMALL_DATA_P +#define TARGET_IN_SMALL_DATA_P alpha_in_small_data_p + #if TARGET_ABI_UNICOSMK static void unicosmk_asm_named_section PARAMS ((const char *, unsigned int)); static void unicosmk_insert_attributes PARAMS ((tree, tree *)); static unsigned int unicosmk_section_type_flags PARAMS ((tree, const char *, int)); +static void unicosmk_unique_section PARAMS ((tree, int)); # undef TARGET_INSERT_ATTRIBUTES # define TARGET_INSERT_ATTRIBUTES unicosmk_insert_attributes # undef TARGET_SECTION_TYPE_FLAGS # define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags +# undef TARGET_ASM_UNIQUE_SECTION +# define TARGET_ASM_UNIQUE_SECTION unicosmk_unique_section #endif #undef TARGET_ASM_ALIGNED_HI_OP @@ -1552,6 +1560,32 @@ decl_in_text_section (decl) && DECL_ONE_ONLY (decl)))); } +/* Return true if EXP should be placed in the small data section. */ + +static bool +alpha_in_small_data_p (exp) + tree exp; +{ + if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp)) + { + const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp)); + if (strcmp (section, ".sdata") == 0 + || strcmp (section, ".sbss") == 0) + return true; + } + else + { + HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); + + /* If this is an incomplete type with size 0, then we can't put it + in sdata because it might be too big when completed. */ + if (size > 0 && size <= g_switch_value) + return true; + } + + return false; +} + /* If we are referencing a function that is static, make the SYMBOL_REF special. We use this to see indicate we can branch to this function without setting PV or restoring GP. @@ -1626,32 +1660,7 @@ alpha_encode_section_info (decl, first) is_local = true; /* Determine if DECL will wind up in .sdata/.sbss. */ - - is_small = false; - if (DECL_SECTION_NAME (decl)) - { - const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); - if (strcmp (section, ".sdata") == 0 - || strcmp (section, ".sbss") == 0) - is_small = true; - } - else - { - HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); - - /* If the variable has already been defined in the output file, then it - is too late to put it in sdata if it wasn't put there in the first - place. The test is here rather than above, because if it is already - in sdata, then it can stay there. */ - - if (TREE_ASM_WRITTEN (decl)) - ; - - /* If this is an incomplete type with size 0, then we can't put it in - sdata because it might be too big when completed. */ - else if (size > 0 && size <= g_switch_value) - is_small = true; - } + is_small = alpha_in_small_data_p (decl); /* Finally, encode this into the symbol string. */ if (is_local) @@ -8546,7 +8555,7 @@ unicosmk_section_type_flags (decl, name, reloc) /* Generate a section name for decl and associate it with the declaration. */ -void +static void unicosmk_unique_section (decl, reloc) tree decl; int reloc ATTRIBUTE_UNUSED; @@ -8626,7 +8635,7 @@ unicosmk_insert_attributes (decl, attr_ptr) { if (DECL_P (decl) && (TREE_PUBLIC (decl) || TREE_CODE (decl) == FUNCTION_DECL)) - UNIQUE_SECTION (decl, 0); + unicosmk_unique_section (decl, 0); } /* Output an alignment directive. We have to use the macro 'gcc@code@align' diff --git a/gcc/config/alpha/elf.h b/gcc/config/alpha/elf.h index 22b63f07cb46..55199983aab1 100644 --- a/gcc/config/alpha/elf.h +++ b/gcc/config/alpha/elf.h @@ -191,13 +191,7 @@ do { \ #undef ASCII_DATA_ASM_OP #define ASCII_DATA_ASM_OP "\t.ascii\t" -/* Support const sections and the ctors and dtors sections for g++. - Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. */ +/* Support const sections and the ctors and dtors sections for g++. */ #undef USE_CONST_SECTION #define USE_CONST_SECTION 1 @@ -284,161 +278,10 @@ void FN () \ /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section - -/* A C statement or statements to switch to the appropriate - section for output of 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. - - Set SECNUM to: - 0 .text - 1 .rodata - 2 .data - 3 .sdata - 4 .bss - 5 .sbss -*/ - -#define DO_SELECT_SECTION(SECNUM, DECL, RELOC) \ - do \ - { \ - HOST_WIDE_INT size; \ - SECNUM = 1; \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ - { \ - SECNUM = 0; \ - break; \ - } \ - else if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (flag_writable_strings) \ - SECNUM = 2; \ - else \ - SECNUM = 0x101; \ - break; \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if (DECL_INITIAL (DECL) == NULL \ - || DECL_INITIAL (DECL) == error_mark_node) \ - SECNUM = 4; \ - else if ((flag_pic && RELOC) \ - || ! TREE_READONLY (DECL) \ - || TREE_SIDE_EFFECTS (DECL) \ - || ! TREE_CONSTANT (DECL_INITIAL (DECL))) \ - SECNUM = 2; \ - else if (flag_merge_constants >= 2) \ - { \ - /* C and C++ don't allow different variables to \ - share the same location. -fmerge-all-constants\ - allows even that (at the expense of not \ - conforming). */ \ - if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST)\ - SECNUM = 0x201; \ - else \ - SECNUM = 0x301; \ - } \ - } \ - else if (TREE_CODE (DECL) == CONSTRUCTOR) \ - { \ - if ((flag_pic && RELOC) \ - || TREE_SIDE_EFFECTS (DECL) \ - || ! TREE_CONSTANT (DECL)) \ - SECNUM = 2; \ - } \ - \ - /* Select small data sections based on size. */ \ - size = int_size_in_bytes (TREE_TYPE (DECL)); \ - if (size >= 0 && size <= g_switch_value) \ - { \ - if ((SECNUM & 0xff) >= 2) \ - SECNUM += 1; \ - /* Move readonly data to .sdata only if -msmall-data. */ \ - /* ??? Consider .sdata.{lit4,lit8} as \ - SHF_MERGE|SHF_ALPHA_GPREL. */ \ - else if (TARGET_SMALL_DATA) \ - SECNUM = 3; \ - } \ - } \ - while (0) - -#undef SELECT_SECTION -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ - do \ - { \ - typedef void (*sec_fn) PARAMS ((void)); \ - static sec_fn const sec_functions[6] = \ - { \ - text_section, \ - const_section, \ - data_section, \ - sdata_section, \ - bss_section, \ - sbss_section \ - }; \ - \ - int sec; \ - \ - DO_SELECT_SECTION (sec, DECL, RELOC); \ - \ - switch (sec) \ - { \ - case 0x101: \ - mergeable_string_section (DECL, ALIGN, 0); \ - break; \ - case 0x201: \ - mergeable_string_section (DECL_INITIAL (DECL),\ - ALIGN, 0); \ - break; \ - case 0x301: \ - mergeable_constant_section (DECL_MODE (DECL), \ - ALIGN, 0); \ - break; \ - default: \ - (*sec_functions[sec]) (); \ - break; \ - } \ - } \ - while (0) +#define TARGET_ASM_SELECT_SECTION default_elf_select_section #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL, RELOC) \ - do \ - { \ - static const char * const prefixes[6][2] = \ - { \ - { ".text.", ".gnu.linkonce.t." }, \ - { ".rodata.", ".gnu.linkonce.r." }, \ - { ".data.", ".gnu.linkonce.d." }, \ - { ".sdata.", ".gnu.linkonce.s." }, \ - { ".bss.", ".gnu.linkonce.b." }, \ - { ".sbss.", ".gnu.linkonce.sb." } \ - }; \ - \ - int nlen, plen, sec; \ - const char *name, *prefix; \ - char *string; \ - \ - DO_SELECT_SECTION (sec, DECL, RELOC); \ - \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - STRIP_NAME_ENCODING (name, name); \ - nlen = strlen (name); \ - \ - prefix = prefixes[sec & 0xff][DECL_ONE_ONLY(DECL)]; \ - plen = strlen (prefix); \ - \ - string = alloca (nlen + plen + 1); \ - \ - memcpy (string, prefix, plen); \ - memcpy (string + plen, name, nlen + 1); \ - \ - DECL_SECTION_NAME (DECL) = build_string (nlen + plen, string); \ - } \ - while (0) - /* A C statement or statements to switch to the appropriate section for output of RTX in mode MODE. RTX is some kind of constant in RTL. The argument MODE is redundant except diff --git a/gcc/config/alpha/unicosmk.h b/gcc/config/alpha/unicosmk.h index 4be7be537f1f..6cf19acf4467 100644 --- a/gcc/config/alpha/unicosmk.h +++ b/gcc/config/alpha/unicosmk.h @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler, for DEC Alpha on Cray T3E running Unicos/Mk. - Copyright (C) 2001 + Copyright (C) 2001, 2002 Free Software Foundation, Inc. Contributed by Roman Lechtchinsky (rl@cs.tu-berlin.de) @@ -380,16 +380,6 @@ ssib_section () \ in_section = in_ssib; \ } -/* A C expression which evaluates to true if declshould be placed into a - unique section for some target-specific reason. On Unicos/Mk, functions - and public variables are always placed in unique sections. */ - -/* -#define UNIQUE_SECTION_P(DECL) (TREE_PUBLIC (DECL) \ - || TREE_CODE (DECL) == FUNCTION_DECL) -*/ -#define UNIQUE_SECTION(DECL, RELOC) unicosmk_unique_section (DECL, RELOC) - /* This outputs text to go at the start of an assembler file. */ #undef ASM_FILE_START diff --git a/gcc/config/arm/pe.c b/gcc/config/arm/pe.c index 4069eac1ab2d..7fb0ed9b5dfb 100644 --- a/gcc/config/arm/pe.c +++ b/gcc/config/arm/pe.c @@ -1,5 +1,5 @@ /* Routines for GCC for ARM/pe. - Copyright (C) 1995, 1996, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Doug Evans (dje@cygnus.com). This file is part of GNU CC. @@ -248,8 +248,6 @@ arm_pe_encode_section_info (decl, first) } } -/* Cover function for UNIQUE_SECTION. */ - void arm_pe_unique_section (decl, reloc) tree decl; diff --git a/gcc/config/arm/pe.h b/gcc/config/arm/pe.h index 6c4375de1224..72fa77d44e38 100644 --- a/gcc/config/arm/pe.h +++ b/gcc/config/arm/pe.h @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler, for ARM with PE obj format. - Copyright (C) 1995, 1996, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1999, 2000, 2002 Free Software Foundation, Inc. Contributed by Doug Evans (dje@cygnus.com). This file is part of GNU CC. @@ -111,7 +111,7 @@ Boston, MA 02111-1307, USA. */ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -#define UNIQUE_SECTION(DECL, RELOC) arm_pe_unique_section (DECL, RELOC) +#define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section #define SUPPORTS_ONE_ONLY 1 diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h index fe69e636efe5..1a239d22587d 100644 --- a/gcc/config/avr/avr-protos.h +++ b/gcc/config/avr/avr-protos.h @@ -1,6 +1,6 @@ /* Prototypes for exported functions defined in avr.c - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Denis Chertykov (denisc@overta.ru) This file is part of GNU CC. @@ -43,7 +43,6 @@ extern void gas_output_ascii PARAMS ((FILE *file, const char *str, #ifdef TREE_CODE extern void asm_output_external PARAMS ((FILE *file, tree decl, char *name)); -extern void unique_section PARAMS ((tree decl, int reloc)); extern void encode_section_info PARAMS ((tree decl, int)); extern int avr_progmem_p PARAMS ((tree decl)); diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index fe1674d26434..955f1b146a40 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -63,6 +63,7 @@ const struct attribute_spec avr_attribute_table[]; static bool avr_assemble_integer PARAMS ((rtx, unsigned int, int)); static void avr_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void avr_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); +static void avr_unique_section PARAMS ((tree, int)); /* Allocate registers from r25 to r8 for parameters for function calls */ #define FIRST_CUM_REG 26 @@ -196,6 +197,8 @@ int avr_case_values_threshold = 30000; #define TARGET_ASM_FUNCTION_EPILOGUE avr_output_function_epilogue #undef TARGET_ATTRIBUTE_TABLE #define TARGET_ATTRIBUTE_TABLE avr_attribute_table +#undef TARGET_ASM_UNIQUE_SECTION +#define TARGET_ASM_UNIQUE_SECTION avr_unique_section struct gcc_target targetm = TARGET_INITIALIZER; @@ -4498,8 +4501,8 @@ avr_assemble_integer (x, size, aligned_p) /* Sets section name for declaration DECL */ -void -unique_section (decl, reloc) +static void +avr_unique_section (decl, reloc) tree decl; int reloc ATTRIBUTE_UNUSED; { diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index 66ca80c663fa..dcba8567e40f 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -1791,17 +1791,6 @@ progmem_section (void) \ If these items should be placed in the text section, this macro should not be defined. */ -/* `SELECT_SECTION (EXP, RELOC, ALIGN)' - A C statement or statements to switch to the appropriate section - for output of EXP. You can assume that EXP is either a `VAR_DECL' - node or a constant of some sort. RELOC indicates whether the - initial value of EXP requires link-time relocations. Select the - section by calling `text_section' or one of the alternatives for - other sections. - - Do not define this macro if you put all read-only variables and - constants in the read-only data section (usually the text section). */ - /* `SELECT_RTX_SECTION (MODE, RTX, ALIGN)' 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 @@ -1842,14 +1831,6 @@ progmem_section (void) \ characters that encode section info. Define this macro if `ENCODE_SECTION_INFO' alters the symbol's name string. */ -#define UNIQUE_SECTION(DECL, RELOC) unique_section (DECL, RELOC) -/* `UNIQUE_SECTION (DECL, RELOC)' - A C statement to build up a unique section name, expressed as a - STRING_CST node, and assign it to `DECL_SECTION_NAME (DECL)'. - RELOC indicates whether the initial value of EXP requires - link-time relocations. If you do not define this macro, GNU CC - will use the symbol name prefixed by `.' as the section name. */ - #define ASM_FILE_START(STREAM) asm_file_start (STREAM) /* A C expression which outputs to the stdio stream STREAM some appropriate text to go at the start of an assembler file. diff --git a/gcc/config/c4x/c4x.h b/gcc/config/c4x/c4x.h index ba63e3cb9b78..04dbe52c6822 100644 --- a/gcc/config/c4x/c4x.h +++ b/gcc/config/c4x/c4x.h @@ -1738,35 +1738,6 @@ const_section () \ /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION c4x_asm_named_section -/* A C statement or statements to switch to the appropriate - section for output of DECL. DECL is either a `VAR_DECL' node - or a constant of some sort. RELOC indicates whether forming - the initial value of DECL requires link-time relocations. */ - -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if ((0 && RELOC) /* Should be (flag_pic && RELOC). */ \ - || ! TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || ! DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && ! TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - data_section (); \ - else \ - const_section (); \ - } \ - else \ - const_section (); \ -} - /* The TI assembler wants to have hex numbers this way. */ #undef HOST_WIDE_INT_PRINT_HEX diff --git a/gcc/config/d30v/d30v.h b/gcc/config/d30v/d30v.h index 41eceb575e13..f13d90c4e016 100644 --- a/gcc/config/d30v/d30v.h +++ b/gcc/config/d30v/d30v.h @@ -2757,18 +2757,6 @@ extern const char *d30v_branch_cost_string; be defined. */ /* #define READONLY_DATA_SECTION */ -/* A C statement or statements to switch to the appropriate section for output - of EXP. You can assume that EXP is either a `VAR_DECL' node or a constant - of some sort. RELOC indicates whether the initial value of EXP requires - link-time relocations. Select the section by calling `text_section' or one - of the alternatives for other sections. - - Do not define this macro if you put all read-only variables and constants in - the read-only data section (usually the text section). - - Defined in svr4.h. */ -/* #define SELECT_SECTION(EXP, RELOC, ALIGN) */ - /* 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' @@ -2792,16 +2780,6 @@ extern const char *d30v_branch_cost_string; that encode section info. Define this macro if `ENCODE_SECTION_INFO' alters the symbol's name string. */ /* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */ - -/* A C statement to build up a unique section name, expressed as a - STRING_CST node, and assign it to `DECL_SECTION_NAME (DECL)'. - RELOC indicates whether the initial value of EXP requires - link-time relocations. If you do not define this macro, GNU CC - will use the symbol name prefixed by `.' as the section name. - - Defined in svr4.h. */ -/* #define UNIQUE_SECTION(DECL, RELOC) */ - /* Position Independent Code. */ diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index 5a93ca651518..9a9c9538572a 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -1,5 +1,5 @@ /* Prototypes. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -68,6 +68,8 @@ extern void machopic_output_possible_stub_label PARAMS ((FILE *, const char*)); extern void darwin_exception_section PARAMS ((void)); extern void darwin_eh_frame_section PARAMS ((void)); +extern void machopic_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)); #ifdef GCC_C_PRAGMA_H extern void darwin_pragma_ignore PARAMS ((cpp_reader *)); diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index f5e9db0e3154..8a3a2da8e11a 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1,5 +1,5 @@ /* Functions for generic Darwin as target machine for GNU C compiler. - Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001 + Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Apple Computer Inc. @@ -1109,6 +1109,134 @@ update_stubs (name) } } +void +machopic_select_section (exp, reloc, align) + tree exp; + int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if (TREE_CODE (exp) == STRING_CST) + { + if (flag_writable_strings) + data_section (); + else if (TREE_STRING_LENGTH (exp) != + strlen (TREE_STRING_POINTER (exp)) + 1) + readonly_data_section (); + else + cstring_section (); + } + else if (TREE_CODE (exp) == INTEGER_CST + || TREE_CODE (exp) == REAL_CST) + { + tree size = TYPE_SIZE (TREE_TYPE (exp)); + + if (TREE_CODE (size) == INTEGER_CST && + TREE_INT_CST_LOW (size) == 4 && + TREE_INT_CST_HIGH (size) == 0) + literal4_section (); + else if (TREE_CODE (size) == INTEGER_CST && + TREE_INT_CST_LOW (size) == 8 && + TREE_INT_CST_HIGH (size) == 0) + literal8_section (); + else + readonly_data_section (); + } + else if (TREE_CODE (exp) == CONSTRUCTOR + && TREE_TYPE (exp) + && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE + && TYPE_NAME (TREE_TYPE (exp))) + { + tree name = TYPE_NAME (TREE_TYPE (exp)); + if (TREE_CODE (name) == TYPE_DECL) + name = DECL_NAME (name); + if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString")) + objc_constant_string_object_section (); + else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) + objc_string_object_section (); + else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) + { + if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) + const_data_section (); + else + readonly_data_section (); + } + else + data_section (); + } + else if (TREE_CODE (exp) == VAR_DECL && + DECL_NAME (exp) && + TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && + IDENTIFIER_POINTER (DECL_NAME (exp)) && + !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) + { + const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); + + if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) + objc_cls_meth_section (); + else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) + objc_inst_meth_section (); + else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) + objc_cat_inst_meth_section (); + else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) + objc_class_vars_section (); + else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) + objc_instance_vars_section (); + else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) + objc_class_names_section (); + else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) + objc_meth_var_names_section (); + else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) + objc_meth_var_types_section (); + else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) + objc_cls_refs_section (); + else if (!strncmp (name, "_OBJC_CLASS_", 12)) + objc_class_section (); + else if (!strncmp (name, "_OBJC_METACLASS_", 16)) + objc_meta_class_section (); + else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) + objc_category_section (); + else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) + objc_selector_refs_section (); + else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) + objc_selector_fixup_section (); + else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) + objc_symbols_section (); + else if (!strncmp (name, "_OBJC_MODULES", 13)) + objc_module_info_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) + objc_cat_inst_meth_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) + objc_protocol_section (); + else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) + && !TREE_SIDE_EFFECTS (exp)) + { + if (flag_pic && reloc) + const_data_section (); + else + readonly_data_section (); + } + else + data_section (); + } + else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) + { + if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) + const_data_section (); + else + readonly_data_section (); + } + else + data_section (); +} + void machopic_asm_out_constructor (symbol, priority) rtx symbol; diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index c5a078b025e5..19c7a096a080 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -316,11 +316,6 @@ FUNCTION () \ } \ } \ -#define ALIAS_SECTION(enum_value, alias_name) \ -do { if (!strcmp (alias_name, name)) \ - section_alias[enum_value] = (alias ? get_identifier (alias) : 0); \ - } while (0) - /* Darwin uses many types of special sections. */ #undef EXTRA_SECTIONS @@ -486,157 +481,13 @@ objc_section_init () \ objc_module_info_section (); \ objc_symbols_section (); \ } \ -} \ -static tree section_alias[(int) num_sections]; \ -static void try_section_alias PARAMS ((void)); \ -static void try_section_alias () \ -{ \ - if (section_alias[in_section] && asm_out_file) \ - fprintf (asm_out_file, "%s\n", \ - IDENTIFIER_POINTER (section_alias[in_section])); \ -} \ - -#if 0 -static void alias_section PARAMS ((const char *, const char *)); \ -static void alias_section (name, alias) \ - const char *name, *alias; \ -{ \ - ALIAS_SECTION (in_data, "data"); \ - ALIAS_SECTION (in_text, "text"); \ - ALIAS_SECTION (in_const, "const"); \ - ALIAS_SECTION (in_const_data, "const_data"); \ - ALIAS_SECTION (in_cstring, "cstring"); \ - ALIAS_SECTION (in_literal4, "literal4"); \ - ALIAS_SECTION (in_literal8, "literal8"); \ } -#endif #undef READONLY_DATA_SECTION #define READONLY_DATA_SECTION const_section -#undef SELECT_SECTION -#define SELECT_SECTION(exp,reloc,align) \ - do \ - { \ - if (TREE_CODE (exp) == STRING_CST) \ - { \ - if (flag_writable_strings) \ - data_section (); \ - else if (TREE_STRING_LENGTH (exp) != \ - strlen (TREE_STRING_POINTER (exp)) + 1) \ - readonly_data_section (); \ - else \ - cstring_section (); \ - } \ - else if (TREE_CODE (exp) == INTEGER_CST \ - || TREE_CODE (exp) == REAL_CST) \ - { \ - tree size = TYPE_SIZE (TREE_TYPE (exp)); \ - \ - if (TREE_CODE (size) == INTEGER_CST && \ - TREE_INT_CST_LOW (size) == 4 && \ - TREE_INT_CST_HIGH (size) == 0) \ - literal4_section (); \ - else if (TREE_CODE (size) == INTEGER_CST && \ - TREE_INT_CST_LOW (size) == 8 && \ - TREE_INT_CST_HIGH (size) == 0) \ - literal8_section (); \ - else \ - readonly_data_section (); \ - } \ - else if (TREE_CODE (exp) == CONSTRUCTOR \ - && TREE_TYPE (exp) \ - && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \ - && TYPE_NAME (TREE_TYPE (exp))) \ - { \ - tree name = TYPE_NAME (TREE_TYPE (exp)); \ - if (TREE_CODE (name) == TYPE_DECL) \ - name = DECL_NAME (name); \ - if (!strcmp (IDENTIFIER_POINTER (name), "NSConstantString")) \ - objc_constant_string_object_section (); \ - else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString")) \ - objc_string_object_section (); \ - else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - { \ - if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \ - const_data_section (); \ - else \ - readonly_data_section (); \ - } \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (exp) == VAR_DECL && \ - DECL_NAME (exp) && \ - TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \ - IDENTIFIER_POINTER (DECL_NAME (exp)) && \ - !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \ - { \ - const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \ - \ - if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \ - objc_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \ - objc_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \ - objc_cat_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \ - objc_class_vars_section (); \ - else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \ - objc_instance_vars_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \ - objc_class_names_section (); \ - else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \ - objc_meth_var_names_section (); \ - else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \ - objc_meth_var_types_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \ - objc_cls_refs_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_", 12)) \ - objc_class_section (); \ - else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \ - objc_meta_class_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \ - objc_category_section (); \ - else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \ - objc_selector_refs_section (); \ - else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20)) \ - objc_selector_fixup_section (); \ - else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \ - objc_symbols_section (); \ - else if (!strncmp (name, "_OBJC_MODULES", 13)) \ - objc_module_info_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \ - objc_cat_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \ - objc_protocol_section (); \ - else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - && !TREE_SIDE_EFFECTS (exp)) \ - { if (flag_pic && reloc ) const_data_section (); \ - else readonly_data_section (); } \ - else \ - data_section (); \ - } \ - else if (TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - { \ - if (TREE_SIDE_EFFECTS (exp) || flag_pic && reloc) \ - const_data_section (); \ - else \ - readonly_data_section (); \ - } \ - else \ - data_section (); \ - try_section_alias (); \ - } \ - while (0) +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION machopic_select_section /* This can be called with address expressions as "rtx". They must go in "const". */ diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index 6b93253be375..ea11b653f5ff 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -1,6 +1,6 @@ /* elfos.h -- operating system specific defines to be used when targeting GCC for some generic ELF system - Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001 + Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com). @@ -216,16 +216,9 @@ Boston, MA 02111-1307, USA. */ #undef ASCII_DATA_ASM_OP #define ASCII_DATA_ASM_OP "\t.ascii\t" -/* Support const sections and the ctors and dtors sections for g++. - Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. */ +/* Support const sections and the ctors and dtors sections for g++. */ #define USE_CONST_SECTION 1 - #define CONST_SECTION_ASM_OP "\t.section\t.rodata" /* On svr4, we *do* have support for the .init and .fini sections, and we @@ -279,45 +272,6 @@ const_section () \ } #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) - -#define UNIQUE_SECTION(DECL, RELOC) \ - do \ - { \ - int len; \ - int sec; \ - const char *name; \ - char *string; \ - const char *prefix; \ - static const char *const prefixes[4][2] = \ - { \ - { ".text.", ".gnu.linkonce.t." }, \ - { ".rodata.", ".gnu.linkonce.r." }, \ - { ".data.", ".gnu.linkonce.d." }, \ - { ".bss.", ".gnu.linkonce.b." } \ - }; \ - \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ - sec = 0; \ - else if (DECL_INITIAL (DECL) == 0 \ - || DECL_INITIAL (DECL) == error_mark_node) \ - sec = 3; \ - else if (DECL_READONLY_SECTION (DECL, RELOC)) \ - sec = 1; \ - else \ - sec = 2; \ - \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - /* Strip off any encoding in name. */ \ - STRIP_NAME_ENCODING (name, name); \ - prefix = prefixes[sec][DECL_ONE_ONLY(DECL)]; \ - len = strlen (name) + strlen (prefix); \ - string = alloca (len + 1); \ - \ - sprintf (string, "%s%s", prefix, name); \ - \ - DECL_SECTION_NAME (DECL) = build_string (len, string); \ - } \ - while (0) /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section @@ -334,79 +288,8 @@ const_section () \ #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \ mergeable_constant_section ((MODE), (ALIGN), 0) -/* 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. - - To optimize loading of shared programs, define following subsections - of data section by attaching: - - .rel - Section with this string in name contains data that do have - relocations, so they get grouped together and dynamic linker - will visit fewer pages in memory. - .ro - Marks data read only otherwise. This is useful with prelinking - as most of relocations won't be dynamically linked and thus - stay read only. - .local - Marks data containing relocations only to local objects. These - relocation will get fully resolved by prelinking. - */ - -#undef SELECT_SECTION -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - mergeable_string_section ((DECL), (ALIGN), 0); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - { \ - if (flag_pic && ((RELOC) & 2)) \ - named_section (NULL_TREE, ".data.rel", RELOC); \ - else if (flag_pic && (RELOC)) \ - named_section (NULL_TREE, ".data.rel.local", RELOC);\ - else \ - data_section (); \ - } \ - else if (flag_pic && ((RELOC) & 2)) \ - named_section (NULL_TREE, ".data.rel.ro", RELOC); \ - else if (flag_pic && (RELOC)) \ - named_section (NULL_TREE, ".data.rel.ro.local", RELOC); \ - else if (flag_merge_constants < 2) \ - /* C and C++ don't allow different variables to share \ - the same location. -fmerge-all-constants allows \ - even that (at the expense of not conforming). */ \ - const_section (); \ - else if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST) \ - mergeable_string_section (DECL_INITIAL (DECL), (ALIGN), \ - 0); \ - else \ - mergeable_constant_section (DECL_MODE (DECL), (ALIGN), \ - 0); \ - } \ - else if (TREE_CODE (DECL) == CONSTRUCTOR) \ - { \ - if ((flag_pic && RELOC) \ - || TREE_SIDE_EFFECTS (DECL) \ - || ! TREE_CONSTANT (DECL)) \ - data_section (); \ - else \ - const_section (); \ - } \ - else \ - const_section (); \ -} +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION default_elf_select_section /* Define the strings used for the special svr4 .type and .size directives. These strings generally do not vary from one system running svr4 to diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index 09d4e691d883..739977b922ed 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -348,7 +348,7 @@ do { \ #define MULTIPLE_SYMBOL_SPACES extern void i386_pe_unique_section PARAMS ((TREE, int)); -#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) +#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section #define SUPPORTS_ONE_ONLY 1 diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h index 6e53e510b4f2..c44b55f9b70a 100644 --- a/gcc/config/i386/djgpp.h +++ b/gcc/config/i386/djgpp.h @@ -204,37 +204,3 @@ while (0) /* Support for C++ templates. */ #undef MAKE_DECL_ONE_ONLY #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) - -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL,RELOC) \ -do { \ - int len; \ - const char *name, *prefix; \ - char *string; \ - \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - /* Strip off any encoding in fnname. */ \ - STRIP_NAME_ENCODING (name, name); \ - \ - if (! DECL_ONE_ONLY (DECL)) \ - { \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ - prefix = ".text."; \ - else if (DECL_READONLY_SECTION (DECL, RELOC)) \ - prefix = ".rodata."; \ - else \ - prefix = ".data."; \ - } \ - else if (TREE_CODE (DECL) == FUNCTION_DECL) \ - prefix = ".gnu.linkonce.t."; \ - else if (DECL_READONLY_SECTION (DECL, RELOC)) \ - prefix = ".gnu.linkonce.r."; \ - else \ - prefix = ".gnu.linkonce.d."; \ - \ - len = strlen (name) + strlen (prefix); \ - string = alloca (len + 1); \ - sprintf (string, "%s%s", prefix, name); \ - \ - DECL_SECTION_NAME (DECL) = build_string (len, string); \ -} while (0) diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h index 1043c5f2a49c..680e0269196b 100644 --- a/gcc/config/i386/i386-interix.h +++ b/gcc/config/i386/i386-interix.h @@ -234,13 +234,6 @@ Boston, MA 02111-1307, USA. */ #define EH_FRAME_IN_DATA_SECTION -/* Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. */ - #define USE_CONST_SECTION 1 #define CONST_SECTION_ASM_OP "\t.section\t.rdata,\"r\"" @@ -402,8 +395,8 @@ do { \ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -extern void i386_pe_unique_section (); -#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) +extern void i386_pe_unique_section PARAMS ((tree, int)); +#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section #define SUPPORTS_ONE_ONLY 1 #endif /* 0 */ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 8d939f2e0984..c5250f6534bd 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3822,7 +3822,7 @@ ix86_asm_file_end (file) get_identifier ("i686.get_pc_thunk"), error_mark_node); DECL_ONE_ONLY (decl) = 1; - UNIQUE_SECTION (decl, 0); + (*targetm.asm_out.unique_section) (decl, 0); named_section (decl, NULL); } else diff --git a/gcc/config/i386/sco5.h b/gcc/config/i386/sco5.h index 1682eda49dfe..0fc142763de4 100644 --- a/gcc/config/i386/sco5.h +++ b/gcc/config/i386/sco5.h @@ -540,28 +540,9 @@ init_section () \ == void_type_node))) ? (SIZE) \ : 0)) -#undef SELECT_SECTION -#define SELECT_SECTION(DECL,RELOC,ALIGN) \ -{ \ - if (TARGET_ELF && flag_pic && RELOC) \ - data_section (); \ - else if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if (! DECL_READONLY_SECTION (DECL, RELOC)) \ - data_section (); \ - else \ - const_section (); \ - } \ - else \ - const_section (); \ -} +/* ??? Ignore coff. */ +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION default_elf_select_section #undef SWITCH_TAKES_ARG #define SWITCH_TAKES_ARG(CHAR) \ diff --git a/gcc/config/i386/svr3gas.h b/gcc/config/i386/svr3gas.h index 00dd408f7c68..489a0dc6852c 100644 --- a/gcc/config/i386/svr3gas.h +++ b/gcc/config/i386/svr3gas.h @@ -83,16 +83,7 @@ Boston, MA 02111-1307, USA. */ this file should be rewritten to include config/svr3.h and override what isn't right. */ -/* Support const sections and the ctors and dtors sections for g++. - Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. - However, use of the const section is turned off by default - unless the specific tm.h file turns it on by defining - USE_CONST_SECTION as 1. */ +/* Support const sections and the ctors and dtors sections for g++. */ #define USE_CONST_SECTION 0 @@ -172,35 +163,6 @@ const_section () \ #define TARGET_ASM_CONSTRUCTOR ix86_svr3_asm_out_constructor -/* 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. */ - -#define SELECT_SECTION(DECL,RELOC,ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \ - || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - data_section (); \ - else \ - const_section (); \ - } \ - else \ - const_section (); \ -} - /* A C statement or statements to switch to the appropriate section for output of RTX in mode MODE. RTX is some kind of constant in RTL. The argument MODE is redundant except diff --git a/gcc/config/i386/win32.h b/gcc/config/i386/win32.h index 561118b558db..2119a19dc754 100644 --- a/gcc/config/i386/win32.h +++ b/gcc/config/i386/win32.h @@ -2,7 +2,7 @@ hosting on Windows NT 3.x, using a Unix style C library and tools, as distinct from winnt.h, which is used to build GCC for use with a windows style library and tool set and uses the Microsoft tools. - Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -184,8 +184,8 @@ do { \ symbols must be explicitly imported from shared libraries (DLLs). */ #define MULTIPLE_SYMBOL_SPACES -extern void i386_pe_unique_section (); -#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC) +extern void i386_pe_unique_section PARAMS ((tree, int)); +#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section #define SUPPORTS_ONE_ONLY 1 diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index b8bb39e727b1..08f144f626bb 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -1,6 +1,7 @@ /* Subroutines for insn-output.c for Windows NT. Contributed by Douglas Rupp (drupp@cs.washington.edu) - Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -423,8 +424,6 @@ i386_pe_encode_section_info (decl, first) } } -/* Cover function for UNIQUE_SECTION. */ - void i386_pe_unique_section (decl, reloc) tree decl; diff --git a/gcc/config/i860/paragon.h b/gcc/config/i860/paragon.h index 6ed94ad70eb5..f55b8859fe09 100644 --- a/gcc/config/i860/paragon.h +++ b/gcc/config/i860/paragon.h @@ -1,5 +1,5 @@ /* Target definitions for GNU compiler for Intel 80860 running OSF/1AD - Copyright (C) 1991, 1996, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1991, 1996, 1999, 2000, 2002 Free Software Foundation, Inc. Based upon original work of Ron Guilmette (rfg@monkeys.com). Contributed by Andy Pfiffer (andyp@ssd.intel.com). Partially inspired by @@ -181,7 +181,7 @@ Boston, MA 02111-1307, USA. */ #undef DTORS_SECTION_ASM_OP #undef DO_GLOBAL_CTORS_BODY #undef ASM_OUTPUT_DESTRUCTOR -#undef SELECT_SECTION +#undef TARGET_ASM_SELECT_SECTION #undef SELECT_RTX_SECTION #undef READONLY_DATA_SECTION diff --git a/gcc/config/ia64/aix.h b/gcc/config/ia64/aix.h index fee073213e29..0e66a5dcb085 100644 --- a/gcc/config/ia64/aix.h +++ b/gcc/config/ia64/aix.h @@ -132,47 +132,10 @@ do { \ #define STANDARD_STARTFILE_PREFIX "/usr/lib/ia64l64/" #endif -/* Override SELECT_SECTION and SELECT_RTX_SECTION from config/ia64/sysv4.h; - these definitions ignore flag_pic as if it were always set; - it is illegal to have relocations in shared segments on AIX. */ - -/* 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. */ - -#undef SELECT_SECTION -#define SELECT_SECTION(DECL,RELOC,ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if (XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0] \ - == SDATA_NAME_FLAG_CHAR) \ - sdata_section (); \ - /* ??? We need the extra ! RELOC check, because the default is to \ - only check RELOC if flag_pic is set, and we don't set flag_pic \ - (yet?). */ \ - else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC)) \ - const_section (); \ - else \ - data_section (); \ - } \ - /* This could be a CONSTRUCTOR containing ADDR_EXPR of a VAR_DECL, \ - in which case we can't put it in a shared library rodata. */ \ - else if (RELOC) \ - data_section (); \ - else \ - const_section (); \ -} - -/* Similarly for constant pool data. */ +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION ia64_aix_select_section +#undef TARGET_ASM_UNIQUE_SECTION +#define TARGET_ASM_UNIQUE_SECTION ia64_aix_unique_section extern unsigned int ia64_section_threshold; #undef SELECT_RTX_SECTION @@ -187,49 +150,6 @@ extern unsigned int ia64_section_threshold; const_section (); \ } -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL, RELOC) \ - do \ - { \ - int len; \ - int sec; \ - const char *name; \ - char *string; \ - const char *prefix; \ - static const char *const prefixes[/*4*/3][2] = \ - { \ - { ".text.", ".gnu.linkonce.t." }, \ - { ".rodata.", ".gnu.linkonce.r." }, \ - { ".data.", ".gnu.linkonce.d." } \ - /* Do not generate unique sections for uninitialised \ - data since we do not have support for this in the \ - linker scripts yet... \ - ,{ ".bss.", ".gnu.linkonce.b." } */ \ - }; \ - \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ - sec = 0; \ - /* else if (DECL_INITIAL (DECL) == 0 \ - || DECL_INITIAL (DECL) == error_mark_node) \ - sec = 3; */ \ - else if (DECL_READONLY_SECTION (DECL, RELOC) && ! (RELOC))\ - sec = 1; \ - else \ - sec = 2; \ - \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - /* Strip off any encoding in name. */ \ - STRIP_NAME_ENCODING (name, name); \ - prefix = prefixes[sec][DECL_ONE_ONLY(DECL)]; \ - len = strlen (name) + strlen (prefix); \ - string = alloca (len + 1); \ - \ - sprintf (string, "%s%s", prefix, name); \ - \ - DECL_SECTION_NAME (DECL) = build_string (len, string); \ - } \ - while (0) - /* Override ia64/sysv4.h setting with that used by AIX5. */ #undef WCHAR_TYPE #ifdef __64BIT__ diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 562c977f677f..f6f6c551bce0 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -125,6 +125,7 @@ static void ia64_free_machine_status PARAMS ((struct function *)); static void emit_insn_group_barriers PARAMS ((FILE *, rtx)); static void emit_all_insn_group_barriers PARAMS ((FILE *, rtx)); static void emit_predicate_relation_info PARAMS ((void)); +static bool ia64_in_small_data_p PARAMS ((tree)); static void process_epilogue PARAMS ((void)); static int process_set PARAMS ((FILE *, rtx)); @@ -152,6 +153,11 @@ static int ia64_sched_reorder PARAMS ((FILE *, int, rtx *, int *, int)); static int ia64_sched_reorder2 PARAMS ((FILE *, int, rtx *, int *, int)); static int ia64_variable_issue PARAMS ((FILE *, int, rtx, int)); +static void ia64_aix_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)) + ATTRIBUTE_UNUSED; +static void ia64_aix_unique_section PARAMS ((tree, int)) + ATTRIBUTE_UNUSED; /* Table of valid machine attributes. */ static const struct attribute_spec ia64_attribute_table[] = @@ -195,6 +201,9 @@ static const struct attribute_spec ia64_attribute_table[] = #undef TARGET_ASM_FUNCTION_EPILOGUE #define TARGET_ASM_FUNCTION_EPILOGUE ia64_output_function_epilogue +#undef TARGET_IN_SMALL_DATA_P +#define TARGET_IN_SMALL_DATA_P ia64_in_small_data_p + #undef TARGET_SCHED_ADJUST_COST #define TARGET_SCHED_ADJUST_COST ia64_adjust_cost #undef TARGET_SCHED_ISSUE_RATE @@ -6858,9 +6867,32 @@ ia64_eh_uses (regno) code faster because there is one less load. This also includes incomplete types which can't go in sdata/sbss. */ -/* ??? See select_section. We must put short own readonly variables in - sdata/sbss instead of the more natural rodata, because we can't perform - the DECL_READONLY_SECTION test here. */ +static bool +ia64_in_small_data_p (exp) + tree exp; +{ + if (TARGET_NO_SDATA) + return false; + + if (TREE_CODE (exp) == VAR_DECL && DECL_SECTION_NAME (exp)) + { + const char *section = TREE_STRING_POINTER (DECL_SECTION_NAME (exp)); + if (strcmp (section, ".sdata") == 0 + || strcmp (section, ".sbss") == 0) + return true; + } + else + { + HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); + + /* If this is an incomplete type with size 0, then we can't put it + in sdata because it might be too big when completed. */ + if (size > 0 && size <= ia64_section_threshold) + return true; + } + + return false; +} void ia64_encode_section_info (decl, first) @@ -6868,6 +6900,8 @@ ia64_encode_section_info (decl, first) int first ATTRIBUTE_UNUSED; { const char *symbol_str; + bool is_local, is_small; + rtx symbol; if (TREE_CODE (decl) == FUNCTION_DECL) { @@ -6880,76 +6914,64 @@ ia64_encode_section_info (decl, first) || GET_CODE (DECL_RTL (decl)) != MEM || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) return; - - symbol_str = XSTR (XEXP (DECL_RTL (decl), 0), 0); - - /* We assume that -fpic is used only to create a shared library (dso). - With -fpic, no global data can ever be sdata. - Without -fpic, global common uninitialized data can never be sdata, since - it can unify with a real definition in a dso. */ - /* ??? Actually, we can put globals in sdata, as long as we don't use gprel - to access them. The linker may then be able to do linker relaxation to - optimize references to them. Currently sdata implies use of gprel. */ - /* We need the DECL_EXTERNAL check for C++. static class data members get - both TREE_STATIC and DECL_EXTERNAL set, to indicate that they are - statically allocated, but the space is allocated somewhere else. Such - decls can not be own data. */ - if (! TARGET_NO_SDATA - && ((TREE_STATIC (decl) && ! DECL_EXTERNAL (decl) - && ! (DECL_ONE_ONLY (decl) || DECL_WEAK (decl)) - && ! (TREE_PUBLIC (decl) - && (flag_pic - || (DECL_COMMON (decl) - && (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node))))) - || MODULE_LOCAL_P (decl)) - /* Either the variable must be declared without a section attribute, - or the section must be sdata or sbss. */ - && (DECL_SECTION_NAME (decl) == 0 - || ! strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), - ".sdata") - || ! strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME (decl)), - ".sbss"))) - { - HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); - - /* If the variable has already been defined in the output file, then it - is too late to put it in sdata if it wasn't put there in the first - place. The test is here rather than above, because if it is already - in sdata, then it can stay there. */ - - if (TREE_ASM_WRITTEN (decl)) - ; - - /* If this is an incomplete type with size 0, then we can't put it in - sdata because it might be too big when completed. - Objects bigger than threshold should have SDATA_NAME_FLAG_CHAR - added if they are in .sdata or .sbss explicitely. */ - else if (((size > 0 - && size <= (HOST_WIDE_INT) ia64_section_threshold) - || DECL_SECTION_NAME (decl)) - && symbol_str[0] != SDATA_NAME_FLAG_CHAR) - { - size_t len = strlen (symbol_str); - char *newstr = alloca (len + 1); - const char *string; - *newstr = SDATA_NAME_FLAG_CHAR; - memcpy (newstr + 1, symbol_str, len + 1); - - string = ggc_alloc_string (newstr, len + 1); - XSTR (XEXP (DECL_RTL (decl), 0), 0) = string; - } - } - /* This decl is marked as being in small data/bss but it shouldn't - be; one likely explanation for this is that the decl has been - moved into a different section from the one it was in when - ENCODE_SECTION_INFO was first called. Remove the '@'. */ - else if (symbol_str[0] == SDATA_NAME_FLAG_CHAR) + symbol = XEXP (DECL_RTL (decl), 0); + symbol_str = XSTR (symbol, 0); + + /* A variable is considered "local" if it is defined by this module. */ + + if (MODULE_LOCAL_P (decl)) + is_local = true; + /* Otherwise, variables defined outside this object may not be local. */ + else if (DECL_EXTERNAL (decl)) + is_local = false; + /* Linkonce and weak data are never local. */ + else if (DECL_ONE_ONLY (decl) || DECL_WEAK (decl)) + is_local = false; + /* Static variables are always local. */ + else if (! TREE_PUBLIC (decl)) + is_local = true; + /* If PIC, then assume that any global name can be overridden by + symbols resolved from other modules. */ + else if (flag_pic) + is_local = false; + /* Uninitialized COMMON variable may be unified with symbols + resolved from other modules. */ + else if (DECL_COMMON (decl) + && (DECL_INITIAL (decl) == NULL + || DECL_INITIAL (decl) == error_mark_node)) + is_local = false; + /* Otherwise we're left with initialized (or non-common) global data + which is of necessity defined locally. */ + else + is_local = true; + + /* Determine if DECL will wind up in .sdata/.sbss. */ + is_small = ia64_in_small_data_p (decl); + + /* Finally, encode this into the symbol string. */ + if (is_local && is_small) { - XSTR (XEXP (DECL_RTL (decl), 0), 0) - = ggc_strdup (symbol_str + 1); + char *newstr; + size_t len; + + if (symbol_str[0] == SDATA_NAME_FLAG_CHAR) + return; + + len = strlen (symbol_str) + 1; + newstr = alloca (len + 1); + newstr[0] = SDATA_NAME_FLAG_CHAR; + memcpy (newstr + 1, symbol_str, len); + + XSTR (symbol, 0) = ggc_alloc_string (newstr, len); } + + /* This decl is marked as being in small data/bss but it shouldn't be; + one likely explanation for this is that the decl has been moved into + a different section from the one it was in when ENCODE_SECTION_INFO + was first called. Remove the '@'. */ + else if (symbol_str[0] == SDATA_NAME_FLAG_CHAR) + XSTR (symbol, 0) = ggc_strdup (symbol_str + 1); } /* Output assembly directives for prologue regions. */ @@ -7820,3 +7842,29 @@ ia64_hpux_function_arg_padding (mode, type) : GET_MODE_BITSIZE (mode) < PARM_BOUNDARY) ? downward : upward); } + +/* It is illegal to have relocations in shared segments on AIX. + Pretend flag_pic is always set. */ + +static void +ia64_aix_select_section (exp, reloc, align) + tree exp; + int reloc; + unsigned HOST_WIDE_INT align; +{ + int save_pic = flag_pic; + flag_pic = 1; + default_elf_select_section (exp, reloc, align); + flag_pic = save_pic; +} + +static void +ia64_aix_unique_section (decl, reloc) + tree decl; + int reloc; +{ + int save_pic = flag_pic; + flag_pic = 1; + default_unique_section (decl, reloc); + flag_pic = save_pic; +} diff --git a/gcc/config/ia64/sysv4.h b/gcc/config/ia64/sysv4.h index f4550b682dbd..1f07b8c0f91b 100644 --- a/gcc/config/ia64/sysv4.h +++ b/gcc/config/ia64/sysv4.h @@ -140,135 +140,6 @@ do { \ emit_safe_across_calls (STREAM); \ } while (0) -/* 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. - - Set SECNUM to: - 0 .text - 1 .rodata - 2 .data - 3 .sdata - 4 .bss - 5 .sbss -*/ -#define DO_SELECT_SECTION(SECNUM, DECL, RELOC) \ - do \ - { \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - SECNUM = 0x101; \ - else \ - SECNUM = 2; \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if (XSTR (XEXP (DECL_RTL (DECL), 0), 0)[0] \ - == SDATA_NAME_FLAG_CHAR) \ - SECNUM = 3; \ - /* ??? We need the extra RELOC check, because the default \ - is to only check RELOC if flag_pic is set, and we don't \ - set flag_pic (yet?). */ \ - else if (!DECL_READONLY_SECTION (DECL, RELOC) || (RELOC)) \ - SECNUM = 2; \ - else if (flag_merge_constants < 2) \ - /* C and C++ don't allow different variables to share \ - the same location. -fmerge-all-constants allows \ - even that (at the expense of not conforming). */ \ - SECNUM = 1; \ - else if (TREE_CODE (DECL_INITIAL (DECL)) == STRING_CST) \ - SECNUM = 0x201; \ - else \ - SECNUM = 0x301; \ - } \ - /* This could be a CONSTRUCTOR containing ADDR_EXPR of a VAR_DECL, \ - in which case we can't put it in a shared library rodata. */ \ - else if (flag_pic && (RELOC)) \ - SECNUM = 3; \ - else \ - SECNUM = 2; \ - } \ - while (0) - -/* We override svr4.h so that we can support the sdata section. */ - -#undef SELECT_SECTION -#define SELECT_SECTION(DECL,RELOC,ALIGN) \ - do \ - { \ - typedef void (*sec_fn) PARAMS ((void)); \ - static sec_fn const sec_functions[6] = \ - { \ - text_section, \ - const_section, \ - data_section, \ - sdata_section, \ - bss_section, \ - sbss_section \ - }; \ - \ - int sec; \ - \ - DO_SELECT_SECTION (sec, DECL, RELOC); \ - \ - switch (sec) \ - { \ - case 0x101: \ - mergeable_string_section (DECL, ALIGN, 0); \ - break; \ - case 0x201: \ - mergeable_string_section (DECL_INITIAL (DECL), \ - ALIGN, 0); \ - break; \ - case 0x301: \ - mergeable_constant_section (DECL_MODE (DECL), \ - ALIGN, 0); \ - break; \ - default: \ - (*sec_functions[sec]) (); \ - break; \ - } \ - } \ - while (0) - -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL, RELOC) \ - do \ - { \ - static const char * const prefixes[6][2] = \ - { \ - { ".text.", ".gnu.linkonce.t." }, \ - { ".rodata.", ".gnu.linkonce.r." }, \ - { ".data.", ".gnu.linkonce.d." }, \ - { ".sdata.", ".gnu.linkonce.s." }, \ - { ".bss.", ".gnu.linkonce.b." }, \ - { ".sbss.", ".gnu.linkonce.sb." } \ - }; \ - \ - int nlen, plen, sec; \ - const char *name, *prefix; \ - char *string; \ - \ - DO_SELECT_SECTION (sec, DECL, RELOC); \ - \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - STRIP_NAME_ENCODING (name, name); \ - nlen = strlen (name); \ - \ - prefix = prefixes[sec & 0xff][DECL_ONE_ONLY(DECL)]; \ - plen = strlen (prefix); \ - \ - string = alloca (nlen + plen + 1); \ - \ - memcpy (string, prefix, plen); \ - memcpy (string + plen, name, nlen + 1); \ - \ - DECL_SECTION_NAME (DECL) = build_string (nlen + plen, string); \ - } \ - while (0) - /* Similarly for constant pool data. */ extern unsigned int ia64_section_threshold; diff --git a/gcc/config/m32r/m32r-protos.h b/gcc/config/m32r/m32r-protos.h index 86adde0166d0..cb8714d898eb 100644 --- a/gcc/config/m32r/m32r-protos.h +++ b/gcc/config/m32r/m32r-protos.h @@ -1,5 +1,5 @@ /* Prototypes for m32r.c functions used in the md file & elsewhere. - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -33,10 +33,8 @@ extern void m32r_finalize_pic PARAMS ((void)); extern void m32r_asm_file_start PARAMS ((FILE *)); extern int direct_return PARAMS ((void)); #ifdef TREE_CODE -extern void m32r_select_section PARAMS ((tree, int)); extern void m32r_encode_section_info PARAMS ((tree, int)); extern enum m32r_function_type m32r_compute_function_type PARAMS ((tree)); -extern void m32r_select_section PARAMS ((tree, int)); #ifdef HAVE_MACHINE_MODES extern void m32r_setup_incoming_varargs PARAMS ((CUMULATIVE_ARGS *, Mmode, tree, int *, int)); diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 32dff3ab23c5..4851127138fd 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -74,6 +74,8 @@ static int m32r_sched_reorder PARAMS ((FILE *, int, rtx *, int *, int)); static int m32r_variable_issue PARAMS ((FILE *, int, rtx, int)); static int m32r_issue_rate PARAMS ((void)); +static void m32r_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)); + /* Initialize the GCC target structure. */ #undef TARGET_ATTRIBUTE_TABLE @@ -320,10 +322,11 @@ m32r_handle_model_attribute (node, name, args, flags, no_add_attrs) or a constant of some sort. RELOC indicates whether forming the initial value of DECL requires link-time relocations. */ -void -m32r_select_section (decl, reloc) +static void +m32r_select_section (decl, reloc, align) tree decl; int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; { if (TREE_CODE (decl) == STRING_CST) { diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index 8d9aeebb7c77..f0b783a7ea87 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -1567,13 +1567,8 @@ sbss_section () \ } \ } \ -/* A C statement or statements to switch to the appropriate section for - output of EXP. You can assume that EXP is either a `VAR_DECL' node - or a constant of some sort. RELOC indicates whether the initial value - of EXP requires link-time relocations. */ -#undef SELECT_SECTION -#define SELECT_SECTION(EXP, RELOC, ALIGN) \ - m32r_select_section ((EXP), (RELOC)) +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION m32r_select_section /* A C statement or statements to switch to the appropriate section for output of RTX in mode MODE. You can assume that RTX diff --git a/gcc/config/m68k/dpx2.h b/gcc/config/m68k/dpx2.h index 06dfd50514db..fa6557b43602 100644 --- a/gcc/config/m68k/dpx2.h +++ b/gcc/config/m68k/dpx2.h @@ -1,6 +1,7 @@ /* Definitions of target machine for GNU compiler. Bull DPX/2 200 and 300 systems (m68k, SysVr3). - Copyright (C) 1987, 1993, 1994, 1995, 1996, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1987, 1993, 1994, 1995, 1996, 1999, 2000, 2002 + Free Software Foundation, Inc. Contributed by Frederic Pierresteguy (F.Pierresteguy@frcl.bull.fr). This file is part of GNU CC. @@ -42,7 +43,7 @@ Boston, MA 02111-1307, USA. */ /* Remove handling for a separate constant data section. We put constant data in text_section, which is the default. */ -#undef SELECT_SECTION +#undef TARGET_ASM_SELECT_SECTION #undef SELECT_RTX_SECTION #undef EXTRA_SECTIONS #undef EXTRA_SECTION_FUNCTIONS diff --git a/gcc/config/m88k/m88k.c b/gcc/config/m88k/m88k.c index 80f3ff44b479..6fdcf4b10951 100644 --- a/gcc/config/m88k/m88k.c +++ b/gcc/config/m88k/m88k.c @@ -1,6 +1,6 @@ /* Subroutines for insn-output.c for Motorola 88000. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001 Free Software Foundation, Inc. + 2001, 2002 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@mcc.com) Currently maintained by (gcc@dg-rtp.dg.com) @@ -71,7 +71,7 @@ static void m88k_output_function_begin_epilogue PARAMS ((FILE *)); static void m88k_svr3_asm_out_constructor PARAMS ((rtx, int)); static void m88k_svr3_asm_out_destructor PARAMS ((rtx, int)); #endif - +static void m88k_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)); static int m88k_adjust_cost PARAMS ((rtx, rtx, rtx, int)); /* Initialize the GCC target structure. */ @@ -3320,6 +3320,38 @@ m88k_svr3_asm_out_destructor (symbol, priority) } #endif /* INIT_SECTION_ASM_OP && ! OBJECT_FORMAT_ELF */ +static void +m88k_select_section (decl, reloc, align) + tree decl; + int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if (TREE_CODE (decl) == STRING_CST) + { + if (! flag_writable_strings) + const_section (); + else if (TREE_STRING_LENGTH (decl) <= m88k_gp_threshold) + sdata_section (); + else + data_section (); + } + else if (TREE_CODE (decl) == VAR_DECL) + { + if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (decl), 0))) + sdata_section (); + else if ((flag_pic && reloc) + || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) + || !DECL_INITIAL (decl) + || (DECL_INITIAL (decl) != error_mark_node + && !TREE_CONSTANT (DECL_INITIAL (decl)))) + data_section (); + else + const_section (); + } + else + const_section (); +} + /* Adjust the cost of INSN based on the relationship between INSN that is dependent on DEP_INSN through the dependence LINK. The default is to make no adjustment to COST. diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h index 2373b9dbbcaf..17b6b7bbb867 100644 --- a/gcc/config/m88k/m88k.h +++ b/gcc/config/m88k/m88k.h @@ -2354,40 +2354,7 @@ sdata_section () \ INIT_SECTION_FUNCTION \ FINI_SECTION_FUNCTION -/* 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. - - For strings, the section is selected before the segment info is encoded. */ -#undef SELECT_SECTION -#define SELECT_SECTION(DECL,RELOC,ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else if ( TREE_STRING_LENGTH (DECL) <= m88k_gp_threshold) \ - sdata_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if (SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0))) \ - sdata_section (); \ - else if ((flag_pic && RELOC) \ - || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - data_section (); \ - else \ - const_section (); \ - } \ - else \ - const_section (); \ -} +#define TARGET_ASM_SELECT_SECTION m88k_select_section /* Jump tables consist of branch instructions and should be output in the text section. When we use a table of addresses, we explicitly diff --git a/gcc/config/mcore/mcore-pe.h b/gcc/config/mcore/mcore-pe.h index efd90871451b..5fd3b8d7ddaa 100644 --- a/gcc/config/mcore/mcore-pe.h +++ b/gcc/config/mcore/mcore-pe.h @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler, for MCore using COFF/PE. - Copyright (C) 1994, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1994, 1999, 2000, 2002 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com). This file is part of GNU CC. @@ -80,35 +80,6 @@ rdata_section () \ #undef READONLY_DATA_SECTION #define READONLY_DATA_SECTION() rdata_section () -/* 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. */ -#undef SELECT_SECTION -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - rdata_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \ - || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - data_section (); \ - else \ - rdata_section (); \ - } \ - else \ - rdata_section (); \ -} - /* A C statement or statements to switch to the appropriate section for output of RTX in mode MODE. RTX is some kind of constant in RTL. The argument MODE is redundant except diff --git a/gcc/config/mcore/mcore-protos.h b/gcc/config/mcore/mcore-protos.h index d6f6e2e8a46c..5cda48c6976c 100644 --- a/gcc/config/mcore/mcore-protos.h +++ b/gcc/config/mcore/mcore-protos.h @@ -1,5 +1,5 @@ /* Prototypes for exported functions defined in mcore.c - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 2002 Free Software Foundation, Inc. Contributed by Nick Clifton (nickc@redhat.com) This file is part of GNU CC. @@ -35,7 +35,6 @@ extern int mcore_dllimport_name_p PARAMS ((const char *)); extern int mcore_naked_function_p PARAMS ((void)); #ifdef TREE_CODE -extern void mcore_unique_section PARAMS ((tree, int)); extern void mcore_encode_section_info PARAMS ((tree, int)); #ifdef HAVE_MACHINE_MODES diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index 2acd158da06b..f9f5ae28ad44 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -1,5 +1,5 @@ /* Output routines for Motorola MCore processor - Copyright (C) 1993, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1993, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -137,6 +137,7 @@ static tree mcore_handle_naked_attribute PARAMS ((tree *, tree, tree, int, static void mcore_asm_named_section PARAMS ((const char *, unsigned int)); #endif +static void mcore_unique_section PARAMS ((tree, int)); /* Initialize the GCC target structure. */ #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES @@ -153,6 +154,8 @@ static void mcore_asm_named_section PARAMS ((const char *, #undef TARGET_ATTRIBUTE_TABLE #define TARGET_ATTRIBUTE_TABLE mcore_attribute_table +#undef TARGET_ASM_UNIQUE_SECTION +#define TARGET_ASM_UNIQUE_SECTION mcore_unique_section struct gcc_target targetm = TARGET_INITIALIZER; @@ -3511,9 +3514,10 @@ mcore_handle_naked_attribute (node, name, args, flags, no_add_attrs) return NULL_TREE; } -/* Cover function for UNIQUE_SECTION. */ +/* ??? It looks like this is PE specific? Oh well, this is what the + old code did as well. */ -void +static void mcore_unique_section (decl, reloc) tree decl; int reloc ATTRIBUTE_UNUSED; diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index 6ef9613030a1..32ceac64adae 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -1143,9 +1143,6 @@ switch_to_section (section, decl) \ #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \ (VAR) = MCORE_STRIP_NAME_ENCODING (SYM_NAME) -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL, RELOC) mcore_unique_section (DECL, RELOC) - #define MULTIPLE_SYMBOL_SPACES 1 #define SUPPORTS_ONE_ONLY 1 diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h index 5add2f12d604..d3267379bf1e 100644 --- a/gcc/config/mips/elf.h +++ b/gcc/config/mips/elf.h @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler. MIPS R3000 version with GOFAST floating point library. - Copyright (C) 1994, 1997, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1994, 1997, 1999, 2000, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -219,9 +219,8 @@ do { \ } while (0) #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL,RELOC) \ - mips_unique_section ((DECL), (RELOC)) + +#define TARGET_ASM_UNIQUE_SECTION mips_unique_section /* A list of other sections which the compiler might be "in" at any given time. */ diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h index 1015573b0618..a162fc41a9f7 100644 --- a/gcc/config/mips/elf64.h +++ b/gcc/config/mips/elf64.h @@ -1,6 +1,7 @@ /* Definitions of target machine for GNU compiler. MIPS R4000 version with GOFAST floating point library. - Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -208,9 +209,8 @@ do { \ } while (0) #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL,RELOC) \ - mips_unique_section ((DECL), (RELOC)) + +#define TARGET_ASM_UNIQUE_SECTION mips_unique_section /* A list of other sections which the compiler might be "in" at any given time. */ diff --git a/gcc/config/mips/iris6gld.h b/gcc/config/mips/iris6gld.h index addc0f7d82ec..75556a0feb66 100644 --- a/gcc/config/mips/iris6gld.h +++ b/gcc/config/mips/iris6gld.h @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler. Iris version 6 with GNU ld. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. Written by Mark Mitchell . This file is part of GNU CC. @@ -49,42 +49,4 @@ Boston, MA 02111-1307, USA. */ /* The GNU linker supports one-only sections. */ #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION(DECL, RELOC) \ - do \ - { \ - int len; \ - int sec; \ - const char *name; \ - char *string; \ - const char *prefix; \ - static const char *const prefixes[/*4*/3][2] = \ - { \ - { ".text.", ".gnu.linkonce.t." }, \ - { ".rodata.", ".gnu.linkonce.r." }, \ - { ".data.", ".gnu.linkonce.d." } \ - /* Do not generate unique sections for uninitialised \ - data since we do not have support for this in the \ - linker scripts yet... \ - , { ".bss.", ".gnu.linkonce.b." } */ \ - }; \ - \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ - sec = 0; \ - /* else if (DECL_INITIAL (DECL) == 0 \ - || DECL_INITIAL (DECL) == error_mark_node) \ - sec = 3; */ \ - else if (DECL_READONLY_SECTION (DECL, RELOC)) \ - sec = 1; \ - else \ - sec = 2; \ - \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - prefix = prefixes[sec][DECL_ONE_ONLY(DECL)]; \ - len = strlen (name) + strlen (prefix); \ - string = alloca (len + 1); \ - \ - sprintf (string, "%s%s", prefix, name); \ - \ - DECL_SECTION_NAME (DECL) = build_string (len, string); \ - } \ - while (0) +#define TARGET_ASM_UNIQUE_SECTION mips_unique_section diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h index 7e2b9ea671ea..755a8c002286 100644 --- a/gcc/config/mips/linux.h +++ b/gcc/config/mips/linux.h @@ -88,9 +88,7 @@ do { \ mips_declare_object (FILE, NAME, "", ":\n", 0); \ } while (0) -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL,RELOC) \ - mips_unique_section ((DECL), (RELOC)) +#define TARGET_ASM_UNIQUE_SECTION mips_unique_section /* A list of other sections which the compiler might be "in" at any given time. */ diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h index 29854f03a01b..2158a02c75ea 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -1,6 +1,6 @@ /* Prototypes of target machine for GNU compiler. MIPS version. Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2001 Free Software Foundation, Inc. + 1999, 2001, 2002 Free Software Foundation, Inc. Contributed by A. Lichnewsky (lich@inria.inria.fr). Changed by Michael Meissner (meissner@osf.org). 64 bit r4000 support by Ian Lance Taylor (ian@cygnus.com) and @@ -79,8 +79,6 @@ extern int mips_output_external PARAMS ((FILE *, tree, extern tree mips_build_va_list PARAMS ((void)); extern void mips_va_start PARAMS ((int, tree, rtx)); extern struct rtx_def *mips_va_arg PARAMS ((tree, tree)); -extern void mips_select_section PARAMS ((tree, int)); -extern void mips_unique_section PARAMS ((tree, int)); extern void expand_block_move PARAMS ((rtx *)); extern void final_prescan_insn PARAMS ((rtx, rtx *, int)); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 72f332509262..b93e53180d81 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -1,6 +1,6 @@ /* Subroutines for insn-output.c for MIPS Copyright (C) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by A. Lichnewsky, lich@inria.inria.fr. Changes by Michael Meissner, meissner@osf.org. 64 bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and @@ -146,6 +146,11 @@ static int mips_issue_rate PARAMS ((void)); static void mips_init_machine_status PARAMS ((struct function *)); static void mips_free_machine_status PARAMS ((struct function *)); static void mips_mark_machine_status PARAMS ((struct function *)); +static void mips_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)) + ATTRIBUTE_UNUSED; +static void mips_unique_section PARAMS ((tree, int)) + ATTRIBUTE_UNUSED; + struct machine_function { /* Pseudo-reg holding the address of the current function when @@ -7943,10 +7948,11 @@ mips_select_rtx_section (mode, x) If you need to make a change here, you probably should check ENCODE_SECTION_INFO to see if it needs a similar change. */ -void -mips_select_section (decl, reloc) +static void +mips_select_section (decl, reloc, align) tree decl; int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; { int size = int_size_in_bytes (TREE_TYPE (decl)); @@ -10145,9 +10151,10 @@ mips_adjust_cost (insn, link, dep, cost) return cost; } -/* Cover function for UNIQUE_SECTION. */ +/* ??? This could be replaced with the default elf version if + TARGET_IS_SMALL_DATA_P is set properly. */ -void +static void mips_unique_section (decl, reloc) tree decl; int reloc; diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index a6467c066ddc..dba54e658167 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -4738,10 +4738,8 @@ rdata_section () \ #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \ mips_select_rtx_section (MODE, RTX) -#undef SELECT_SECTION -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ - mips_select_section (DECL, RELOC) - +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION mips_select_section /* Store in OUTPUT a string (made with alloca) containing an assembler-name for a local static variable named NAME. diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h index eb9c24c60217..cc81308c9b6c 100644 --- a/gcc/config/mmix/mmix-protos.h +++ b/gcc/config/mmix/mmix-protos.h @@ -74,9 +74,7 @@ extern int mmix_constant_alignment PARAMS ((tree, int)); extern int mmix_local_alignment PARAMS ((tree, int)); extern void mmix_setup_incoming_varargs PARAMS ((CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int)); -extern void mmix_select_section PARAMS ((tree, int, int)); extern void mmix_encode_section_info PARAMS ((tree, int)); -extern void mmix_unique_section PARAMS ((tree, int)); extern void mmix_asm_output_pool_prologue PARAMS ((FILE *, const char *, tree, int)); extern void mmix_asm_output_aligned_common diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index af06624e1df6..40bd94f8d740 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -1713,46 +1713,6 @@ mmix_data_section_asm_op () return "\t.data ! mmixal:= 8H LOC 9B"; } -/* SELECT_SECTION. - The meat is from elfos.h, which we will eventually consider using. */ - -void -mmix_select_section (decl, reloc, align) - tree decl; - int reloc; - int align ATTRIBUTE_UNUSED; -{ - if (TREE_CODE (decl) == STRING_CST) - { - if (! flag_writable_strings) - const_section (); - else - data_section (); - } - else if (TREE_CODE (decl) == VAR_DECL) - { - if ((flag_pic && reloc) - || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) - || !DECL_INITIAL (decl) - || (DECL_INITIAL (decl) != error_mark_node - && !TREE_CONSTANT (DECL_INITIAL (decl)))) - data_section (); - else - const_section (); - } - else if (TREE_CODE (decl) == CONSTRUCTOR) - { - if ((flag_pic && reloc) - || !TREE_READONLY (decl) || TREE_SIDE_EFFECTS (decl) - || ! TREE_CONSTANT (decl)) - data_section (); - else - const_section (); - } - else - const_section (); -} - /* ENCODE_SECTION_INFO. */ void @@ -1818,49 +1778,6 @@ mmix_strip_name_encoding (name) return name; } -/* UNIQUE_SECTION. - The meat is from elfos.h, which we should consider using. */ - -void -mmix_unique_section (decl, reloc) - tree decl; - int reloc; -{ - int len; - int sec; - const char *name; - char *string; - const char *prefix; - static const char *const prefixes[4][2] = - { - { ".text.", ".gnu.linkonce.t." }, - { ".rodata.", ".gnu.linkonce.r." }, - { ".data.", ".gnu.linkonce.d." }, - { ".bss.", ".gnu.linkonce.b." } - }; - - if (TREE_CODE (decl) == FUNCTION_DECL) - sec = 0; - else if (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node) - sec = 3; - else if (DECL_READONLY_SECTION (decl, reloc)) - sec = 1; - else - sec = 2; - - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in name. */ - STRIP_NAME_ENCODING (name, name); - prefix = prefixes[sec][DECL_ONE_ONLY (decl)]; - len = strlen (name) + strlen (prefix); - string = alloca (len + 1); - - sprintf (string, "%s%s", prefix, name); - - DECL_SECTION_NAME (decl) = build_string (len, string); -} - /* ASM_FILE_START. */ void diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 3abfe29f6a2c..c603ebb5c1af 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -929,18 +929,12 @@ const_section () \ #undef SELECT_RTX_SECTION #define SELECT_RTX_SECTION(MODE, RTX, ALIGN) const_section () -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ - mmix_select_section (DECL, RELOC, ALIGN) - #define ENCODE_SECTION_INFO(DECL, FIRST) \ mmix_encode_section_info (DECL, FIRST) #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \ (VAR) = mmix_strip_name_encoding (SYM_NAME) -#define UNIQUE_SECTION(DECL, RELOC) \ - mmix_unique_section (decl, reloc) - /* Node: PIC */ /* (empty) */ diff --git a/gcc/config/netware.h b/gcc/config/netware.h index 129fa3921796..dbb247740b15 100644 --- a/gcc/config/netware.h +++ b/gcc/config/netware.h @@ -1,6 +1,6 @@ /* netware.h -- operating system specific defines to be used when targeting GCC for some generic NetWare 4 system. - Copyright (C) 1993, 1994, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 2000, 2001, 2002 Free Software Foundation, Inc. Written by David V. Henkel-Wallace (gumby@cygnus.com) @@ -56,13 +56,7 @@ Boston, MA 02111-1307, USA. */ #undef PREFERRED_DEBUGGING_TYPE #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG -/* Support const sections and the ctors and dtors sections for g++. - Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. */ +/* Support const sections and the ctors and dtors sections for g++. */ #undef HAS_INIT_SECTION #undef INIT_SECTION_ASM_OP diff --git a/gcc/config/nextstep-protos.h b/gcc/config/nextstep-protos.h index 1f86e1d9b3bb..e5b520ddf27e 100644 --- a/gcc/config/nextstep-protos.h +++ b/gcc/config/nextstep-protos.h @@ -1,6 +1,6 @@ /* Operating system specific defines to be used when targeting GCC for NeXTSTEP. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -26,3 +26,5 @@ extern void constructor_section PARAMS ((void)); extern void destructor_section PARAMS ((void)); extern void nextstep_exception_section PARAMS ((void)); extern void nextstep_eh_frame_section PARAMS ((void)); +extern void nextstep_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)); diff --git a/gcc/config/nextstep.c b/gcc/config/nextstep.c index 228c5662a2d0..a701776ff27f 100644 --- a/gcc/config/nextstep.c +++ b/gcc/config/nextstep.c @@ -1,6 +1,6 @@ /* Functions for generic NeXT as target machine for GNU C compiler. Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997, 1998, - 2000 Free Software Foundation, Inc. + 2000, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -115,3 +115,123 @@ nextstep_asm_out_destructor (symbol, priority) fprintf (asm_out_file, ".reference .destructors_used\n"); } +void +nextstep_select_section (exp, reloc, align) + tree exp; + int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if (TREE_CODE (exp) == STRING_CST) + { + if (flag_writable_strings) + data_section (); + else if (TREE_STRING_LENGTH (exp) + != strlen (TREE_STRING_POINTER (exp)) + 1) + readonly_data_section (); + else + cstring_section (); + } + else if (TREE_CODE (exp) == INTEGER_CST + || TREE_CODE (exp) == REAL_CST) + { + tree size = TYPE_SIZE (TREE_TYPE (exp)); + HOST_WIDE_INT size_int; + + if (TREE_CODE (size) == INTEGER_CST) + size_int = tree_low_cst (size, 1); + else + size_int = 0; + + if (size_int == 4) + literal4_section (); + else if (size_int == 8) + literal8_section (); + else + readonly_data_section (); + } + else if (TREE_CODE (exp) == CONSTRUCTOR + && TREE_TYPE (exp) + && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE + && TYPE_NAME (TREE_TYPE (exp)) + && TREE_CODE (TYPE_NAME (TREE_TYPE (exp))) == IDENTIFIER_NODE + && IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp)))) + { + if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))), + "NXConstantString")) + objc_string_object_section (); + else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) + && !TREE_SIDE_EFFECTS (exp)) + readonly_data_section (); + else + data_section (); + } + else if (TREE_CODE (exp) == VAR_DECL + && DECL_NAME (exp) + && TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE + && IDENTIFIER_POINTER (DECL_NAME (exp)) + && !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) + { + const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); + + if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) + objc_cls_meth_section (); + else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) + objc_inst_meth_section (); + else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) + objc_cat_inst_meth_section (); + else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) + objc_class_vars_section (); + else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) + objc_instance_vars_section (); + else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) + objc_class_names_section (); + else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) + objc_meth_var_names_section (); + else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) + objc_meth_var_types_section (); + else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) + objc_cls_refs_section (); + else if (!strncmp (name, "_OBJC_CLASS_", 12)) + objc_class_section (); + else if (!strncmp (name, "_OBJC_METACLASS_", 16)) + objc_meta_class_section (); + else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) + objc_category_section (); + else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) + objc_selector_refs_section (); + else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) + objc_symbols_section (); + else if (!strncmp (name, "_OBJC_MODULES", 13)) + objc_module_info_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) + objc_cat_inst_meth_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) + objc_cat_cls_meth_section (); + else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) + objc_protocol_section (); + else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) + && !TREE_SIDE_EFFECTS (exp)) + readonly_data_section (); + else + data_section (); + } + else if (TREE_CODE (exp) == VAR_DECL) + { + if ((flag_pic && reloc) + || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp) + || !DECL_INITIAL (exp) + || (DECL_INITIAL (exp) != error_mark_node + && !TREE_CONSTANT (DECL_INITIAL (exp)))) + data_section (); + else + readonly_data_section (); + } + else + readonly_data_section (); +} diff --git a/gcc/config/nextstep.h b/gcc/config/nextstep.h index 850f0e64137a..b96e365ac288 100644 --- a/gcc/config/nextstep.h +++ b/gcc/config/nextstep.h @@ -1,7 +1,7 @@ /* Operating system specific defines to be used when targeting GCC for NeXTSTEP. Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997, - 1999 Free Software Foundation, Inc. + 1999, 2002 Free Software Foundation, Inc. This file is part of GNU CC. @@ -442,123 +442,8 @@ objc_section_init () \ #undef READONLY_DATA_SECTION #define READONLY_DATA_SECTION const_section -#undef SELECT_SECTION -#define SELECT_SECTION(exp,reloc,align) \ - do \ - { \ - if (TREE_CODE (exp) == STRING_CST) \ - { \ - if (flag_writable_strings) \ - data_section (); \ - else if (TREE_STRING_LENGTH (exp) != \ - strlen (TREE_STRING_POINTER (exp)) + 1) \ - readonly_data_section (); \ - else \ - cstring_section (); \ - } \ - else if (TREE_CODE (exp) == INTEGER_CST \ - || TREE_CODE (exp) == REAL_CST) \ - { \ - tree size = TYPE_SIZE (TREE_TYPE (exp)); \ - \ - if (TREE_CODE (size) == INTEGER_CST && \ - TREE_INT_CST_LOW (size) == 4 && \ - TREE_INT_CST_HIGH (size) == 0) \ - literal4_section (); \ - else if (TREE_CODE (size) == INTEGER_CST && \ - TREE_INT_CST_LOW (size) == 8 && \ - TREE_INT_CST_HIGH (size) == 0) \ - literal8_section (); \ - else \ - readonly_data_section (); \ - } \ - else if (TREE_CODE (exp) == CONSTRUCTOR \ - && TREE_TYPE (exp) \ - && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \ - && TYPE_NAME (TREE_TYPE (exp)) \ - && TREE_CODE (TYPE_NAME (TREE_TYPE (exp))) == IDENTIFIER_NODE \ - && IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp)))) \ - { \ - if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))), \ - "NXConstantString")) \ - objc_string_object_section (); \ - else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - && !TREE_SIDE_EFFECTS (exp)) \ - readonly_data_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (exp) == VAR_DECL && \ - DECL_NAME (exp) && \ - TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \ - IDENTIFIER_POINTER (DECL_NAME (exp)) && \ - !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \ - { \ - const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \ - \ - if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \ - objc_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \ - objc_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \ - objc_cat_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \ - objc_class_vars_section (); \ - else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \ - objc_instance_vars_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \ - objc_class_names_section (); \ - else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \ - objc_meth_var_names_section (); \ - else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \ - objc_meth_var_types_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \ - objc_cls_refs_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_", 12)) \ - objc_class_section (); \ - else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \ - objc_meta_class_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \ - objc_category_section (); \ - else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \ - objc_selector_refs_section (); \ - else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \ - objc_symbols_section (); \ - else if (!strncmp (name, "_OBJC_MODULES", 13)) \ - objc_module_info_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \ - objc_cat_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \ - objc_protocol_section (); \ - else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - && !TREE_SIDE_EFFECTS (exp)) \ - readonly_data_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (exp) == VAR_DECL) \ - { \ - if ((flag_pic && reloc) \ - || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp) \ - || !DECL_INITIAL (exp) \ - || (DECL_INITIAL (exp) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (exp)))) \ - data_section (); \ - else \ - readonly_data_section (); \ - } \ - else \ - readonly_data_section (); \ - } \ - while (0) +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION nextstep_select_section #undef SELECT_RTX_SECTION #define SELECT_RTX_SECTION(mode, rtx, align) \ diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 8e93194f6539..babf1a86e01d 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -114,6 +114,8 @@ static void pa_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); static int pa_adjust_cost PARAMS ((rtx, rtx, rtx, int)); static int pa_adjust_priority PARAMS ((rtx, int)); static int pa_issue_rate PARAMS ((void)); +static void pa_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)) + ATTRIBUTE_UNUSED; /* Save the operands last given to a compare for use when we generate a scc or bcc insn. */ @@ -7566,3 +7568,30 @@ pa_add_gc_roots () ggc_add_root (&deferred_plabels, 1, sizeof (&deferred_plabels), &mark_deferred_plabels); } + +/* On hpux10, the linker will give an error if we have a reference + in the read-only data section to a symbol defined in a shared + library. Therefore, expressions that might require a reloc can + not be placed in the read-only data section. */ + +static void +pa_select_section (exp, reloc, align) + tree exp; + int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if (TREE_CODE (exp) == VAR_DECL + && TREE_READONLY (exp) + && !TREE_THIS_VOLATILE (exp) + && DECL_INITIAL (exp) + && (DECL_INITIAL (exp) == error_mark_node + || TREE_CONSTANT (DECL_INITIAL (exp))) + && !reloc) + readonly_data_section (); + else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c' + && !(TREE_CODE (exp) == STRING_CST && flag_writable_strings) + && !reloc) + readonly_data_section (); + else + data_section (); +} diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index b4f076819574..af19b64d0510 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -1503,25 +1503,7 @@ do { \ else \ readonly_data_section (); -/* On hpux10, the linker will give an error if we have a reference - in the read-only data section to a symbol defined in a shared - library. Therefore, expressions that might require a reloc can - not be placed in the read-only data section. */ -#define SELECT_SECTION(EXP,RELOC,ALIGN) \ - if (TREE_CODE (EXP) == VAR_DECL \ - && TREE_READONLY (EXP) \ - && !TREE_THIS_VOLATILE (EXP) \ - && DECL_INITIAL (EXP) \ - && (DECL_INITIAL (EXP) == error_mark_node \ - || TREE_CONSTANT (DECL_INITIAL (EXP))) \ - && !RELOC) \ - readonly_data_section (); \ - else if (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'c' \ - && !(TREE_CODE (EXP) == STRING_CST && flag_writable_strings) \ - && !RELOC) \ - readonly_data_section (); \ - else \ - data_section (); +#define TARGET_ASM_SELECT_SECTION pa_select_section /* Define this macro if references to a symbol must be treated differently depending on something about the variable or diff --git a/gcc/config/pa/pa64-hpux.h b/gcc/config/pa/pa64-hpux.h index c4a6b27df8bf..4469e378dbc0 100644 --- a/gcc/config/pa/pa64-hpux.h +++ b/gcc/config/pa/pa64-hpux.h @@ -171,36 +171,6 @@ const_section () \ #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1) -#define UNIQUE_SECTION(DECL,RELOC) \ -do { \ - int len; \ - char *string; \ - const char *prefix, \ - *const name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));\ - \ - if (! DECL_ONE_ONLY (DECL)) \ - { \ - prefix = "."; \ - if (TREE_CODE (DECL) == FUNCTION_DECL) \ - prefix = ".text."; \ - else if (DECL_READONLY_SECTION (DECL, RELOC)) \ - prefix = ".rodata."; \ - else \ - prefix = ".data."; \ - } \ - else if (TREE_CODE (DECL) == FUNCTION_DECL) \ - prefix = ".gnu.linkonce.t."; \ - else if (DECL_READONLY_SECTION (DECL, RELOC)) \ - prefix = ".gnu.linkonce.r."; \ - else \ - prefix = ".gnu.linkonce.d."; \ - \ - len = strlen (name) + strlen (prefix); \ - string = alloca (len + 1); \ - sprintf (string, "%s%s", prefix, name); \ - \ - DECL_SECTION_NAME (DECL) = build_string (len, string); \ -} while (0) /* Define the strings used for the special svr4 .type and .size directives. These strings generally do not vary from one system running svr4 to diff --git a/gcc/config/rs6000/lynx.h b/gcc/config/rs6000/lynx.h index 5a859ca27b7d..5416abba3ed9 100644 --- a/gcc/config/rs6000/lynx.h +++ b/gcc/config/rs6000/lynx.h @@ -1,5 +1,5 @@ /* Definitions for Rs6000 running LynxOS. - Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2000, 2002 Free Software Foundation, Inc. Contributed by David Henkel-Wallace, Cygnus Support (gumby@cygnus.com) This file is part of GNU CC. @@ -29,7 +29,7 @@ Boston, MA 02111-1307, USA. */ #undef READONLY_DATA_SECTION #undef EXTRA_SECTION_FUNCTIONS #undef SELECT_RTX_SECTION -#undef SELECT_SECTION +#undef TARGET_ASM_SELECT_SECTION #undef USER_LABEL_PREFIX #undef ASM_OUTPUT_LABELREF #undef ASM_OUTPUT_INTERNAL_LABEL diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index 954366334ba5..06114d3a4a5e 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler, for IBM RS/6000. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) This file is part of GNU CC. @@ -148,8 +148,6 @@ extern void setup_incoming_varargs PARAMS ((CUMULATIVE_ARGS *, extern struct rtx_def *rs6000_va_arg PARAMS ((tree, tree)); extern void output_mi_thunk PARAMS ((FILE *, tree, int, tree)); extern void rs6000_encode_section_info PARAMS ((tree, int)); -extern void rs6000_select_section PARAMS ((tree, int)); -extern void rs6000_unique_section PARAMS ((tree, int)); #ifdef ARGS_SIZE_RTX /* expr.h defines ARGS_SIZE_RTX and `enum direction' */ extern enum direction function_arg_padding PARAMS ((enum machine_mode, tree)); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 44e70dbc3844..e803e2eebb71 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -163,9 +163,15 @@ static unsigned int rs6000_elf_section_type_flags PARAMS ((tree, const char *, int)); static void rs6000_elf_asm_out_constructor PARAMS ((rtx, int)); static void rs6000_elf_asm_out_destructor PARAMS ((rtx, int)); +static void rs6000_elf_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)); +static void rs6000_elf_unique_section PARAMS ((tree, int)); #endif #ifdef OBJECT_FORMAT_COFF static void xcoff_asm_named_section PARAMS ((const char *, unsigned int)); +static void rs6000_xcoff_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)); +static void rs6000_xcoff_unique_section PARAMS ((tree, int)); #endif static int rs6000_adjust_cost PARAMS ((rtx, rtx, rtx, int)); static int rs6000_adjust_priority PARAMS ((rtx, int)); @@ -10954,10 +10960,11 @@ rs6000_select_rtx_section (mode, x) or a constant of some sort. RELOC indicates whether forming the initial value of DECL requires link-time relocations. */ -void -rs6000_select_section (decl, reloc) +static void +rs6000_elf_select_section (decl, reloc, align) tree decl; int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; { int size = int_size_in_bytes (TREE_TYPE (decl)); int needs_sdata; @@ -11003,8 +11010,8 @@ rs6000_select_section (decl, reloc) macro can now be called for uninitialized data items as well as initialised data and functions. */ -void -rs6000_unique_section (decl, reloc) +static void +rs6000_elf_unique_section (decl, reloc) tree decl; int reloc; { @@ -11628,4 +11635,52 @@ xcoff_asm_named_section (name, flags) { fprintf (asm_out_file, "\t.csect %s\n", name); } + +static void +rs6000_xcoff_select_section (exp, reloc, align) + tree exp; + int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if ((TREE_CODE (exp) == STRING_CST + && ! flag_writable_strings) + || (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd' + && TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp) + && DECL_INITIAL (exp) + && (DECL_INITIAL (exp) == error_mark_node + || TREE_CONSTANT (DECL_INITIAL (exp))) + && ! (reloc))) + { + if (TREE_PUBLIC (exp)) + read_only_data_section (); + else + read_only_private_data_section (); + } + else + { + if (TREE_PUBLIC (exp)) + data_section (); + else + private_data_section (); + } +} + +static void +rs6000_xcoff_unique_section (decl, reloc) + tree decl; + int reloc; +{ + const char *name; + char *string; + size_t len; + + if (TREE_CODE (decl) == FUNCTION_DECL) + { + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + len = strlen (name) + 5; + string = alloca (len + 1); + sprintf (string, ".%s[PR]", name); + DECL_SECTION_NAME (decl) = build_string (len, string); + } +} #endif diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index cf0c6682ce8e..2eff24c97621 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -1,5 +1,5 @@ /* Target definitions for GNU compiler for PowerPC running System V.4 - Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -567,8 +567,8 @@ fini_section () \ the initial value of DECL requires link-time relocations. */ /* Override elfos.h definition. */ -#undef SELECT_SECTION -#define SELECT_SECTION(DECL, RELOC, ALIGN) rs6000_select_section (DECL, RELOC) +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION rs6000_elf_select_section /* A C statement to build up a unique section name, expressed as a STRING_CST node, and assign it to DECL_SECTION_NAME (decl). @@ -578,9 +578,8 @@ fini_section () \ macro can now be called for uninitialized data items as well as initialised data and functions. */ -/* Override elfos.h definition. */ -#undef UNIQUE_SECTION -#define UNIQUE_SECTION(DECL, RELOC) rs6000_unique_section (DECL, RELOC) +/* Override default elf definition. */ +#define TARGET_ASM_UNIQUE_SECTION rs6000_elf_unique_section /* Return non-zero 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 diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 9fcedf8de5cd..cae5a37e7588 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -140,30 +140,7 @@ toc_section () \ On the RS/6000, we have a special section for all variables except those that are static. */ -#define SELECT_SECTION(EXP,RELOC,ALIGN) \ -{ \ - if ((TREE_CODE (EXP) == STRING_CST \ - && ! flag_writable_strings) \ - || (TREE_CODE_CLASS (TREE_CODE (EXP)) == 'd' \ - && TREE_READONLY (EXP) && ! TREE_THIS_VOLATILE (EXP) \ - && DECL_INITIAL (EXP) \ - && (DECL_INITIAL (EXP) == error_mark_node \ - || TREE_CONSTANT (DECL_INITIAL (EXP))) \ - && ! (RELOC))) \ - { \ - if (TREE_PUBLIC (EXP)) \ - read_only_data_section (); \ - else \ - read_only_private_data_section (); \ - } \ - else \ - { \ - if (TREE_PUBLIC (EXP)) \ - data_section (); \ - else \ - private_data_section (); \ - } \ -} +#define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section /* Return non-zero 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 @@ -468,20 +445,7 @@ toc_section () \ #define DATA_SECTION_ASM_OP "\t.csect .data[RW],3" /* Define unique section name -- functions only. */ -#define UNIQUE_SECTION(DECL,RELOC) \ - do { \ - int len; \ - const char *name; \ - char *string; \ - \ - if (TREE_CODE (DECL) == FUNCTION_DECL) { \ - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \ - len = strlen (name) + 5; \ - string = alloca (len + 1); \ - sprintf (string, ".%s[PR]", name); \ - DECL_SECTION_NAME (DECL) = build_string (len, string); \ - } \ - } while (0) +#define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section /* Switch into a generic section. */ #define TARGET_ASM_NAMED_SECTION xcoff_asm_named_section diff --git a/gcc/config/sparc/aout.h b/gcc/config/sparc/aout.h index 3a2273f488bf..292f164cd1fc 100644 --- a/gcc/config/sparc/aout.h +++ b/gcc/config/sparc/aout.h @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler, for SPARC using a.out. - Copyright (C) 1994, 1996 Free Software Foundation, Inc. + Copyright (C) 1994, 1996, 2002 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com). This file is part of GNU CC. @@ -37,36 +37,7 @@ Boston, MA 02111-1307, USA. */ (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \ || !strcmp (STR, "target") || !strcmp (STR, "assert")) -/* This is defined differently for v9 in a cover file. */ -#define SELECT_SECTION(T,RELOC,ALIGN) \ -{ \ - if (TREE_CODE (T) == VAR_DECL) \ - { \ - if (TREE_READONLY (T) && ! TREE_SIDE_EFFECTS (T) \ - && DECL_INITIAL (T) \ - && (DECL_INITIAL (T) == error_mark_node \ - || TREE_CONSTANT (DECL_INITIAL (T))) \ - && DECL_ALIGN (T) <= MAX_TEXT_ALIGN \ - && ! (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))) \ - text_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (T) == CONSTRUCTOR) \ - { \ - if (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES)) \ - data_section (); \ - } \ - else if (TREE_CODE_CLASS (TREE_CODE (T)) == 'c') \ - { \ - if ((TREE_CODE (T) == STRING_CST && flag_writable_strings) \ - || TYPE_ALIGN (TREE_TYPE (T)) > MAX_TEXT_ALIGN \ - || (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))) \ - data_section (); \ - else \ - text_section (); \ - } \ -} +#define TARGET_ASM_SELECT_SECTION sparc_aout_select_section /* Output the label for a function definition. */ diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index ad1b3c0c65e6..2f8e36cfdb87 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -1,6 +1,6 @@ /* Subroutines for insn-output.c for Sun SPARC. Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans, at Cygnus Support. @@ -157,6 +157,9 @@ static void sparc_nonflat_function_prologue PARAMS ((FILE *, HOST_WIDE_INT, #ifdef OBJECT_FORMAT_ELF static void sparc_elf_asm_named_section PARAMS ((const char *, unsigned int)); #endif +static void sparc_aout_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)) + ATTRIBUTE_UNUSED; static int sparc_adjust_cost PARAMS ((rtx, rtx, rtx, int)); static int sparc_issue_rate PARAMS ((void)); @@ -8040,6 +8043,19 @@ sparc_elf_asm_named_section (name, flags) } #endif /* OBJECT_FORMAT_ELF */ +/* ??? Similar to the standard section selection, but force reloc-y-ness + if SUNOS4_SHARED_LIBRARIES. Unclear why this helps (as opposed to + pretending PIC always on), but that's what the old code did. */ + +static void +sparc_aout_select_section (t, reloc, align) + tree t; + int reloc; + unsigned HOST_WIDE_INT align; +{ + default_select_section (t, reloc | SUNOS4_SHARED_LIBRARIES, align) +} + int sparc_extra_constraint_check (op, c, strict) rtx op; diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index 099fac0d8cba..4c49ad8ec6ec 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -2545,18 +2545,6 @@ do { \ be defined. */ /* #define READONLY_DATA_SECTION */ -/* A C statement or statements to switch to the appropriate section for output - of EXP. You can assume that EXP is either a `VAR_DECL' node or a constant - of some sort. RELOC indicates whether the initial value of EXP requires - link-time relocations. Select the section by calling `text_section' or one - of the alternatives for other sections. - - Do not define this macro if you put all read-only variables and constants in - the read-only data section (usually the text section). - - Defined in svr4.h. */ -/* #define SELECT_SECTION(EXP, RELOC, ALIGN) */ - /* 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' @@ -2594,16 +2582,6 @@ do { \ that encode section info. Define this macro if `ENCODE_SECTION_INFO' alters the symbol's name string. */ /* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */ - -/* A C statement to build up a unique section name, expressed as a - STRING_CST node, and assign it to `DECL_SECTION_NAME (DECL)'. - RELOC indicates whether the initial value of EXP requires - link-time relocations. If you do not define this macro, GNU CC - will use the symbol name prefixed by `.' as the section name. - - Defined in svr4.h. */ -/* #define UNIQUE_SECTION(DECL, RELOC) */ - /* Position Independent Code. */ diff --git a/gcc/config/svr3.h b/gcc/config/svr3.h index 4de6f52670c8..5e3ddc948527 100644 --- a/gcc/config/svr3.h +++ b/gcc/config/svr3.h @@ -1,6 +1,6 @@ /* Operating system specific defines to be used when targeting GCC for generic System V Release 3 system. - Copyright (C) 1991, 1996, 2000 Free Software Foundation, Inc. + Copyright (C) 1991, 1996, 2000, 2002 Free Software Foundation, Inc. Contributed by Ron Guilmette (rfg@monkeys.com). This file is part of GNU CC. @@ -188,16 +188,7 @@ Boston, MA 02111-1307, USA. #undef LOCAL_LABEL_PREFIX #define LOCAL_LABEL_PREFIX "." -/* Support const sections and the ctors and dtors sections for g++. - Note that there appears to be two different ways to support const - sections at the moment. You can either #define the symbol - READONLY_DATA_SECTION (giving it some code which switches to the - readonly data section) or else you can #define the symbols - EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and - SELECT_RTX_SECTION. We do both here just to be on the safe side. - However, use of the const section is turned off by default - unless the specific tm.h file turns it on by defining - USE_CONST_SECTION as 1. */ +/* Support const sections and the ctors and dtors sections for g++. */ /* Define a few machine-specific details of the implementation of constructors. @@ -291,36 +282,6 @@ const_section () \ } \ } -/* 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. */ - -#undef SELECT_SECTION -#define SELECT_SECTION(DECL,RELOC,ALIGN) \ -{ \ - if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (DECL) == VAR_DECL) \ - { \ - if ((0 && RELOC) /* should be (flag_pic && RELOC) */ \ - || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - data_section (); \ - else \ - const_section (); \ - } \ - else \ - const_section (); \ -} - /* A C statement or statements to switch to the appropriate section for output of RTX in mode MODE. RTX is some kind of constant in RTL. The argument MODE is redundant except diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index a20e4ff50420..c47e47b3dcd1 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -58,6 +58,7 @@ const struct attribute_spec v850_attribute_table[]; static tree v850_handle_interrupt_attribute PARAMS ((tree *, tree, tree, int, bool *)); static tree v850_handle_data_area_attribute PARAMS ((tree *, tree, tree, int, bool *)); static void v850_insert_attributes PARAMS ((tree, tree *)); +static void v850_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)); /* True if the current function has anonymous arguments. */ int current_function_anonymous_args; @@ -96,6 +97,9 @@ static int v850_interrupt_p = FALSE; #undef TARGET_INSERT_ATTRIBUTES #define TARGET_INSERT_ATTRIBUTES v850_insert_attributes +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION v850_select_section + struct gcc_target targetm = TARGET_INITIALIZER; /* Sometimes certain combinations of command options do not make @@ -2845,3 +2849,60 @@ v850_return_addr (count) return get_hard_reg_initial_val (Pmode, LINK_POINTER_REGNUM); } + +static void +v850_select_section (exp, reloc, align) + tree exp; + int reloc; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if (TREE_CODE (exp) == VAR_DECL) + { + int is_const; + if (!TREE_READONLY (exp) + || TREE_SIDE_EFFECTS (exp) + || !DECL_INITIAL (exp) + || (DECL_INITIAL (exp) != error_mark_node + && !TREE_CONSTANT (DECL_INITIAL (exp)))) + is_const = FALSE; + else + is_const = TRUE; + + switch (v850_get_data_area (exp)) + { + case DATA_AREA_ZDA: + if (is_const) + rozdata_section (); + else + zdata_section (); + break; + + case DATA_AREA_TDA: + tdata_section (); + break; + + case DATA_AREA_SDA: + if (is_const) + rosdata_section (); + else + sdata_section (); + break; + + default: + if (is_const) + const_section (); + else + data_section (); + break; + } + } + else if (TREE_CODE (exp) == STRING_CST) + { + if (! flag_writable_strings) + const_section (); + else + data_section (); + } + else + const_section (); +} diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index b7f63670a56c..4f637ff7095f 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -1119,71 +1119,6 @@ zbss_section () \ #define ZCOMMON_ASM_OP "\t.zcomm\t" #define TCOMMON_ASM_OP "\t.tcomm\t" -/* A C statement or statements to switch to the appropriate section - for output of EXP. You can assume that EXP is either a `VAR_DECL' - node or a constant of some sort. RELOC indicates whether the - initial value of EXP requires link-time relocations. Select the - section by calling `text_section' or one of the alternatives for - other sections. - - Do not define this macro if you put all read-only variables and - constants in the read-only data section (usually the text section). */ -#undef SELECT_SECTION -#define SELECT_SECTION(EXP, RELOC, ALIGN) \ -do { \ - if (TREE_CODE (EXP) == VAR_DECL) \ - { \ - int is_const; \ - if (!TREE_READONLY (EXP) \ - || TREE_SIDE_EFFECTS (EXP) \ - || !DECL_INITIAL (EXP) \ - || (DECL_INITIAL (EXP) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (EXP)))) \ - is_const = FALSE; \ - else \ - is_const = TRUE; \ - \ - switch (v850_get_data_area (EXP)) \ - { \ - case DATA_AREA_ZDA: \ - if (is_const) \ - rozdata_section (); \ - else \ - zdata_section (); \ - break; \ - \ - case DATA_AREA_TDA: \ - tdata_section (); \ - break; \ - \ - case DATA_AREA_SDA: \ - if (is_const) \ - rosdata_section (); \ - else \ - sdata_section (); \ - break; \ - \ - default: \ - if (is_const) \ - const_section (); \ - else \ - data_section (); \ - break; \ - } \ - } \ - else if (TREE_CODE (EXP) == STRING_CST) \ - { \ - if (! flag_writable_strings) \ - const_section (); \ - else \ - data_section (); \ - } \ - \ - else \ - const_section (); \ - \ -} while (0) - /* 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 diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 9665609df2a4..fc1d9fa5b109 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -42,6 +42,7 @@ static void vax_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); #if VMS_TARGET static void vms_asm_out_constructor PARAMS ((rtx, int)); static void vms_asm_out_destructor PARAMS ((rtx, int)); +static void vms_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)); #endif /* Initialize the GCC target structure. */ @@ -51,6 +52,11 @@ static void vms_asm_out_destructor PARAMS ((rtx, int)); #undef TARGET_ASM_FUNCTION_PROLOGUE #define TARGET_ASM_FUNCTION_PROLOGUE vax_output_function_prologue +#if VMS_TARGET +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION vms_select_section +#endif + struct gcc_target targetm = TARGET_INITIALIZER; /* Generate the assembly code for function entry. FILE is a stdio @@ -871,6 +877,36 @@ vms_asm_out_destructor (symbol, priority) assemble_name (asm_out_file, XSTR (symbol, 0)); fputc ('\n', asm_out_file); } + +static void +vax_select_section (exp, reloc, align) + tree exp; + int reloc ATTRIBUTE_UNUSED; + unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED; +{ + if (TREE_CODE (exp) == VAR_DECL) + { + if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp) + && DECL_INITIAL (exp) + && (DECL_INITIAL (exp) == error_mark_node + || TREE_CONSTANT (DECL_INITIAL (exp)))) + { + if (TREE_PUBLIC (exp)) + const_section (); + else + text_section (); + } + else + data_section (); + } + if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c') + { + if (TREE_CODE (exp) == STRING_CST && flag_writable_strings) + data_section (); + else + text_section (); + } +} #endif /* VMS_TARGET */ /* Additional support code for VMS host. */ diff --git a/gcc/config/vax/vms.h b/gcc/config/vax/vms.h index 69eced9db1db..1703e9bf3041 100644 --- a/gcc/config/vax/vms.h +++ b/gcc/config/vax/vms.h @@ -1,5 +1,6 @@ /* Output variables, constants and external declarations, for GNU compiler. - Copyright (C) 1988, 1994, 1995, 1996, 1997, 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1988, 1994, 1995, 1996, 1997, 1999, 2001, 2002 + Free Software Foundation, Inc. This file is part of GNU CC. @@ -210,40 +211,6 @@ const_section () \ } \ } -/* This macro contains the logic to decide which section a variable - should be stored in. Static constant variables go in the text_section, - non-const variables go in the data_section, and non-static const - variables go in the const_section. - - Since this macro is used in a number of places, we must also be able - to decide where to place string constants. */ - -#define SELECT_SECTION(T,RELOC,ALIGN) \ -{ \ - if (TREE_CODE (T) == VAR_DECL) \ - { \ - if (TREE_READONLY (T) && ! TREE_THIS_VOLATILE (T) \ - && DECL_INITIAL (T) \ - && (DECL_INITIAL (T) == error_mark_node \ - || TREE_CONSTANT (DECL_INITIAL (T)))) \ - { \ - if (TREE_PUBLIC (T)) \ - const_section (); \ - else \ - text_section (); \ - } \ - else \ - data_section (); \ - } \ - if (TREE_CODE_CLASS (TREE_CODE (T)) == 'c') \ - { \ - if ((TREE_CODE (T) == STRING_CST && flag_writable_strings)) \ - data_section (); \ - else \ - text_section (); \ - } \ -} - /* This is used by a hook in varasm.c to write the assembler directives that are needed to tell the startup code which constructors need to be run. */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index bbb2c5010bde..f3b379fb896d 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5752,21 +5752,6 @@ switches to the section to be used for read-only items. If these items should be placed in the text section, this macro should not be defined. -@findex SELECT_SECTION -@item SELECT_SECTION (@var{exp}, @var{reloc}, @var{align}) -A C statement or statements to switch to the appropriate section for -output of @var{exp}. 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 1 is set when variable contains local relocations -only, while bit 2 is set for global relocations. -Select the section by calling @code{text_section} or one -of the alternatives for other sections. @var{align} is the constant -alignment in bits. - -Do not define this macro if you put all read-only variables and -constants in the read-only data section (usually the text section). - @findex SELECT_RTX_SECTION @item SELECT_RTX_SECTION (@var{mode}, @var{rtx}, @var{align}) A C statement or statements to switch to the appropriate section for @@ -5820,18 +5805,34 @@ enough information). Decode @var{sym_name} and store the real name part in @var{var}, sans the characters that encode section info. Define this macro if @code{ENCODE_SECTION_INFO} alters the symbol's name string. - -@findex UNIQUE_SECTION -@item UNIQUE_SECTION (@var{decl}, @var{reloc}) -A C statement to build up a unique section name, expressed as a -@code{STRING_CST} node, and assign it to @samp{DECL_SECTION_NAME (@var{decl})}. -@var{reloc} indicates whether the initial value of @var{exp} requires -link-time relocations. If you do not define this macro, GCC will use -the symbol name prefixed by @samp{.} as the section name. Note - this -macro can now be called for uninitialized data items as well as -initialized data and functions. @end table +@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 +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. + +The default version of this function takes care of putting read-only +variables in @code{readonly_data_section}. +@end deftypefn + +@deftypefn {Target Hook} void TARGET_ASM_UNIQUE_SECTION (tree @var{decl}, int @var{reloc}) +Build up a unique section name, expressed as a @code{STRING_CST} node, +and assign it to @samp{DECL_SECTION_NAME (@var{decl})}. +As with @code{TARGET_ASM_SELECT_SECTION}, @var{reloc} indicates whether +the initial value of @var{exp} requires link-time relocations. + +The default version of this function appends the symbol name to the +ELF section name that would normally be used for the symbol. For +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 + @node PIC @section Position Independent Code @cindex position independent code diff --git a/gcc/hooks.c b/gcc/hooks.c index 387f4db961a8..c5371e915e64 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -32,3 +32,11 @@ hook_void_bool_false () { return false; } + +/* Generic hook that takes (tree) and returns false. */ +bool +hook_tree_bool_false (a) + tree a ATTRIBUTE_UNUSED; +{ + return false; +} diff --git a/gcc/hooks.h b/gcc/hooks.h index 7a8daa55d7fd..0358ae934eb1 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -20,3 +20,4 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. what you give them. Help stamp out software-hoarding! */ bool hook_void_bool_false PARAMS ((void)); +bool hook_tree_bool_false PARAMS ((tree)); diff --git a/gcc/output.h b/gcc/output.h index a33f15b2c16a..2c8dbd638bed 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -543,6 +543,12 @@ extern void default_named_section_asm_out_constructor PARAMS ((struct rtx_def *, extern void default_ctor_section_asm_out_constructor PARAMS ((struct rtx_def *, int)); +extern void default_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)); +extern void default_elf_select_section PARAMS ((tree, int, + unsigned HOST_WIDE_INT)); +extern void default_unique_section PARAMS ((tree, int)); + /* Emit data for vtable gc for GNU binutils. */ extern void assemble_vtable_entry PARAMS ((struct rtx_def *, HOST_WIDE_INT)); extern void assemble_vtable_inherit PARAMS ((struct rtx_def *, diff --git a/gcc/target-def.h b/gcc/target-def.h index 76d238e07267..5390efa57abe 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -59,6 +59,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream #define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream +#ifndef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION default_select_section +#endif + +#ifndef TARGET_ASM_UNIQUE_SECTION +#define TARGET_ASM_UNIQUE_SECTION default_unique_section +#endif + #if !defined(TARGET_ASM_CONSTRUCTOR) && !defined(USE_COLLECT2) # ifdef CTORS_SECTION_ASM_OP # define TARGET_ASM_CONSTRUCTOR default_ctor_section_asm_out_constructor @@ -131,6 +139,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_ASM_NAMED_SECTION, \ TARGET_ASM_EXCEPTION_SECTION, \ TARGET_ASM_EH_FRAME_SECTION, \ + TARGET_ASM_SELECT_SECTION, \ + TARGET_ASM_UNIQUE_SECTION, \ TARGET_ASM_CONSTRUCTOR, \ TARGET_ASM_DESTRUCTOR} @@ -192,6 +202,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* In hook.c. */ #define TARGET_CANNOT_MODIFY_JUMPS_P hook_void_bool_false +#define TARGET_IN_SMALL_DATA_P hook_tree_bool_false /* The whole shebang. */ #define TARGET_INITIALIZER \ @@ -211,7 +222,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_SECTION_TYPE_FLAGS, \ TARGET_HAVE_NAMED_SECTIONS, \ TARGET_HAVE_CTORS_DTORS, \ - TARGET_CANNOT_MODIFY_JUMPS_P \ + TARGET_CANNOT_MODIFY_JUMPS_P, \ + TARGET_IN_SMALL_DATA_P \ } #include "hooks.h" diff --git a/gcc/target.h b/gcc/target.h index 1f294126ae94..8b500bd15c64 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -91,6 +91,17 @@ struct gcc_target /* Switch to the section that holds the exception frames. */ void (* eh_frame_section) PARAMS ((void)); + /* Select and switch to a section for EXP. It may be a DECL or a + constant for which TREE_CST_RTL is valid. RELOC is non-zero 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) PARAMS ((tree, int, unsigned HOST_WIDE_INT)); + + /* Select a unique section name for DECL. RELOC is the same as + for SELECT_SECTION. */ + void (* unique_section) PARAMS ((tree, int)); + /* Output a constructor for a symbol with a given priority. */ void (* constructor) PARAMS ((rtx, int)); @@ -224,6 +235,9 @@ struct gcc_target /* True if new jumps cannot be created, to replace existing ones or not, at the current point in the compilation. */ bool (* cannot_modify_jumps_p) PARAMS ((void)); + + /* True if EXP should be placed in a "small data" section. */ + bool (* in_small_data_p) PARAMS ((tree)); }; extern struct gcc_target targetm; diff --git a/gcc/varasm.c b/gcc/varasm.c index 4a8841230282..e13efe0914cb 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -465,10 +465,10 @@ resolve_unique_section (decl, reloc, flag_function_or_data_sections) int flag_function_or_data_sections; { if (DECL_SECTION_NAME (decl) == NULL_TREE + && targetm.have_named_sections && (flag_function_or_data_sections - || (targetm.have_named_sections - && DECL_ONE_ONLY (decl)))) - UNIQUE_SECTION (decl, reloc); + || DECL_ONE_ONLY (decl))) + (*targetm.asm_out.unique_section) (decl, reloc); } #ifdef BSS_SECTION_ASM_OP @@ -567,9 +567,8 @@ function_section (decl) text_section (); } -/* Switch to section for variable DECL. - - RELOC is the `reloc' argument to SELECT_SECTION. */ +/* Switch to section for variable DECL. RELOC is the same as the + argument to SELECT_SECTION. */ void variable_section (decl, reloc) @@ -579,29 +578,7 @@ variable_section (decl, reloc) if (IN_NAMED_SECTION (decl)) named_section (decl, NULL, reloc); else - { - /* C++ can have const variables that get initialized from constructors, - and thus can not be in a readonly section. We prevent this by - verifying that the initial value is constant for objects put in a - readonly section. - - error_mark_node is used by the C front end to indicate that the - initializer has not been seen yet. In this case, we assume that - the initializer must be constant. - - C++ uses error_mark_node for variables that have complicated - initializers, but these variables go in BSS so we won't be called - for them. */ - -#ifdef SELECT_SECTION - SELECT_SECTION (decl, reloc, DECL_ALIGN (decl)); -#else - if (DECL_READONLY_SECTION (decl, reloc)) - readonly_data_section (); - else - data_section (); -#endif - } + (*targetm.asm_out.select_section) (decl, reloc, DECL_ALIGN (decl)); } /* Tell assembler to switch to the section for the exception handling @@ -3211,18 +3188,7 @@ output_constant_def_contents (exp, reloc, labelno) if (IN_NAMED_SECTION (exp)) named_section (exp, NULL, reloc); else - { - /* First switch to text section, except for writable strings. */ -#ifdef SELECT_SECTION - SELECT_SECTION (exp, reloc, align); -#else - if (((TREE_CODE (exp) == STRING_CST) && flag_writable_strings) - || (flag_pic && reloc)) - data_section (); - else - readonly_data_section (); -#endif - } + (*targetm.asm_out.select_section) (exp, reloc, align); if (align > BITS_PER_UNIT) { @@ -5254,3 +5220,267 @@ assemble_vtable_inherit (child, parent) output_addr_const (asm_out_file, parent); fputc ('\n', asm_out_file); } + +/* The lame default section selector. */ + +void +default_select_section (decl, reloc, align) + 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; + } + else if (TREE_CODE (decl) == CONSTRUCTOR) + { + if (! ((flag_pic && reloc) + || !TREE_READONLY (decl) + || TREE_SIDE_EFFECTS (decl) + || !TREE_CONSTANT (decl))) + readonly = true; + } + else if (TREE_CODE (decl) == STRING_CST) + readonly = !flag_writable_strings; + else if (! (flag_pic && reloc)) + readonly = true; + + if (readonly) + readonly_data_section (); + else + data_section (); +} + +/* A helper function for default_elf_select_section and + default_elf_unique_section. Categorizes the DECL. */ + +enum section_category +{ + SECCAT_TEXT, + + SECCAT_RODATA, + SECCAT_RODATA_MERGE_STR, + SECCAT_RODATA_MERGE_STR_INIT, + SECCAT_RODATA_MERGE_CONST, + + SECCAT_DATA, + + /* To optimize loading of shared programs, define following subsections + of data section: + _REL Contains data that has relocations, so they get grouped + together and dynamic linker will visit fewer pages in memory. + _RO Contains data that is otherwise read-only. This is useful + with prelinking as most relocations won't be dynamically + linked and thus stay read only. + _LOCAL Marks data containing relocations only to local objects. + These relocations will get fully resolved by prelinking. */ + SECCAT_DATA_REL, + SECCAT_DATA_REL_LOCAL, + SECCAT_DATA_REL_RO, + SECCAT_DATA_REL_RO_LOCAL, + + SECCAT_SDATA, + SECCAT_TDATA, + + SECCAT_BSS, + SECCAT_SBSS, + SECCAT_TBSS +}; + +static enum section_category categorize_decl_for_section PARAMS ((tree, int)); + +static enum section_category +categorize_decl_for_section (decl, reloc) + tree decl; + int reloc; +{ + enum section_category ret; + + if (TREE_CODE (decl) == FUNCTION_DECL) + return SECCAT_TEXT; + else if (TREE_CODE (decl) == STRING_CST) + { + if (flag_writable_strings) + return SECCAT_DATA; + else + return SECCAT_RODATA_MERGE_STR; + } + else if (TREE_CODE (decl) == VAR_DECL) + { + if (DECL_INITIAL (decl) == NULL + || DECL_INITIAL (decl) == error_mark_node) + ret = SECCAT_BSS; + else if (! TREE_READONLY (decl) + || TREE_SIDE_EFFECTS (decl) + || ! TREE_CONSTANT (DECL_INITIAL (decl))) + { + if (flag_pic && (reloc & 2)) + ret = SECCAT_DATA_REL; + else if (flag_pic && reloc) + ret = SECCAT_DATA_REL_LOCAL; + else + ret = SECCAT_DATA; + } + else if (flag_pic && (reloc & 2)) + ret = SECCAT_DATA_REL_RO; + else if (flag_pic && reloc) + ret = SECCAT_DATA_REL_RO_LOCAL; + else if (flag_merge_constants < 2) + /* C and C++ don't allow different variables to share the same + location. -fmerge-all-constants allows even that (at the + expense of not conforming). */ + ret = SECCAT_RODATA; + else if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST) + ret = SECCAT_RODATA_MERGE_STR_INIT; + else + ret = SECCAT_RODATA_MERGE_CONST; + } + else if (TREE_CODE (decl) == CONSTRUCTOR) + { + if ((flag_pic && reloc) + || TREE_SIDE_EFFECTS (decl) + || ! TREE_CONSTANT (decl)) + ret = SECCAT_DATA; + else + ret = SECCAT_RODATA; + } + else + ret = SECCAT_RODATA; + + /* If the target uses small data sections, select it. */ + if ((*targetm.in_small_data_p) (decl)) + { + if (ret == SECCAT_BSS) + ret = SECCAT_SBSS; + else + ret = SECCAT_SDATA; + } + + return ret; +} + +/* Select a section based on the above categorization. */ + +void +default_elf_select_section (decl, reloc, align) + tree decl; + int reloc; + unsigned HOST_WIDE_INT align; +{ + switch (categorize_decl_for_section (decl, reloc)) + { + case SECCAT_TEXT: + /* We're not supposed to be called on FUNCTION_DECLs. */ + abort (); + case SECCAT_RODATA: + readonly_data_section (); + break; + case SECCAT_RODATA_MERGE_STR: + mergeable_string_section (decl, align, 0); + break; + case SECCAT_RODATA_MERGE_STR_INIT: + mergeable_string_section (DECL_INITIAL (decl), align, 0); + break; + case SECCAT_RODATA_MERGE_CONST: + mergeable_constant_section (DECL_MODE (decl), align, 0); + break; + case SECCAT_DATA: + data_section (); + break; + case SECCAT_DATA_REL: + named_section (NULL_TREE, ".data.rel", reloc); + break; + case SECCAT_DATA_REL_LOCAL: + named_section (NULL_TREE, ".data.rel.local", reloc); + break; + case SECCAT_DATA_REL_RO: + named_section (NULL_TREE, ".data.rel.ro", reloc); + break; + case SECCAT_DATA_REL_RO_LOCAL: + named_section (NULL_TREE, ".data.rel.ro.local", reloc); + break; + case SECCAT_SDATA: + named_section (NULL_TREE, ".sdata", reloc); + break; + case SECCAT_TDATA: + named_section (NULL_TREE, ".tdata", reloc); + break; + case SECCAT_BSS: +#ifdef BSS_SECTION_ASM_OP + bss_section (); +#else + named_section (NULL_TREE, ".bss", reloc); +#endif + break; + case SECCAT_SBSS: + named_section (NULL_TREE, ".sbss", reloc); + break; + case SECCAT_TBSS: + named_section (NULL_TREE, ".tbss", reloc); + break; + default: + abort (); + } +} + +/* Construct a unique section name based on the decl name and the + categorization performed above. */ + +void +default_unique_section (decl, reloc) + tree decl; + int reloc; +{ + bool one_only = DECL_ONE_ONLY (decl); + const char *prefix, *name; + size_t nlen, plen; + char *string; + + switch (categorize_decl_for_section (decl, reloc)) + { + case SECCAT_TEXT: + prefix = one_only ? ".gnu.linkonce.t." : ".text."; + break; + case SECCAT_RODATA: + case SECCAT_RODATA_MERGE_STR: + case SECCAT_RODATA_MERGE_STR_INIT: + case SECCAT_RODATA_MERGE_CONST: + prefix = one_only ? ".gnu.linkonce.r." : ".rodata."; + break; + case SECCAT_DATA: + case SECCAT_DATA_REL: + case SECCAT_DATA_REL_LOCAL: + case SECCAT_DATA_REL_RO: + case SECCAT_DATA_REL_RO_LOCAL: + prefix = one_only ? ".gnu.linkonce.d." : ".data."; + break; + case SECCAT_SDATA: + prefix = one_only ? ".gnu.linkonce.s." : ".sdata."; + break; + case SECCAT_BSS: + prefix = one_only ? ".gnu.linkonce.b." : ".bss."; + break; + case SECCAT_SBSS: + prefix = one_only ? ".gnu.linkonce.sb." : ".sbss."; + break; + case SECCAT_TDATA: + case SECCAT_TBSS: + default: + abort (); + } + plen = strlen (prefix); + + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + STRIP_NAME_ENCODING (name, name); + nlen = strlen (name); + + string = alloca (nlen + plen + 1); + memcpy (string, prefix, plen); + memcpy (string + plen, name, nlen + 1); + + DECL_SECTION_NAME (decl) = build_string (nlen + plen, string); +} -- 2.43.5