From patchwork Mon Aug 6 03:40:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 175255 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 AF9C22C0084 for ; Mon, 6 Aug 2012 13:40:34 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344829236; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=kXM1vOb cPp2A68YHWZdcgtSPqyo=; b=Zu/JAYDc98P7FJ0iAt410I3H9N/V6Bksi+sPoE2 wruSK27SEcKmnik/6grnfT65InjsQbvfycqHpKmCHNihCMHnBTGVD8T5tD1CuB5T hf+csapISwNYxGFfwyu94apy/158QEV1xdh2sukpfXHL0WLmU9Kdn4vQrWH+bf99 A6+w= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=oWBAdu2FZ1s8Mh+NGDqHJizm9vlFVUBfrvYmhGDwZGU4lPyoz/qENvk+Es2h2x hUUPwTZDif46sKGa5pilgBR+npFsYp/pdWEHWN1KTukCkpGmN6+/pW1cwaSgC/Pd IxrqEbu4bQvyr1lRz6borPbo5bi1wU2PD+foKsjYoN4eI=; Received: (qmail 25344 invoked by alias); 6 Aug 2012 03:40:31 -0000 Received: (qmail 25334 invoked by uid 22791); 6 Aug 2012 03:40:30 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Aug 2012 03:40:15 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SyEAw-0004xQ-21 from Sandra_Loosemore@mentor.com for gcc-patches@gcc.gnu.org; Sun, 05 Aug 2012 20:40:14 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 5 Aug 2012 20:40:13 -0700 Received: from [IPv6:::1] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Sun, 5 Aug 2012 20:40:13 -0700 Message-ID: <501F3CA0.3040106@codesourcery.com> Date: Sun, 5 Aug 2012 21:40:16 -0600 From: Sandra Loosemore User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Subject: [PATCH] put exception tables for comdat functions in comdat, too 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 For C++ functions that are emitted to a comdat section (template instantiations and the like), the corresponding exception handling information is presently being emitted to the non-comdat .gcc_except_table section. This means that you can end up with multiple copies of the exception tables in the executable from different objects, even though the linker can remove all but one copy of the function it goes with. We do have a test case for this, but I don't know how to mash it into the Dejagnu framework. My hand-testing involved comparing the before/after output of readelf to see the new exception table sections in the group, and verifying that the size of the executable is smaller with the patch than without it. Otherwise, I bootstrapped and regression tested on x86_64, and also tested on mipsisa32r2-sde-elf since I had an existing build tree for that set up. This patch has also been present in our local source base for a while so it's been well-tested in that context. OK for mainline? -Sandra 2012-08-04 Paul Brook Sandra Loosemore gcc/ * except.c (switch_to_exception_section): Place tables for DECL_ONE_ONLY functions in comdat groups. Index: gcc/except.c =================================================================== --- gcc/except.c (revision 190149) +++ gcc/except.c (working copy) @@ -2777,11 +2777,16 @@ switch_to_exception_section (const char flags = SECTION_WRITE; #ifdef HAVE_LD_EH_GC_SECTIONS - if (flag_function_sections) + if (flag_function_sections + || (DECL_ONE_ONLY (current_function_decl) && HAVE_COMDAT_GROUP)) { char *section_name = XNEWVEC (char, strlen (fnname) + 32); + /* The EH table must match the code section, so only mark + it linkonce if we have COMDAT groups to tie them together. */ + if (DECL_ONE_ONLY (current_function_decl) && HAVE_COMDAT_GROUP) + flags |= SECTION_LINKONCE; sprintf (section_name, ".gcc_except_table.%s", fnname); - s = get_section (section_name, flags, NULL); + s = get_section (section_name, flags, current_function_decl); free (section_name); } else