forked from ports/contrib
353 lines
12 KiB
Diff
353 lines
12 KiB
Diff
Description: Fixes linkone/comdat issue
|
|
Origin: Original patch from LFS against 3.4.3.
|
|
This patch is re-diffed against gcc 3.4.4.
|
|
Upstream status: Unknown
|
|
|
|
diff -Nru gcc-3.4.4/gcc/config/alpha/alpha.c gcc-3.4.4-new/gcc/config/alpha/alpha.c
|
|
--- gcc-3.4.4/gcc/config/alpha/alpha.c 2004-11-12 10:11:33.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/alpha/alpha.c 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -10175,6 +10175,8 @@
|
|
# define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags
|
|
# undef TARGET_ASM_UNIQUE_SECTION
|
|
# define TARGET_ASM_UNIQUE_SECTION unicosmk_unique_section
|
|
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
# undef TARGET_ASM_GLOBALIZE_LABEL
|
|
# define TARGET_ASM_GLOBALIZE_LABEL hook_void_FILEptr_constcharptr
|
|
#endif
|
|
diff -Nru gcc-3.4.4/gcc/config/arm/pe.h gcc-3.4.4-new/gcc/config/arm/pe.h
|
|
--- gcc-3.4.4/gcc/config/arm/pe.h 2004-02-24 15:25:22.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/arm/pe.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -97,6 +97,7 @@
|
|
#define MULTIPLE_SYMBOL_SPACES
|
|
|
|
#define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
|
|
#define SUPPORTS_ONE_ONLY 1
|
|
|
|
diff -Nru gcc-3.4.4/gcc/config/avr/avr.c gcc-3.4.4-new/gcc/config/avr/avr.c
|
|
--- gcc-3.4.4/gcc/config/avr/avr.c 2005-03-20 22:14:28.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/avr/avr.c 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -229,6 +229,8 @@
|
|
#define TARGET_ASM_FUNCTION_EPILOGUE avr_output_function_epilogue
|
|
#undef TARGET_ATTRIBUTE_TABLE
|
|
#define TARGET_ATTRIBUTE_TABLE avr_attribute_table
|
|
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
#undef TARGET_INSERT_ATTRIBUTES
|
|
#define TARGET_INSERT_ATTRIBUTES avr_insert_attributes
|
|
#undef TARGET_SECTION_TYPE_FLAGS
|
|
diff -Nru gcc-3.4.4/gcc/config/darwin.h gcc-3.4.4-new/gcc/config/darwin.h
|
|
--- gcc-3.4.4/gcc/config/darwin.h 2004-09-11 22:32:17.000000000 +0200
|
|
+++ gcc-3.4.4-new/gcc/config/darwin.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -686,6 +686,9 @@
|
|
#undef TARGET_ASM_SELECT_RTX_SECTION
|
|
#define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
|
|
|
|
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
+
|
|
#define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME) \
|
|
do { \
|
|
if (FILE) { \
|
|
diff -Nru gcc-3.4.4/gcc/config/i386/cygming.h gcc-3.4.4-new/gcc/config/i386/cygming.h
|
|
--- gcc-3.4.4/gcc/config/i386/cygming.h 2004-06-08 08:30:13.000000000 +0200
|
|
+++ gcc-3.4.4-new/gcc/config/i386/cygming.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -255,6 +255,7 @@
|
|
|
|
extern void i386_pe_unique_section (TREE, int);
|
|
#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
|
|
#define SUPPORTS_ONE_ONLY 1
|
|
|
|
diff -Nru gcc-3.4.4/gcc/config/i386/i386-interix.h gcc-3.4.4-new/gcc/config/i386/i386-interix.h
|
|
--- gcc-3.4.4/gcc/config/i386/i386-interix.h 2004-01-31 07:18:20.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/i386/i386-interix.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -344,6 +344,7 @@
|
|
|
|
extern void i386_pe_unique_section (tree, int);
|
|
#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
|
|
#define SUPPORTS_ONE_ONLY 1
|
|
#endif /* 0 */
|
|
diff -Nru gcc-3.4.4/gcc/config/ip2k/ip2k.c gcc-3.4.4-new/gcc/config/ip2k/ip2k.c
|
|
--- gcc-3.4.4/gcc/config/ip2k/ip2k.c 2004-01-31 07:18:25.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/ip2k/ip2k.c 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -98,6 +98,9 @@
|
|
#undef TARGET_ASM_UNIQUE_SECTION
|
|
#define TARGET_ASM_UNIQUE_SECTION unique_section
|
|
|
|
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
+
|
|
#undef TARGET_ATTRIBUTE_TABLE
|
|
#define TARGET_ATTRIBUTE_TABLE ip2k_attribute_table
|
|
|
|
diff -Nru gcc-3.4.4/gcc/config/mcore/mcore.c gcc-3.4.4-new/gcc/config/mcore/mcore.c
|
|
--- gcc-3.4.4/gcc/config/mcore/mcore.c 2004-01-31 07:18:29.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/mcore/mcore.c 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -165,6 +165,8 @@
|
|
#define TARGET_ATTRIBUTE_TABLE mcore_attribute_table
|
|
#undef TARGET_ASM_UNIQUE_SECTION
|
|
#define TARGET_ASM_UNIQUE_SECTION mcore_unique_section
|
|
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
#undef TARGET_ENCODE_SECTION_INFO
|
|
#define TARGET_ENCODE_SECTION_INFO mcore_encode_section_info
|
|
#undef TARGET_STRIP_NAME_ENCODING
|
|
diff -Nru gcc-3.4.4/gcc/config/rs6000/xcoff.h gcc-3.4.4-new/gcc/config/rs6000/xcoff.h
|
|
--- gcc-3.4.4/gcc/config/rs6000/xcoff.h 2004-01-31 07:18:34.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/config/rs6000/xcoff.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -172,6 +172,7 @@
|
|
#define TARGET_ASM_SELECT_SECTION rs6000_xcoff_select_section
|
|
#define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section
|
|
#define TARGET_ASM_UNIQUE_SECTION rs6000_xcoff_unique_section
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
|
|
#define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding
|
|
#define TARGET_SECTION_TYPE_FLAGS rs6000_xcoff_section_type_flags
|
|
|
|
diff -Nru gcc-3.4.4/gcc/doc/tm.texi gcc-3.4.4-new/gcc/doc/tm.texi
|
|
--- gcc-3.4.4/gcc/doc/tm.texi 2005-01-16 17:01:28.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/doc/tm.texi 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -6003,6 +6003,15 @@
|
|
Whatever the actual target object format, this is often good enough.
|
|
@end deftypefn
|
|
|
|
+@deftypefn {Target Hook} void TARGET_ASM_FUNCTION_RODATA_SECTION (tree @var{decl})
|
|
+Switches to a readonly data section associated with
|
|
+@samp{DECL_SECTION_NAME (@var{decl})}.
|
|
+The default version of this function switches to @code{.gnu.linkonce.r.name}
|
|
+section if function's section is @code{.gnu.linkonce.t.name}, to
|
|
+@code{.rodata.name} if function is in @code{.text.name} section
|
|
+and otherwise switches to the normal readonly data section.
|
|
+@end deftypefn
|
|
+
|
|
@deftypefn {Target Hook} void TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode @var{mode}, rtx @var{x}, unsigned HOST_WIDE_INT @var{align})
|
|
Switches to the appropriate section for output of constant pool entry
|
|
@var{x} in @var{mode}. You can assume that @var{x} is some kind of
|
|
diff -Nru gcc-3.4.4/gcc/final.c gcc-3.4.4-new/gcc/final.c
|
|
--- gcc-3.4.4/gcc/final.c 2004-01-18 23:39:57.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/final.c 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -1881,7 +1881,7 @@
|
|
{
|
|
int log_align;
|
|
|
|
- readonly_data_section ();
|
|
+ targetm.asm_out.function_rodata_section (current_function_decl);
|
|
|
|
#ifdef ADDR_VEC_ALIGN
|
|
log_align = ADDR_VEC_ALIGN (NEXT_INSN (insn));
|
|
diff -Nru gcc-3.4.4/gcc/output.h gcc-3.4.4-new/gcc/output.h
|
|
--- gcc-3.4.4/gcc/output.h 2004-01-18 23:39:57.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/output.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -500,6 +500,8 @@
|
|
unsigned HOST_WIDE_INT, int);
|
|
extern void default_unique_section (tree, int);
|
|
extern void default_unique_section_1 (tree, int, int);
|
|
+extern void default_function_rodata_section (tree);
|
|
+extern void default_no_function_rodata_section (tree);
|
|
extern void default_select_rtx_section (enum machine_mode, rtx,
|
|
unsigned HOST_WIDE_INT);
|
|
extern void default_elf_select_rtx_section (enum machine_mode, rtx,
|
|
diff -Nru gcc-3.4.4/gcc/target-def.h gcc-3.4.4-new/gcc/target-def.h
|
|
--- gcc-3.4.4/gcc/target-def.h 2004-08-23 20:02:40.000000000 +0200
|
|
+++ gcc-3.4.4-new/gcc/target-def.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -78,6 +78,10 @@
|
|
#define TARGET_ASM_UNIQUE_SECTION default_unique_section
|
|
#endif
|
|
|
|
+#ifndef TARGET_ASM_FUNCTION_RODATA_SECTION
|
|
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_function_rodata_section
|
|
+#endif
|
|
+
|
|
#ifndef TARGET_ASM_SELECT_RTX_SECTION
|
|
#define TARGET_ASM_SELECT_RTX_SECTION default_select_rtx_section
|
|
#endif
|
|
@@ -201,6 +205,7 @@
|
|
TARGET_ASM_SELECT_SECTION, \
|
|
TARGET_ASM_SELECT_RTX_SECTION, \
|
|
TARGET_ASM_UNIQUE_SECTION, \
|
|
+ TARGET_ASM_FUNCTION_RODATA_SECTION, \
|
|
TARGET_ASM_CONSTRUCTOR, \
|
|
TARGET_ASM_DESTRUCTOR, \
|
|
TARGET_ASM_OUTPUT_MI_THUNK, \
|
|
diff -Nru gcc-3.4.4/gcc/target.h gcc-3.4.4-new/gcc/target.h
|
|
--- gcc-3.4.4/gcc/target.h 2004-08-23 20:02:41.000000000 +0200
|
|
+++ gcc-3.4.4-new/gcc/target.h 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -118,6 +118,10 @@
|
|
for SELECT_SECTION. */
|
|
void (* unique_section) (tree, int);
|
|
|
|
+ /* Tell assembler to switch to the readonly data section associated
|
|
+ with function DECL. */
|
|
+ void (* function_rodata_section) (tree);
|
|
+
|
|
/* Output a constructor for a symbol with a given priority. */
|
|
void (* constructor) (rtx, int);
|
|
|
|
diff -Nru gcc-3.4.4/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc gcc-3.4.4-new/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc
|
|
--- gcc-3.4.4/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc 1970-01-01 01:00:00.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -0,0 +1,40 @@
|
|
+extern void
|
|
+bar (int x);
|
|
+
|
|
+inline void
|
|
+foo (int i)
|
|
+{
|
|
+ switch (i)
|
|
+ {
|
|
+ case 3:
|
|
+ case 5:
|
|
+ case 6:
|
|
+ case 9:
|
|
+ case 15:
|
|
+ bar (1);
|
|
+ break;
|
|
+ case 2:
|
|
+ case 4:
|
|
+ case 7:
|
|
+ case 10:
|
|
+ case 11:
|
|
+ case 12:
|
|
+ bar (2);
|
|
+ break;
|
|
+ case 0:
|
|
+ case 1:
|
|
+ case 8:
|
|
+ case 13:
|
|
+ case 16:
|
|
+ bar (3);
|
|
+ break;
|
|
+ case 14:
|
|
+ bar (4);
|
|
+ break;
|
|
+ default:
|
|
+ bar (5);
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
+void *fooaddr2 = (void *) foo;
|
|
diff -Nru gcc-3.4.4/gcc/testsuite/g++.old-deja/g++.other/comdat4.C gcc-3.4.4-new/gcc/testsuite/g++.old-deja/g++.other/comdat4.C
|
|
--- gcc-3.4.4/gcc/testsuite/g++.old-deja/g++.other/comdat4.C 1970-01-01 01:00:00.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/testsuite/g++.old-deja/g++.other/comdat4.C 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -0,0 +1,57 @@
|
|
+// PR c++/16276
|
|
+// { dg-do link }
|
|
+// { dg-additional-sources " comdat4-aux.cc" }
|
|
+// { dg-options "-O2" }
|
|
+
|
|
+extern void
|
|
+bar (int x);
|
|
+
|
|
+inline void
|
|
+foo (int i)
|
|
+{
|
|
+ switch (i)
|
|
+ {
|
|
+ case 3:
|
|
+ case 5:
|
|
+ case 6:
|
|
+ case 9:
|
|
+ case 15:
|
|
+ bar (1);
|
|
+ break;
|
|
+ case 2:
|
|
+ case 4:
|
|
+ case 7:
|
|
+ case 10:
|
|
+ case 11:
|
|
+ case 12:
|
|
+ bar (2);
|
|
+ break;
|
|
+ case 0:
|
|
+ case 1:
|
|
+ case 8:
|
|
+ case 13:
|
|
+ case 16:
|
|
+ bar (3);
|
|
+ break;
|
|
+ case 14:
|
|
+ bar (4);
|
|
+ break;
|
|
+ default:
|
|
+ bar (5);
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
+void *fooaddr = (void *) foo;
|
|
+
|
|
+void
|
|
+bar (int x)
|
|
+{
|
|
+ __asm __volatile ("" : : "r" (x));
|
|
+}
|
|
+
|
|
+int
|
|
+main (void)
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
diff -Nru gcc-3.4.4/gcc/varasm.c gcc-3.4.4-new/gcc/varasm.c
|
|
--- gcc-3.4.4/gcc/varasm.c 2005-03-02 21:57:48.000000000 +0100
|
|
+++ gcc-3.4.4-new/gcc/varasm.c 2005-07-21 21:22:56.000000000 +0200
|
|
@@ -535,6 +535,53 @@
|
|
text_section ();
|
|
}
|
|
|
|
+/* Switch to read-only data section associated with function DECL. */
|
|
+
|
|
+void
|
|
+default_function_rodata_section (tree decl)
|
|
+{
|
|
+ if (decl != NULL_TREE && DECL_SECTION_NAME (decl))
|
|
+ {
|
|
+ const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
|
|
+
|
|
+ /* For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo. */
|
|
+ if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0)
|
|
+ {
|
|
+ size_t len = strlen (name) + 1;
|
|
+ char *rname = alloca (len);
|
|
+
|
|
+ memcpy (rname, name, len);
|
|
+ rname[14] = 'r';
|
|
+ named_section_flags (rname, SECTION_LINKONCE);
|
|
+ return;
|
|
+ }
|
|
+ /* For .text.foo we want to use .rodata.foo. */
|
|
+ else if (flag_function_sections && flag_data_sections
|
|
+ && strncmp (name, ".text.", 6) == 0)
|
|
+ {
|
|
+ size_t len = strlen (name) + 1;
|
|
+ char *rname = alloca (len + 2);
|
|
+
|
|
+ memcpy (rname, ".rodata", 7);
|
|
+ memcpy (rname + 7, name + 5, len - 5);
|
|
+ named_section_flags (rname, 0);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ readonly_data_section ();
|
|
+}
|
|
+
|
|
+/* Switch to read-only data section associated with function DECL
|
|
+ for targets where that section should be always the single
|
|
+ readonly data section. */
|
|
+
|
|
+void
|
|
+default_no_function_rodata_section (tree decl ATTRIBUTE_UNUSED)
|
|
+{
|
|
+ readonly_data_section ();
|
|
+}
|
|
+
|
|
/* Switch to section for variable DECL. RELOC is the same as the
|
|
argument to SELECT_SECTION. */
|
|
|