From patchwork Thu Dec 2 09:05:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Lin Tang X-Patchwork-Id: 73947 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 90A47B70A7 for ; Thu, 2 Dec 2010 20:06:06 +1100 (EST) Received: (qmail 15300 invoked by alias); 2 Dec 2010 09:06:04 -0000 Received: (qmail 15290 invoked by uid 22791); 2 Dec 2010 09:06:03 -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; Thu, 02 Dec 2010 09:05:59 +0000 Received: (qmail 2023 invoked from network); 2 Dec 2010 09:05:56 -0000 Received: from unknown (HELO ?110.26.202.170?) (cltang@127.0.0.2) by mail.codesourcery.com with ESMTPA; 2 Dec 2010 09:05:56 -0000 Message-ID: <4CF76168.6060806@codesourcery.com> Date: Thu, 02 Dec 2010 17:05:44 +0800 From: Chung-Lin Tang User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH] PR46667, fix section type conflicts X-IsSubscribed: yes 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 Hi, this patch tries to fix the section type conflicts seen on ARM-Linux (which currently prevents libstdc++ from building on trunk) and the reported x86-64 fails when -freorder-blocks-and-partition is involved. The ARM fails seem to be due to DECL_ONE_ONLY symbols being treated as added to the .text.unlikely section; I've added a call to resolve_unique_section() to fill in the DECL_SECTION_NAME and DECL_HAS_IMPLICIT_SECTION_NAME_P values as I see are needed. The x86-64 failure seems to be calling get_named_section() during dwarf2out_init(), when current_function_decl is still NULL, with the resulting section flags containing SECTION_WRITE. I've added an additional condition testing the ".text." section name prefix when decl is NULL. This patch has been tested on the respective platforms with no regressions, and does now revive the ARM-Linux C++ build; however, I'm not sure whether this is a robust enough fix; it may just well be band-aid :P Thanks, Chung-Lin 2010-12-02 Chung-Lin Tang PR middle-end/46667 * varasm.c (get_named_section): Add call to resolve_unique_section(). (default_function_section): Call get_named_section() for DECL_ONE_ONLY decls. (default_section_type_flags): Start off with SECTION_CODE as flags value when decl is NULL and section name starts with ".text.". Index: varasm.c =================================================================== --- varasm.c (revision 167365) +++ varasm.c (working copy) @@ -380,6 +380,10 @@ unsigned int flags; gcc_assert (!decl || DECL_P (decl)); + + if (decl) + resolve_unique_section (decl, reloc, 0); + if (name == NULL) name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); @@ -533,6 +537,9 @@ default_function_section (tree decl, enum node_frequency freq, bool startup, bool exit) { + if (decl && DECL_ONE_ONLY (decl)) + return get_named_section (decl, NULL, 0); + /* Startup code should go to startup subsection unless it is unlikely executed (this happens especially with function splitting where we can split away unnecesary parts of static constructors. */ @@ -5934,7 +5941,8 @@ { unsigned int flags; - if (decl && TREE_CODE (decl) == FUNCTION_DECL) + if ((decl && TREE_CODE (decl) == FUNCTION_DECL) + || (!decl && strncmp (name, ".text.", 6) == 0)) flags = SECTION_CODE; else if (decl && decl_readonly_section (decl, reloc)) flags = 0;