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.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 1A589C433E2 for ; Mon, 7 Sep 2020 15:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D29132078E for ; Mon, 7 Sep 2020 15:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599492475; bh=GjaTLL9mqYgM0KFLEDVd8XJPVrWeuEDerRZq8QEoeCA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=bWlf8kGsEz7ir/c5LpHFllRtgDINw4nKO8zkapNn4BGjC58EF0VLZyqBIoQfJJjjG 5aDXvX0gnrQfPR4OnFY1jIKxcd5u1Yktsg+y2K4Tg0FpNykCREeo1G7MrfemSuunhv XIneQGTHp2V2lqdQIZc3Nk1pkX8Hx7ypqp0hnA00= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730177AbgIGP1u (ORCPT ); Mon, 7 Sep 2020 11:27:50 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:22974 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730072AbgIGP1G (ORCPT ); Mon, 7 Sep 2020 11:27:06 -0400 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 087FQVpa001816; Tue, 8 Sep 2020 00:26:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 087FQVpa001816 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.210.173] Received: by mail-pf1-f173.google.com with SMTP id c196so3310350pfc.0; Mon, 07 Sep 2020 08:26:32 -0700 (PDT) X-Gm-Message-State: AOAM531MQ94vq0bcadHaJu4h2pPF2hphNSNWiiobu5yZjv8EZaE3aG5O IChk22lQWldIeRKUdl3bBFeMVCfULHqrTixZCzY= 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 Cc: Will Deacon , Peter Zijlstra , Steven Rostedt , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , Linux Kbuild mailing list , Linux Kernel Mailing List , linux-pci@vger.kernel.org, X86 ML 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 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