Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp926046ybt; Wed, 24 Jun 2020 15:02:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9D/cZuaJnzixdyxvKDg1rghY4mWAmHCD/5DzB2mbqhzmZBNyTTAKvKD5EyS8sYo4j2gRV X-Received: by 2002:aa7:d845:: with SMTP id f5mr9956764eds.162.1593036147211; Wed, 24 Jun 2020 15:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593036147; cv=none; d=google.com; s=arc-20160816; b=yo5RMQloJtzWzTAKjl8YX7oDgnIywZcBOwx2LT4oIU8VNbnHSTdjLTd65OabHpkO4h 1swPfDioiL0A+wd358omwhMzU5HZ/oMs+4uIRlzrjishcMiE97qaw2NSjQd/OSz1GyrR YEwz4WNKvlljtotlqvlWz/MneH2JyFPmFmv6bwCJIom80WMh7V+8C1BK5oTj3euESrtN 7NqD5u642Ah+2xaazVK8Zzbwi3HgY+eT/sfWf1Yv7MWnBUZwAMaGO9zpJQvZ3KpGtCQ/ pCQV3jGMD8yh5+1b027UUg/jVEOSxXWn7TGfAANe7D+ggBbF7G5kgcD9TPt7XvBfmXcq Kvfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=F0CH5zhnz6ayOh3mQsnUEqy/k37rjt1CS3Xrl+QPqsk=; b=PKRgu5zV1OG5XDcEVLb1YkTfdQNtSbrvE/7bzfSvyMSG4Dc0VjtMl6R1NoqbwFgls2 YEMAPxxeeYB6Ntbj9r2vav2Bpt+rglo4WX9lKOMb1lxce4LY9JtAw4jv8qNTkfnw/BhM pOGkXtYMXfeKJOrkUbqFEvHXhdZektZdV2FbKOsvlKCrPs771/kP9z0nc8lLJcLf4kGP vUezRxaYwfcenss+dj/VIMgxwO9IxMtZIHRZXK/9Bf2IhXs8gd3tDzCBkZEGD/LZEjhD Ws/09pzBgCr6dOoVv2+jB6fmsAGaz1KjiBEgq1w/hh1+mXuuXPn8W45q6ehvQIjAHOrp f1wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ERVcY1k3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si6294709edq.272.2020.06.24.15.02.04; Wed, 24 Jun 2020 15:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ERVcY1k3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388706AbgFXVCN (ORCPT + 99 others); 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-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