diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-10 00:53:09 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-10 00:53:09 +0000 |
commit | 4e151b05f8a87e819f4c0f74fb6dbccc1c6e3f4d (patch) | |
tree | ddb930f60eed9d2395dd9b4695e612928d440a18 /gcc/config | |
parent | 7f0837e316732b8b186f2e2e4b0ef3d58c862894 (diff) | |
download | gcc-4e151b05f8a87e819f4c0f74fb6dbccc1c6e3f4d.tar.gz |
PR target/26090
* target.h (targetm.asm.out.reloc_rw_mask): New.
* target-def.h (TARGET_ASM_RELOC_RW_MASK): New.
(TARGET_ASM_OUT): Use it.
* targhooks.c, targhooks.h (default_reloc_rw_mask): New.
* varasm.c (categorize_decl_for_section): Remove shlib argument;
use the new reloc_rw_mask target hook instead.
(default_section_type_flags_1): Merge into...
(default_section_type_flags): ... here.
(decl_readonly_section_1): Merge into...
(decl_readonly_section): ... here.
(default_elf_select_section_1): Merge into...
(default_elf_select_section): ... here.
(default_unique_section_1): Merge into...
(default_unique_section): ... here.
(compute_reloc_for_rtx_1, compute_reloc_for_rtx): New.
(default_select_rtx_section): Use it.
(default_elf_select_rtx_section): Likewise.
* output.h: Update to match.
* doc/tm.texi (TARGET_ASM_RELOC_RW_MASK): New.
* config/alpha/alpha.c (alpha_elf_reloc_rw_mask): New.
(TARGET_ASM_RELOC_RW_MASK): New.
* config/i386/i386.c (x86_64_elf_select_section): Adjust call
to categorize_decl_for_section.
(x86_64_elf_unique_section): Likewise.
* config/ia64/hpux.h (TARGET_ASM_SELECT_SECTION,
TARGET_ASM_UNIQUE_SECTION, TARGET_ASM_SELECT_RTX_SECTION): Remove.
(TARGET_ASM_RELOC_RW_MASK): New.
* config/ia64/ia64.c (ia64_rwreloc_select_section,
ia64_rwreloc_unique_section, ia64_rwreloc_select_rtx_section): Remove.
(ia64_hpux_reloc_rw_mask, ia64_reloc_rw_mask): New.
(TARGET_RWRELOC): Remove.
(ia64_section_type_flags): Adjust call to default_section_type_flags.
* config/ia64/sysv4.h (TARGET_ASM_RELOC_RW_MASK): New.
* config/rs6000/rs6000.c (rs6000_elf_section_type_flags): Remove.
(rs6000_elf_select_section, rs6000_elf_unique_section): Remove.
(rs6000_elf_reloc_rw_mask, rs6000_xcoff_reloc_rw_mask): New.
(rs6000_xcoff_select_section): Use decl_readonly_section.
(rs6000_xcoff_section_type_flags): Use default_section_type_flags.
* config/rs6000/sysv4.h (TARGET_ASM_RELOC_RW_MASK): New.
(TARGET_ASM_SELECT_SECTION, TARGET_ASM_UNIQUE_SECTION): Remove.
(TARGET_SECTION_TYPE_FLAGS): Remove.
* config/rs6000/xcoff.h (TARGET_ASM_RELOC_RW_MASK): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122781 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/alpha/alpha.c | 10 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 4 | ||||
-rw-r--r-- | gcc/config/ia64/hpux.h | 11 | ||||
-rw-r--r-- | gcc/config/ia64/ia64.c | 62 | ||||
-rw-r--r-- | gcc/config/ia64/sysv4.h | 2 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 58 | ||||
-rw-r--r-- | gcc/config/rs6000/sysv4.h | 8 | ||||
-rw-r--r-- | gcc/config/rs6000/xcoff.h | 3 |
8 files changed, 62 insertions, 96 deletions
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index ae00e1c2ff4..e6ea03f1b49 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -9320,6 +9320,14 @@ alpha_file_start (void) #endif #ifdef OBJECT_FORMAT_ELF +/* Since we don't have a .dynbss section, we should not allow global + relocations in the .rodata section. */ + +static int +alpha_elf_reloc_rw_mask (void) +{ + return flag_pic ? 3 : 2; +} /* Return a section for X. The only special thing we do here is to honor small data. */ @@ -10568,6 +10576,8 @@ alpha_init_libfuncs (void) #endif #ifdef OBJECT_FORMAT_ELF +#undef TARGET_ASM_RELOC_RW_MASK +#define TARGET_ASM_RELOC_RW_MASK alpha_elf_reloc_rw_mask #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION alpha_elf_select_rtx_section #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 70fd96ce8fe..469d909b983 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2509,7 +2509,7 @@ x86_64_elf_select_section (tree decl, int reloc, { const char *sname = NULL; unsigned int flags = SECTION_WRITE; - switch (categorize_decl_for_section (decl, reloc, flag_pic)) + switch (categorize_decl_for_section (decl, reloc)) { case SECCAT_DATA: sname = ".ldata"; @@ -2576,7 +2576,7 @@ x86_64_elf_unique_section (tree decl, int reloc) /* We only need to use .gnu.linkonce if we don't have COMDAT groups. */ bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP; - switch (categorize_decl_for_section (decl, reloc, flag_pic)) + switch (categorize_decl_for_section (decl, reloc)) { case SECCAT_DATA: case SECCAT_DATA_REL: diff --git a/gcc/config/ia64/hpux.h b/gcc/config/ia64/hpux.h index 186f339147b..bdf3968e95c 100644 --- a/gcc/config/ia64/hpux.h +++ b/gcc/config/ia64/hpux.h @@ -1,5 +1,5 @@ /* Definitions of target machine GNU compiler. IA-64 version. - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. Contributed by Steve Ellcey <sje@cup.hp.com> and Reva Cuthbertson <reva@cup.hp.com> @@ -174,13 +174,8 @@ do { \ /* It is illegal to have relocations in shared segments on HPUX. Pretend flag_pic is always set. */ -#undef TARGET_ASM_SELECT_SECTION -#define TARGET_ASM_SELECT_SECTION ia64_rwreloc_select_section -#undef TARGET_ASM_UNIQUE_SECTION -#define TARGET_ASM_UNIQUE_SECTION ia64_rwreloc_unique_section -#undef TARGET_ASM_SELECT_RTX_SECTION -#define TARGET_ASM_SELECT_RTX_SECTION ia64_rwreloc_select_rtx_section -#define TARGET_RWRELOC true +#undef TARGET_ASM_RELOC_RW_MASK +#define TARGET_ASM_RELOC_RW_MASK ia64_hpux_reloc_rw_mask /* ia64 HPUX has the float and long double forms of math functions. */ #undef TARGET_C99_FUNCTIONS diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index f1dbfc35a73..dc10abb3dcd 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler. - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by James E. Wilson <wilson@cygnus.com> and David Mosberger <davidm@hpl.hp.com>. @@ -244,17 +244,12 @@ static void ia64_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, static void ia64_file_start (void); static void ia64_globalize_decl_name (FILE *, tree); +static int ia64_hpux_reloc_rw_mask (void) ATTRIBUTE_UNUSED; +static int ia64_reloc_rw_mask (void) ATTRIBUTE_UNUSED; static section *ia64_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT); static void ia64_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED; -static section *ia64_rwreloc_select_section (tree, int, unsigned HOST_WIDE_INT) - ATTRIBUTE_UNUSED; -static void ia64_rwreloc_unique_section (tree, int) - ATTRIBUTE_UNUSED; -static section *ia64_rwreloc_select_rtx_section (enum machine_mode, rtx, - unsigned HOST_WIDE_INT) - ATTRIBUTE_UNUSED; static unsigned int ia64_section_type_flags (tree, const char *, int); static void ia64_init_libfuncs (void) ATTRIBUTE_UNUSED; @@ -9374,6 +9369,24 @@ ia64_sysv4_init_libfuncs (void) glibc doesn't have them. */ } +/* For HPUX, it is illegal to have relocations in shared segments. */ + +static int +ia64_hpux_reloc_rw_mask (void) +{ + return 3; +} + +/* For others, relax this so that relocations to local data goes in + read-only segments, but we still cannot allow global relocations + in read-only segments. */ + +static int +ia64_reloc_rw_mask (void) +{ + return flag_pic ? 3 : 2; +} + /* Return the section to use for X. The only special thing we do here is to honor small data. */ @@ -9389,37 +9402,6 @@ ia64_select_rtx_section (enum machine_mode mode, rtx x, return default_elf_select_rtx_section (mode, x, align); } -/* It is illegal to have relocations in shared segments on AIX and HPUX. - Pretend flag_pic is always set. */ - -static section * -ia64_rwreloc_select_section (tree exp, int reloc, unsigned HOST_WIDE_INT align) -{ - return default_elf_select_section_1 (exp, reloc, align, true); -} - -static void -ia64_rwreloc_unique_section (tree decl, int reloc) -{ - default_unique_section_1 (decl, reloc, true); -} - -static section * -ia64_rwreloc_select_rtx_section (enum machine_mode mode, rtx x, - unsigned HOST_WIDE_INT align) -{ - section *sect; - int save_pic = flag_pic; - flag_pic = 1; - sect = ia64_select_rtx_section (mode, x, align); - flag_pic = save_pic; - return sect; -} - -#ifndef TARGET_RWRELOC -#define TARGET_RWRELOC flag_pic -#endif - static unsigned int ia64_section_type_flags (tree decl, const char *name, int reloc) { @@ -9435,7 +9417,7 @@ ia64_section_type_flags (tree decl, const char *name, int reloc) || strncmp (name, ".gnu.linkonce.sb.", 17) == 0) flags = SECTION_SMALL; - flags |= default_section_type_flags_1 (decl, name, reloc, TARGET_RWRELOC); + flags |= default_section_type_flags (decl, name, reloc); return flags; } diff --git a/gcc/config/ia64/sysv4.h b/gcc/config/ia64/sysv4.h index 5e93d4cd2d9..0e03e7d6107 100644 --- a/gcc/config/ia64/sysv4.h +++ b/gcc/config/ia64/sysv4.h @@ -121,6 +121,8 @@ do { \ } while (0) /* Override default elf definition. */ +#undef TARGET_ASM_RELOC_RW_MASK +#define TARGET_ASM_RELOC_RW_MASK ia64_reloc_rw_mask #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION ia64_select_rtx_section diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index fd1b8358a9b..d80d061c857 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -656,13 +656,11 @@ static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT); static bool rs6000_return_in_memory (tree, tree); static void rs6000_file_start (void); #if TARGET_ELF -static unsigned int rs6000_elf_section_type_flags (tree, const char *, int); +static int rs6000_elf_reloc_rw_mask (void); static void rs6000_elf_asm_out_constructor (rtx, int); static void rs6000_elf_asm_out_destructor (rtx, int); static void rs6000_elf_end_indicate_exec_stack (void) ATTRIBUTE_UNUSED; static void rs6000_elf_asm_init_sections (void); -static section *rs6000_elf_select_section (tree, int, unsigned HOST_WIDE_INT); -static void rs6000_elf_unique_section (tree, int); static section *rs6000_elf_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT); static void rs6000_elf_encode_section_info (tree, rtx, int) @@ -673,6 +671,7 @@ static bool rs6000_use_blocks_for_constant_p (enum machine_mode, rtx); static void rs6000_xcoff_asm_output_anchor (rtx); static void rs6000_xcoff_asm_globalize_label (FILE *, const char *); static void rs6000_xcoff_asm_init_sections (void); +static int rs6000_xcoff_reloc_rw_mask (void); static void rs6000_xcoff_asm_named_section (const char *, unsigned int, tree); static section *rs6000_xcoff_select_section (tree, int, unsigned HOST_WIDE_INT); @@ -18928,37 +18927,6 @@ rs6000_elf_select_rtx_section (enum machine_mode mode, rtx x, else return default_elf_select_rtx_section (mode, x, align); } - -/* Implement TARGET_ASM_SELECT_SECTION for ELF targets. */ - -static section * -rs6000_elf_select_section (tree decl, int reloc, - unsigned HOST_WIDE_INT align) -{ - /* Pretend that we're always building for a shared library when - ABI_AIX, because otherwise we end up with dynamic relocations - in read-only sections. This happens for function pointers, - references to vtables in typeinfo, and probably other cases. */ - return default_elf_select_section_1 (decl, reloc, align, - flag_pic || DEFAULT_ABI == ABI_AIX); -} - -/* A C statement to build up a unique section name, expressed as a - 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, GCC will use - the symbol name prefixed by `.' as the section name. Note - this - macro can now be called for uninitialized data items as well as - initialized data and functions. */ - -static void -rs6000_elf_unique_section (tree decl, int reloc) -{ - /* As above, pretend that we're always building for a shared library - when ABI_AIX, to avoid dynamic relocations in read-only sections. */ - default_unique_section_1 (decl, reloc, - flag_pic || DEFAULT_ABI == ABI_AIX); -} /* For a SYMBOL_REF, set generic flags and then perform some target-specific processing. @@ -19437,11 +19405,15 @@ rs6000_darwin_file_start (void) #endif /* TARGET_MACHO */ #if TARGET_ELF -static unsigned int -rs6000_elf_section_type_flags (tree decl, const char *name, int reloc) +static int +rs6000_elf_reloc_rw_mask (void) { - return default_section_type_flags_1 (decl, name, reloc, - flag_pic || DEFAULT_ABI == ABI_AIX); + if (flag_pic) + return 3; + else if (DEFAULT_ABI == ABI_AIX) + return 2; + else + return 0; } /* Record an element in the table of global constructors. SYMBOL is @@ -19679,6 +19651,12 @@ rs6000_xcoff_asm_init_sections (void) exception_section = data_section; } +static int +rs6000_xcoff_reloc_rw_mask (void) +{ + return 3; +} + static void rs6000_xcoff_asm_named_section (const char *name, unsigned int flags, tree decl ATTRIBUTE_UNUSED) @@ -19702,7 +19680,7 @@ static section * rs6000_xcoff_select_section (tree decl, int reloc, unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) { - if (decl_readonly_section_1 (decl, reloc, 1)) + if (decl_readonly_section (decl, reloc)) { if (TREE_PUBLIC (decl)) return read_only_data_section; @@ -19774,7 +19752,7 @@ static unsigned int rs6000_xcoff_section_type_flags (tree decl, const char *name, int reloc) { unsigned int align; - unsigned int flags = default_section_type_flags_1 (decl, name, reloc, 1); + unsigned int flags = default_section_type_flags (decl, name, reloc); /* Align to at least UNIT size. */ if (flags & SECTION_CODE) diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index d7c10028a79..0b1eb1ebb4d 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -1,6 +1,6 @@ /* Target definitions for GNU compiler for PowerPC running System V.4 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005, 2006 Free Software Foundation, Inc. + 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by Cygnus Support. This file is part of GCC. @@ -364,11 +364,10 @@ do { \ /* Override default elf definitions. */ #define TARGET_ASM_INIT_SECTIONS rs6000_elf_asm_init_sections +#undef TARGET_ASM_RELOC_RW_MASK +#define TARGET_ASM_RELOC_RW_MASK rs6000_elf_reloc_rw_mask #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION rs6000_elf_select_rtx_section -#undef TARGET_ASM_SELECT_SECTION -#define TARGET_ASM_SELECT_SECTION rs6000_elf_select_section -#define TARGET_ASM_UNIQUE_SECTION rs6000_elf_unique_section /* Return nonzero if this entry is to be written into the constant pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF or a CONST @@ -533,7 +532,6 @@ extern int fixuplabelno; #define TARGET_ENCODE_SECTION_INFO rs6000_elf_encode_section_info #define TARGET_IN_SMALL_DATA_P rs6000_elf_in_small_data_p -#define TARGET_SECTION_TYPE_FLAGS rs6000_elf_section_type_flags /* The ELF version doesn't encode [DS] or whatever at the end of symbols. */ diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 6a954655b04..ebf79b51e9d 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -1,6 +1,6 @@ /* Definitions of target machine for GNU compiler, for some generic XCOFF file format - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2007 Free Software Foundation, Inc. This file is part of GCC. @@ -88,6 +88,7 @@ #define TARGET_ASM_OUTPUT_ANCHOR rs6000_xcoff_asm_output_anchor #define TARGET_ASM_GLOBALIZE_LABEL rs6000_xcoff_asm_globalize_label #define TARGET_ASM_INIT_SECTIONS rs6000_xcoff_asm_init_sections +#define TARGET_ASM_RELOC_RW_MASK rs6000_xcoff_reloc_rw_mask #define TARGET_ASM_NAMED_SECTION rs6000_xcoff_asm_named_section #define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section |