From patchwork Tue May 10 15:42:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 95011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1F7A3B6EE6 for ; Wed, 11 May 2011 03:29:50 +1000 (EST) Received: (qmail 4891 invoked by alias); 10 May 2011 15:43:08 -0000 Received: (qmail 4880 invoked by uid 22791); 10 May 2011 15:43:07 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 15:42:53 +0000 Received: (qmail 2588 invoked from network); 10 May 2011 15:42:52 -0000 Received: from unknown (HELO ?84.152.158.68?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2011 15:42:52 -0000 Message-ID: <4DC95CDA.3000909@codesourcery.com> Date: Tue, 10 May 2011 17:42:18 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: GCC Patches Subject: C6X port 7/11: Cope with odd section names Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The C6X ELF ABI chooses to use ".const" rather than ".rodata" for far-readonly data. This patch adds a target hook to deal with the problem. Bernd * doc/tm.texi.in (TARGET_ASM_MERGEABLE_RODATA_PREFIX): Document. * doc/tm.texi: Regenerate. * target.def (mergeable_rodata_prefix: New defhookpod. * varasm.c (mergeable_string_section, mergeable_constant_section): Use it. Index: doc/tm.texi =================================================================== --- doc/tm.texi.orig +++ doc/tm.texi @@ -7024,6 +7024,12 @@ if function is in @code{.text.name}, and otherwise. @end deftypefn +@deftypevr {Target Hook} {const char *} TARGET_ASM_MERGEABLE_RODATA_PREFIX +Usually, the compiler uses the prefix @code{".rodata"} to construct section +names for mergeable constant data. Define this macro to override the string +if a different section name should be used. +@end deftypevr + @deftypefn {Target Hook} {section *} TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode @var{mode}, rtx @var{x}, unsigned HOST_WIDE_INT @var{align}) Return the section into which a constant @var{x}, of mode @var{mode}, should be placed. You can assume that @var{x} is some kind of Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in.orig +++ doc/tm.texi.in @@ -6976,6 +6976,12 @@ if function is in @code{.text.name}, and otherwise. @end deftypefn +@hook TARGET_ASM_MERGEABLE_RODATA_PREFIX +Usually, the compiler uses the prefix @code{".rodata"} to construct section +names for mergeable constant data. Define this macro to override the string +if a different section name should be used. +@end deftypevr + @hook TARGET_ASM_SELECT_RTX_SECTION Return the section into which a constant @var{x}, of mode @var{mode}, should be placed. You can assume that @var{x} is some kind of Index: target.def =================================================================== --- target.def.orig +++ target.def @@ -296,6 +296,13 @@ DEFHOOK section *, (tree decl), default_function_rodata_section) +/* Nonnull if the target wants to override the default ".rodata" prefix + for mergeable data sections. */ +DEFHOOKPOD +(mergeable_rodata_prefix, + "", + const char *, NULL) + /* Output a constructor for a symbol with a given priority. */ DEFHOOK (constructor, Index: varasm.c =================================================================== --- varasm.c.orig +++ varasm.c @@ -737,7 +737,7 @@ mergeable_string_section (tree decl ATTR const char *str; HOST_WIDE_INT i; int j, unit; - char name[30]; + char name[80]; mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl))); modesize = GET_MODE_BITSIZE (mode); @@ -761,8 +761,10 @@ mergeable_string_section (tree decl ATTR } if (i == len - unit) { - sprintf (name, ".rodata.str%d.%d", modesize / 8, - (int) (align / 8)); + sprintf (name, "%s.str%d.%d", + targetm.asm_out.mergeable_rodata_prefix + ? targetm.asm_out.mergeable_rodata_prefix : ".rodata", + modesize / 8, (int) (align / 8)); flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS; return get_section (name, flags, NULL); } @@ -789,9 +791,12 @@ mergeable_constant_section (enum machine && align <= 256 && (align & (align - 1)) == 0) { - char name[24]; + char name[80]; - sprintf (name, ".rodata.cst%d", (int) (align / 8)); + sprintf (name, "%s.cst%d", + targetm.asm_out.mergeable_rodata_prefix + ? targetm.asm_out.mergeable_rodata_prefix : ".rodata", + (int) (align / 8)); flags |= (align / 8) | SECTION_MERGE; return get_section (name, flags, NULL); }