From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 648C9C433E1 for ; Wed, 24 Jun 2020 21:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4445F207FC for ; Wed, 24 Jun 2020 21:02:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ERVcY1k3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388950AbgFXVCN (ORCPT ); Wed, 24 Jun 2020 17:02:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388770AbgFXVCM (ORCPT ); Wed, 24 Jun 2020 17:02:12 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB312C061796 for ; Wed, 24 Jun 2020 14:02:11 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id d66so1784275pfd.6 for ; Wed, 24 Jun 2020 14:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=ERVcY1k3sSjCpLOAr8awDULH6hHwCvyEkuApK5Qd/yy5SDCViDdkIB8JSQ5L/xRD+d 8Y592Pat2k/ChLh9OYujlbJnjlGNVLx/ZpfbEt1sE8kMlvWJzHlDhj0x+JLWI/sCQ71m Qc98XVDBN4Tj5eQLSTeQur2SwoHWInWoHJEhUCCE5GXRfarr8qGepXCtm5phPzsnQ/fx r0chNzaABXZLlufMpQ+880lEY1eRlM2cvfZqGUG3SBnyMqYm4bUW8z+wyLj5pHtSzavu pLpwIlYwlO/U6gNgApMNdpJIBGZ6tRJTmGgBOtagYfhNoPIS0UxFZGw9u/o29RNxq2va 8lJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=BjzclJM5TEdLR9fD+WWv6eXwFX3Q7ZzuMwPFUxw01arCpJsVgMtXcLLaNow5VdUrPw N+eGaCErzX7Li/ksQxiUbulabVa/ItY1+h72onohVwmcJoHs4Y42XNtjMfm4vgI0NU2M atb/4sw7U6ZnoYaFBSPOwlP6Zbrgchwijmiwillj/zGjT/c9wQihotvVqZfFzMzwVNy0 NZNoVGbPl8i4Iew7xYwBERh7GLlWmQOoTZZkGN0m9g70FmbHiRT1XgrTRMhPHlroJnf9 xMJj0FBQjAW90LpXdxnjiH05PT7cOQnZNws0/uhPZj+7MnIks7kQ/9DmdL3c8V148Ysr vYnA== X-Gm-Message-State: AOAM530jNCUYgsbYDdCx22ajHyIx9fNBlFK9Kc1YD9pxk8rCQV9If68v E1pM3Bu8lb5/m9iX+mPqAhxmqw+hP8f9u8qI5TzRQw== X-Google-Smtp-Source: ABdhPJy3pMPiQAGPmTVujSMRX6922OqjtLRlYCZUOTerucVNVRzOs/5XjS34LxJ/ndw7kmB1zYWqmSiQ8V38zGtrKuE= X-Received: by 2002:a05:6a00:15ca:: with SMTP id o10mr31723451pfu.169.1593032530992; Wed, 24 Jun 2020 14:02:10 -0700 (PDT) MIME-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200624203200.78870-8-samitolvanen@google.com> In-Reply-To: <20200624203200.78870-8-samitolvanen@google.com> From: Nick Desaulniers Date: Wed, 24 Jun 2020 14:01:59 -0700 Message-ID: Subject: Re: [PATCH 07/22] kbuild: lto: merge module sections To: Sami Tolvanen Cc: Masahiro Yamada , Will Deacon , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , Linux ARM , Linux Kbuild mailing list , LKML , linux-pci@vger.kernel.org, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 1:33 PM Sami Tolvanen wrote: > > LLD always splits sections with LTO, which increases module sizes. This > change adds a linker script that merges the split sections in the final > module and discards the .eh_frame section that LLD may generate. For discarding .eh_frame, Kees is currently fighting with a series that I would really like to see land that enables warnings on orphan section placement. I don't see any new flags to inhibit .eh_frame generation, or discard it in the linker script, so I'd expect it to be treated as an orphan section and kept. Was that missed, or should that be removed from the commit message? > > Suggested-by: Nick Desaulniers > Signed-off-by: Sami Tolvanen > --- > Makefile | 2 ++ > scripts/module-lto.lds | 26 ++++++++++++++++++++++++++ > 2 files changed, 28 insertions(+) > create mode 100644 scripts/module-lto.lds > > diff --git a/Makefile b/Makefile > index ee66513a5b66..9ffec5fe1737 100644 > --- a/Makefile > +++ b/Makefile > @@ -898,6 +898,8 @@ CC_FLAGS_LTO_CLANG += -fvisibility=default > # Limit inlining across translation units to reduce binary size > LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5 > KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG) > + > +KBUILD_LDS_MODULE += $(srctree)/scripts/module-lto.lds > endif > > ifdef CONFIG_LTO > diff --git a/scripts/module-lto.lds b/scripts/module-lto.lds > new file mode 100644 > index 000000000000..65884c652bf2 > --- /dev/null > +++ b/scripts/module-lto.lds > @@ -0,0 +1,26 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and > + * -ffunction-sections, which increases the size of the final module. > + * Merge the split sections in the final binary. > + */ > +SECTIONS { > + __patchable_function_entries : { *(__patchable_function_entries) } > + > + .bss : { > + *(.bss .bss.[0-9a-zA-Z_]*) > + *(.bss..L* .bss..compoundliteral*) > + } > + > + .data : { > + *(.data .data.[0-9a-zA-Z_]*) > + *(.data..L* .data..compoundliteral*) > + } > + > + .rodata : { > + *(.rodata .rodata.[0-9a-zA-Z_]*) > + *(.rodata..L* .rodata..compoundliteral*) > + } > + > + .text : { *(.text .text.[0-9a-zA-Z_]*) } > +} > -- > 2.27.0.212.ge8ba1cc988-goog > -- Thanks, ~Nick Desaulniers From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 922C8C433DF for ; Wed, 24 Jun 2020 21:04:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63F4F207E8 for ; Wed, 24 Jun 2020 21:04:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xlOE9j43"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ERVcY1k3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63F4F207E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eseTHFvgpyjIAHgsDHJMC4/JVUVuCZ136nr1RKAZWUo=; b=xlOE9j43Fgjc6mV9+DuijQuG0 Mx/gvM9lAPeOT4sXBgR84i3lPSmkjMBYdMcnSQ7CYVD1mTgZrehhehYNJBAwb3kpMPGwTXoF/7sy1 R5+1Wr+GiuuPyd6nV6dA5fh61lRmQy/OQFhloVbKviEf7H3bbuSDzVCHF1skdVsoItWVzc6NV6WC0 cxb4/2Oa1ZuJujUg0odHMc9Wh7JJ9hDgSNlKxkhvV0/eCI0GHAZmLib9PVYjxVT+3DaKC6AOPLWGz Dz65tsB8jY+r7eG611Ahz34dyPnbZbt2+/ixxzNO1BVZDZobX+W0RqS/Klof4cOhzTk5iACl7KGuZ HFOr9Migw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joCXH-0004g3-FC; Wed, 24 Jun 2020 21:02:23 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joCX7-0004bR-Nx for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 21:02:15 +0000 Received: by mail-pf1-x441.google.com with SMTP id f9so1803009pfn.0 for ; Wed, 24 Jun 2020 14:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=ERVcY1k3sSjCpLOAr8awDULH6hHwCvyEkuApK5Qd/yy5SDCViDdkIB8JSQ5L/xRD+d 8Y592Pat2k/ChLh9OYujlbJnjlGNVLx/ZpfbEt1sE8kMlvWJzHlDhj0x+JLWI/sCQ71m Qc98XVDBN4Tj5eQLSTeQur2SwoHWInWoHJEhUCCE5GXRfarr8qGepXCtm5phPzsnQ/fx r0chNzaABXZLlufMpQ+880lEY1eRlM2cvfZqGUG3SBnyMqYm4bUW8z+wyLj5pHtSzavu pLpwIlYwlO/U6gNgApMNdpJIBGZ6tRJTmGgBOtagYfhNoPIS0UxFZGw9u/o29RNxq2va 8lJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=Yk8sByN+ikfjkrjF3z96AWUOo73VdInu23YH3P7S839N1lm41p5ig//LwPayk8BrZh oKMZ7Vv6ozHOURqEXQV+Z7/RE8LgdTS1ljeoHuqPyB+/5Wiok9K3cVvFEDIpZfE2KFuu o9f4KN4cYu5ALOnI3hU3qkSIKihEG3hrMAlakwBIaav8HtKVKkXDHeUNWd/is5kPkVac vluq3Q3pr5G72c9zcrIaUlXvctcHuiaNw1JE5cPjn/tpXaHT2T96kSZOIf0tCwav3/hu 5ymlNm01YeZ1DIcNyBpecQ70/YR+2UP7GnuCGKrISMAyIhYpXbto1vz6IdLqBCFwwJ5X PROQ== X-Gm-Message-State: AOAM533z1MQsJQNG5Z+n6DeAqMRMgmT7scznk+aIh2RKi0FMa6l4uJv6 EXXVKU/UmhTYnWXZMFG8wCrTa2Oeu3daN9QtnE3gag== X-Google-Smtp-Source: ABdhPJy3pMPiQAGPmTVujSMRX6922OqjtLRlYCZUOTerucVNVRzOs/5XjS34LxJ/ndw7kmB1zYWqmSiQ8V38zGtrKuE= X-Received: by 2002:a05:6a00:15ca:: with SMTP id o10mr31723451pfu.169.1593032530992; Wed, 24 Jun 2020 14:02:10 -0700 (PDT) MIME-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200624203200.78870-8-samitolvanen@google.com> In-Reply-To: <20200624203200.78870-8-samitolvanen@google.com> From: Nick Desaulniers Date: Wed, 24 Jun 2020 14:01:59 -0700 Message-ID: Subject: Re: [PATCH 07/22] kbuild: lto: merge module sections To: Sami Tolvanen X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , "maintainer:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , Kees Cook , "Paul E. McKenney" , Kernel Hardening , Greg Kroah-Hartman , Masahiro Yamada , Linux Kbuild mailing list , LKML , clang-built-linux , linux-pci@vger.kernel.org, Will Deacon , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 24, 2020 at 1:33 PM Sami Tolvanen wrote: > > LLD always splits sections with LTO, which increases module sizes. This > change adds a linker script that merges the split sections in the final > module and discards the .eh_frame section that LLD may generate. For discarding .eh_frame, Kees is currently fighting with a series that I would really like to see land that enables warnings on orphan section placement. I don't see any new flags to inhibit .eh_frame generation, or discard it in the linker script, so I'd expect it to be treated as an orphan section and kept. Was that missed, or should that be removed from the commit message? > > Suggested-by: Nick Desaulniers > Signed-off-by: Sami Tolvanen > --- > Makefile | 2 ++ > scripts/module-lto.lds | 26 ++++++++++++++++++++++++++ > 2 files changed, 28 insertions(+) > create mode 100644 scripts/module-lto.lds > > diff --git a/Makefile b/Makefile > index ee66513a5b66..9ffec5fe1737 100644 > --- a/Makefile > +++ b/Makefile > @@ -898,6 +898,8 @@ CC_FLAGS_LTO_CLANG += -fvisibility=default > # Limit inlining across translation units to reduce binary size > LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5 > KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG) > + > +KBUILD_LDS_MODULE += $(srctree)/scripts/module-lto.lds > endif > > ifdef CONFIG_LTO > diff --git a/scripts/module-lto.lds b/scripts/module-lto.lds > new file mode 100644 > index 000000000000..65884c652bf2 > --- /dev/null > +++ b/scripts/module-lto.lds > @@ -0,0 +1,26 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and > + * -ffunction-sections, which increases the size of the final module. > + * Merge the split sections in the final binary. > + */ > +SECTIONS { > + __patchable_function_entries : { *(__patchable_function_entries) } > + > + .bss : { > + *(.bss .bss.[0-9a-zA-Z_]*) > + *(.bss..L* .bss..compoundliteral*) > + } > + > + .data : { > + *(.data .data.[0-9a-zA-Z_]*) > + *(.data..L* .data..compoundliteral*) > + } > + > + .rodata : { > + *(.rodata .rodata.[0-9a-zA-Z_]*) > + *(.rodata..L* .rodata..compoundliteral*) > + } > + > + .text : { *(.text .text.[0-9a-zA-Z_]*) } > +} > -- > 2.27.0.212.ge8ba1cc988-goog > -- Thanks, ~Nick Desaulniers _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C986C433E0 for ; Wed, 24 Jun 2020 21:02:30 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 6BC54207E8 for ; Wed, 24 Jun 2020 21:02:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ERVcY1k3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BC54207E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-19134-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 10007 invoked by uid 550); 24 Jun 2020 21:02:23 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 9972 invoked from network); 24 Jun 2020 21:02:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=ERVcY1k3sSjCpLOAr8awDULH6hHwCvyEkuApK5Qd/yy5SDCViDdkIB8JSQ5L/xRD+d 8Y592Pat2k/ChLh9OYujlbJnjlGNVLx/ZpfbEt1sE8kMlvWJzHlDhj0x+JLWI/sCQ71m Qc98XVDBN4Tj5eQLSTeQur2SwoHWInWoHJEhUCCE5GXRfarr8qGepXCtm5phPzsnQ/fx r0chNzaABXZLlufMpQ+880lEY1eRlM2cvfZqGUG3SBnyMqYm4bUW8z+wyLj5pHtSzavu pLpwIlYwlO/U6gNgApMNdpJIBGZ6tRJTmGgBOtagYfhNoPIS0UxFZGw9u/o29RNxq2va 8lJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=a9OBR/A90yRyN5fUw95FANHncC7Hmmv6qf+BCNb7I90vNtintvrOQv8yhB1OtAv29g FBGeUj1oY301xHAcocBoYoc1g7o3YecettyLCNVMkfDElMqIeG3nV4zqRcmaEMQa3xEQ P/HeRPNCtw6aijqtyAhsNkmKc+EUN4Ee1OnrKA8+PJTA8RxJ1qpeDgcrmWeJ/Xe6OG1t MA6BkrGy764xJ6GPvEymkgnyxv/mLQn4eb0KE56LBYt9gahr5ZyVfy7aB7xqCzpIPbz9 6pb4y3pmrAEYUCS/6iQFjrXdq396KdobfcCFh7y8dLvQOaBHZRuYsaWnt47OA15ledFB vPVQ== X-Gm-Message-State: AOAM531px6HQG3dTSzqrS26wB/TTq56kPemxIKh0nmwwB55yL4Pg0EqY nhWToCPXaAaAHCnJDQS2KLYG/YFXxK3uPlHpU8++Rv+k X-Google-Smtp-Source: ABdhPJy3pMPiQAGPmTVujSMRX6922OqjtLRlYCZUOTerucVNVRzOs/5XjS34LxJ/ndw7kmB1zYWqmSiQ8V38zGtrKuE= X-Received: by 2002:a05:6a00:15ca:: with SMTP id o10mr31723451pfu.169.1593032530992; Wed, 24 Jun 2020 14:02:10 -0700 (PDT) MIME-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200624203200.78870-8-samitolvanen@google.com> In-Reply-To: <20200624203200.78870-8-samitolvanen@google.com> From: Nick Desaulniers Date: Wed, 24 Jun 2020 14:01:59 -0700 Message-ID: Subject: Re: [PATCH 07/22] kbuild: lto: merge module sections To: Sami Tolvanen Cc: Masahiro Yamada , Will Deacon , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , Linux ARM , Linux Kbuild mailing list , LKML , linux-pci@vger.kernel.org, "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Content-Type: text/plain; charset="UTF-8" On Wed, Jun 24, 2020 at 1:33 PM Sami Tolvanen wrote: > > LLD always splits sections with LTO, which increases module sizes. This > change adds a linker script that merges the split sections in the final > module and discards the .eh_frame section that LLD may generate. For discarding .eh_frame, Kees is currently fighting with a series that I would really like to see land that enables warnings on orphan section placement. I don't see any new flags to inhibit .eh_frame generation, or discard it in the linker script, so I'd expect it to be treated as an orphan section and kept. Was that missed, or should that be removed from the commit message? > > Suggested-by: Nick Desaulniers > Signed-off-by: Sami Tolvanen > --- > Makefile | 2 ++ > scripts/module-lto.lds | 26 ++++++++++++++++++++++++++ > 2 files changed, 28 insertions(+) > create mode 100644 scripts/module-lto.lds > > diff --git a/Makefile b/Makefile > index ee66513a5b66..9ffec5fe1737 100644 > --- a/Makefile > +++ b/Makefile > @@ -898,6 +898,8 @@ CC_FLAGS_LTO_CLANG += -fvisibility=default > # Limit inlining across translation units to reduce binary size > LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5 > KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG) > + > +KBUILD_LDS_MODULE += $(srctree)/scripts/module-lto.lds > endif > > ifdef CONFIG_LTO > diff --git a/scripts/module-lto.lds b/scripts/module-lto.lds > new file mode 100644 > index 000000000000..65884c652bf2 > --- /dev/null > +++ b/scripts/module-lto.lds > @@ -0,0 +1,26 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * With CONFIG_LTO_CLANG, LLD always enables -fdata-sections and > + * -ffunction-sections, which increases the size of the final module. > + * Merge the split sections in the final binary. > + */ > +SECTIONS { > + __patchable_function_entries : { *(__patchable_function_entries) } > + > + .bss : { > + *(.bss .bss.[0-9a-zA-Z_]*) > + *(.bss..L* .bss..compoundliteral*) > + } > + > + .data : { > + *(.data .data.[0-9a-zA-Z_]*) > + *(.data..L* .data..compoundliteral*) > + } > + > + .rodata : { > + *(.rodata .rodata.[0-9a-zA-Z_]*) > + *(.rodata..L* .rodata..compoundliteral*) > + } > + > + .text : { *(.text .text.[0-9a-zA-Z_]*) } > +} > -- > 2.27.0.212.ge8ba1cc988-goog > -- Thanks, ~Nick Desaulniers