From patchwork Tue Apr 30 20:34:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshit Chopra X-Patchwork-Id: 240690 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4711D2C00C1 for ; Wed, 1 May 2013 07:00:01 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :to:subject:mime-version:content-type:content-transfer-encoding :message-id:from; q=dns; s=default; b=ranW2bMKBDxJR4DS9l2Ch9E09F k5lcakIgdvdG+FsrKCfE1USA+OrO85H06f4MmHaT5ugMMwhxzpv6iuEKMrpFwuoi hNKC5g04pUfGGvwcbKUDBpDeU1061L6NbZq3UmaUH+KkRtD5uPahT/mT/JyeKoBh vAVLDYg/lTlVD6R9Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :to:subject:mime-version:content-type:content-transfer-encoding :message-id:from; s=default; bh=X5XJNkD9p9rkmqWCjEE/VoC8+UI=; b= XCdeNu0ymLZuK6t09C9yCY2p/OsDSLSrKa2m8zJkd0W27IVW3o7eLxCqKKohFam/ r/G/I8S8TTwKGL/oyQkONRE5uvvVShJmFjRRxwUpMWP3fPX5GaGEHBAKzDgp4myg HgcJHJpO/aw4AIp0S8T0eBBQmm0GJLPLNa6ZUXCcsss= Received: (qmail 22185 invoked by alias); 30 Apr 2013 20:59:55 -0000 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 Received: (qmail 22173 invoked by uid 89); 30 Apr 2013 20:59:54 -0000 X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-qe0-f73.google.com (HELO mail-qe0-f73.google.com) (209.85.128.73) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 30 Apr 2013 20:59:53 +0000 Received: by mail-qe0-f73.google.com with SMTP id 9so104736qea.0 for ; Tue, 30 Apr 2013 13:59:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:to:subject:user-agent:mime-version:content-type :content-transfer-encoding:message-id:from:x-gm-message-state; bh=Hw+9+aftpUP/TrWFGqHm2001C1nm7HoAZ/NWohBneZw=; b=VPeHAxnNNjxMFRsY34PxEwJ8hxbgCoewNUSXtYUvKpjxB4dcUESy6yap8OGoSvHMFO H2BruzIurnFhh37+rW3yJS8YnTYyff1/aEvYUBbfvN4WIZ+kly4k4+Ps8pYiAAlKJUSm zDvtFJcOIKZUaIwoQE/DgeRX14e92JeHopkA0Cn2Z1+cY1QcRbKuxixM75kwzf5+PJRJ CekF4YFXwm/kzDxDqjHhNE9Ivnw4TqzjuR0ltNu4TnM3qazOiSWrxjkPXyLEkJCBM3FQ emybVS3lgi3Mn3Xy0ZSCiHGSJ9QeI1NoTNYYKM2gI6O4odEc2ls56J3ofE5q41VHHbZm rkuQ== X-Received: by 10.236.123.199 with SMTP id v47mr17978475yhh.21.1367354095740; Tue, 30 Apr 2013 13:34:55 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id i36si465422yhb.3.2013.04.30.13.34.55 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 30 Apr 2013 13:34:55 -0700 (PDT) Received: from hchopra.mtv.corp.google.com (hchopra.mtv.corp.google.com [172.17.133.27]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 9632131C3B3; Tue, 30 Apr 2013 13:34:55 -0700 (PDT) Received: by hchopra.mtv.corp.google.com (Postfix, from userid 48577) id 4036F12092E; Tue, 30 Apr 2013 13:34:55 -0700 (PDT) Date: Tue, 30 Apr 2013 13:34:55 -0700 To: gcc-patches@gcc.gnu.org, davidxl@google.com, reply@codereview.appspotmail.com Subject: [google] Add function name to function_patch_* sections (issue9025045) User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-Id: <20130430203455.4036F12092E@hchopra.mtv.corp.google.com> From: harshit@google.com (Harshit Chopra) X-Gm-Message-State: ALoCoQkDGJ1vPYEUCeurqlBzJrRoKcAn/I+YaogcL3l8nCHYAdWtAA3SGLmj2QEClKHjXL+YWMjFr7Y/E6NpSit3B6ScYPBIdcC2hQeS/HA8rqmHjpqfwvm3ns2JDAgAfUt2yQVIpmHRiE0xGjg68ZAvxR9XhO26NPeN4Wk9cUVezh1ecMJyYUfJFdXUCQXODcO+K/o3JZOE Adding function name to the function_patch_* sections when -ffunction-sections is provided. Helps in garbage collecting dead functions with the help of linker. Tested: Tested using 'make -k check-gcc RUNTESTFLAGS="i386.exp=patch* --target_board=unix\{-m32,,-m64\}"'. 2013-04-30 Harshit Chopra * gcc/config/i386/i386.c (ix86_output_function_nops_prologue_epilogue): (ix86_elf_asm_named_section): --- This patch is available for review at http://codereview.appspot.com/9025045 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index aa6ec82..7cb832b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -11285,6 +11285,8 @@ ix86_output_function_nops_prologue_epilogue (FILE *file, unsigned int section_flags = SECTION_RELRO; char *section_name_comdat = NULL; const char *decl_section_name = NULL; + const char *func_name = NULL; + char *section_name_function_sections = NULL; size_t len; gcc_assert (num_remaining_nops >= 0); @@ -11336,12 +11338,24 @@ ix86_output_function_nops_prologue_epilogue (FILE *file, { decl_section_name = TREE_STRING_POINTER (DECL_SECTION_NAME (current_function_decl)); - len = strlen (decl_section_name) + strlen (section_name) + 1; + len = strlen (decl_section_name) + strlen (section_name) + 2; section_name_comdat = (char *) alloca (len); sprintf (section_name_comdat, "%s.%s", section_name, decl_section_name); section_name = section_name_comdat; section_flags |= SECTION_LINKONCE; } + else if (flag_function_sections) + { + func_name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0); + if (func_name) + { + len = strlen (func_name) + strlen (section_name) + 2; + section_name_function_sections = (char *) alloca (len); + sprintf (section_name_function_sections, "%s.%s", section_name, + func_name); + section_name = section_name_function_sections; + } + } section = get_section (section_name, section_flags, current_function_decl); switch_to_section (section); /* Align the section to 8-byte boundary. */ @@ -11369,7 +11383,7 @@ ix86_elf_asm_named_section (const char *name, unsigned int flags, tree decl) { const char *section_name = name; - if (HAVE_COMDAT_GROUP && flags & SECTION_LINKONCE) + if (!flag_function_sections && HAVE_COMDAT_GROUP && flags & SECTION_LINKONCE) { const int prologue_section_name_length = sizeof(FUNCTION_PATCH_PROLOGUE_SECTION) - 1;