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=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 E8D3BC433E2 for ; Mon, 7 Sep 2020 15:32:07 +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 8C41C2065E for ; Mon, 7 Sep 2020 15:32:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KDyIjO1t"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="HF6kxwrZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C41C2065E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=7RGC8uOh7mO41sE6Ya9FLvYp3rhb+CGzYjyTpmDAqjk=; b=KDyIjO1t3COdtx0mTpP1N2c3P JETmQTQytpo2K/01RR5trlpRIjmtkHiHfWvYZ5C9yIrWlFmNZFYJqJUOUJ0DwxXcVujsIaDkeSlBc IUm1N3B81B+4KboV/rVA0VkS49P0JWN9IX9i6bJM2SEPA3k6fW3/lRlcPyk+8FN8ang9JddwJoz0P r9GGAvMXskLVmbTHBar4Aa3ih9S5w1Yeis7GhqMdaK0K6baTKErFdk/NhCdlZcmLwY3c9CH5ajhgX qEVrNSOU0CY7V3eo+CDV2rxzbGo50nlWD9ggxTPTMZC2ZH/Ku0JUcUDDd0kIL6yK6h35XNlJCh0lQ z7q/4CoRA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFJ5q-0000ej-9H; Mon, 07 Sep 2020 15:30:06 +0000 Received: from conssluserg-03.nifty.com ([210.131.2.82]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFJ2w-0007FL-Gd for linux-arm-kernel@lists.infradead.org; Mon, 07 Sep 2020 15:27:08 +0000 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 087FQVtt026179 for ; Tue, 8 Sep 2020 00:26:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 087FQVtt026179 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1599492392; bh=IR6uGigyFtGDGIA+2OM5ZSYgDCjCsPA/08OP3wwPpmI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HF6kxwrZWb/RyvWw0lecR13yfGnI7g+SVYuZ3GDrpLhjeQQBDFe3oweHMbptemm66 SshCNN/29Q2UvC9TLvqIwjxGc087kf+LNwwYemZ9X8N179UEkHP+whZYbBQFKBslQI QLRVSs1kmDEgwP5nA60GQLqD2M/mdvIvnBM0aTB/FKDPseKBNZcIq2a2D/0zPSmgKn AEmqSmPA7h2X4LFcI6QPvPonC70Ag3cB7mKCBtL8/C97R4MKbM4UHwkDKT0yrD5ghL Zfzv833opPYiVtdnMgBuia+Ds748+7ZOS+r2vFL3fF0+vwlBvikfS9mHMkE8AAJya3 YQxpECBRYEZSg== X-Nifty-SrcIP: [209.85.215.170] Received: by mail-pg1-f170.google.com with SMTP id g29so8182484pgl.2 for ; Mon, 07 Sep 2020 08:26:31 -0700 (PDT) X-Gm-Message-State: AOAM532wK9/SJQFUuCk4GnyoOM42DksL/hO1ctIavdy519C95Hwyn/lz qu4CSUD0qgvBDQhPPE+JqybTrjPHkq16nKn9xPI= X-Google-Smtp-Source: ABdhPJzWMpKJKkob3tKKbsRMggvPdqUmZIz53kyp4B311hdgI26YjoFRx5atEqEpQRhRX5rjh34sk2xeMQI+Eblelz8= X-Received: by 2002:a62:e116:: with SMTP id q22mr9587524pfh.179.1599492391141; Mon, 07 Sep 2020 08:26:31 -0700 (PDT) MIME-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> <20200903203053.3411268-1-samitolvanen@google.com> <20200903203053.3411268-14-samitolvanen@google.com> In-Reply-To: <20200903203053.3411268-14-samitolvanen@google.com> From: Masahiro Yamada Date: Tue, 8 Sep 2020 00:25:54 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 13/28] kbuild: lto: merge module sections To: Sami Tolvanen X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200907_112706_917039_FBF75BBC X-CRM114-Status: GOOD ( 22.27 ) 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 , X86 ML , Kees Cook , "Paul E. McKenney" , Kernel Hardening , Peter Zijlstra , Greg Kroah-Hartman , Linux Kbuild mailing list , Nick Desaulniers , Linux Kernel Mailing List , Steven Rostedt , clang-built-linux , linux-pci@vger.kernel.org, Will Deacon , linux-arm-kernel 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 Fri, Sep 4, 2020 at 5:31 AM 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. > > 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 c69e07bd506a..bb82a4323f1d 100644 > --- a/Makefile > +++ b/Makefile > @@ -921,6 +921,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..cbb11dc3639a > --- /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*) > + } > + > + .data : { > + *(.data .data.[0-9a-zA-Z_]*) > + *(.data..L*) > + } > + > + .rodata : { > + *(.rodata .rodata.[0-9a-zA-Z_]*) > + *(.rodata..L*) > + } > + > + .text : { *(.text .text.[0-9a-zA-Z_]*) } > +} > -- > 2.28.0.402.g5ffc5be6b7-goog > After I apply https://patchwork.kernel.org/patch/11757323/, is it possible to do like this ? #ifdef CONFIG_LTO SECTIONS { ... }; #endif in scripts/module.lds.S -- Best Regards Masahiro Yamada _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel