diff options
author | Julian Brown <julian@codesourcery.com> | 2005-05-08 16:58:03 +0000 |
---|---|---|
committer | Julian Brown <julian@codesourcery.com> | 2005-05-08 16:58:03 +0000 |
commit | 8c9d4eb8eae6e4b7cf6ab0aafc052173b54c0ff0 (patch) | |
tree | fd14cfe6d9d55ff5167a2cd3d7ecf8cf70ea5b5b /gcc/varasm.c | |
parent | d7b669e3f39272b48e10ee57c0630e67c69df2d4 (diff) |
* configure.ac: Set ld_vers_major, ld_vers_minor and ld_vers_patch for
GNU linker. Support linker version x.x.x.x.x. Require GNU linker
20050308/2.16.0 or newer for comdat group.
* configure: Regenerated.
* config.in: Regenerated.
* varasm.c (default_function_rodata_section): Put .rodata section in
COMDAT group when necessary.
(default_elf_asm_named_section): Rename HAVE_GAS_COMDAT_GROUP to
HAVE_COMDAT_GROUP.
(default_unique_section_1): Don't use .gnu.linkonce when COMDAT is
available.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@99395 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 6f6a817275d..bc0597efab5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -618,8 +618,19 @@ default_function_rodata_section (tree decl) { const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); + if (DECL_ONE_ONLY (decl) && HAVE_COMDAT_GROUP) + { + size_t len = strlen (name) + 3; + char* rname = alloca (len); + + strcpy (rname, ".rodata"); + strcat (rname, name + 5); + named_section_real (rname, SECTION_LINKONCE, decl); + return; + } /* 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) + else if (DECL_ONE_ONLY (decl) + && strncmp (name, ".gnu.linkonce.t.", 16) == 0) { size_t len = strlen (name) + 1; char *rname = alloca (len); @@ -4880,7 +4891,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags, abbreviated form to switch back to it -- unless this section is part of a COMDAT groups, in which case GAS requires the full declaration every time. */ - if (!(HAVE_GAS_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) && ! named_section_first_declaration (name)) { fprintf (asm_out_file, "\t.section\t%s\n", name); @@ -4901,7 +4912,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags, *f++ = 'S'; if (flags & SECTION_TLS) *f++ = 'T'; - if (HAVE_GAS_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) *f++ = 'G'; *f = '\0'; @@ -4928,7 +4939,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags, if (flags & SECTION_ENTSIZE) fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE); - if (HAVE_GAS_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) fprintf (asm_out_file, ",%s,comdat", lang_hooks.decls.comdat_group (decl)); } @@ -5240,7 +5251,8 @@ default_unique_section (tree decl, int reloc) void default_unique_section_1 (tree decl, int reloc, int shlib) { - bool one_only = DECL_ONE_ONLY (decl); + /* We only need to use .gnu.linkonce if we don't have COMDAT groups. */ + bool one_only = DECL_ONE_ONLY (decl) && !HAVE_COMDAT_GROUP; const char *prefix, *name; size_t nlen, plen; char *string; |