From 76aec42feedd95a299537c9678ea28a986c51a4f Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 12 Aug 2004 13:57:04 +0000 Subject: PR c++/16276 * output.h (default_function_rodata_section, default_no_function_rodata_section): New prototypes. * target.h (struct gcc_target): Add asm_out.function_rodata_section. * target-def.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define. (TARGET_ASM_OUT): Add it. * varasm.c (default_function_rodata_section, default_no_function_rodata_section): New functions. * final.c (final_scan_insn): Call targetm.asm_out.function_rodata_section instead of readonly_data_section. * config/darwin.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define. * config/mcore/mcore.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/ip2k/ip2k.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/rs6000/xcoff.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/alpha/alpha.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/i386/cygming.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/i386/i386-interix.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/arm/pe.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * config/avr/avr.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise. * doc/tm.texi (TARGET_ASM_FUNCTION_RODATA_SECTION): Document. * g++.old-deja/g++.other/comdat4.C: New test. * g++.old-deja/g++.other/comdat4-aux.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85873 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/varasm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'gcc/varasm.c') diff --git a/gcc/varasm.c b/gcc/varasm.c index 908ced5fd0a..afbde92f11e 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -547,6 +547,53 @@ function_section (tree decl) } } +/* 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. */ -- cgit v1.2.1