From patchwork Tue Oct 13 00:31:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 11834597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4E2592C for ; Tue, 13 Oct 2020 00:34:59 +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 74C1E21655 for ; Tue, 13 Oct 2020 00:34:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BqY5wuZa"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BYCRNmFn"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="RWGnAnvd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74C1E21655 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+patchwork-linux-arm=patchwork.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:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5qcbLyqodYaWlPZR+tW0ku8tbPZHV4MK2ir3Li60ijs=; b=BqY5wuZa2lhTympAtKPrxT4zg FRtqqr9JvRcGnDRrPb0Qpbz1upRnei1usvZC7vl8EHmmwSCqmBt3ehjaGP2cZM5UsGS8LC9ICgqaV hhl6Zup0S9LhfE+h2mOgc80dvTLh1rRlfifIKmSSLNx4JAj9UP7Al4v/Q7M78qC39/9X14OD3NV1e /k0iYXT1WtN+6vQs9VRGIyY5ZK/rLQJok51bQvs5TcHpHh/nhZ6ScIus1wJz3akxa0ISeZPg+IWE1 UM6h0ac4rokXhQjRqOAyGRkNVYRInjqw0ntZXpOX0ahKOZw9EFOn8CG2k0QcQH3EHhAm6yLAtkIeU 8o0NXoGpA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kS8H5-0006Z4-BF; Tue, 13 Oct 2020 00:34:43 +0000 Received: from casper.infradead.org ([90.155.50.34]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kS8FC-0005dC-2M for linux-arm-kernel@merlin.infradead.org; Tue, 13 Oct 2020 00:32:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=i0HfMD/wRChzzw+H0j5SIQI+XYlsyfomuEvjB0A2b7U=; b=BYCRNmFnaZ9xw0tyiu7BpAjeUO 2DtRnTtCQYk8DC3BgUb2mqw/lhowKNLFQ/McBTe0bCM3fskSZ2/0P80xwUqKmIsSEFSzXDLYMlEVC eisf/QWSmPEkWXm01XzmqSENStGd5RlqfW/3J7MyIGJ2IeoKohTKCyGdxv7uzRIUivQN/oSXGHhmY fPTA++xs1cy/g/5OSIfMUqxFKXhUzagDBVkSpFRvs3SA2tyccMdt9SxcALkuGUqNayt3SZFLeD9cW cj2T2p2ijOOIC00bl52dluqXMUaWgPrEbkbkcTNpW+VVMbixFmcaP8r4X6R1HhVlmYB6LMcIHsOyD gvXRz4Gg==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kS8F6-0007gB-1v for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2020 00:32:44 +0000 Received: by mail-yb1-xb49.google.com with SMTP id z27so9379295ybi.17 for ; Mon, 12 Oct 2020 17:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=i0HfMD/wRChzzw+H0j5SIQI+XYlsyfomuEvjB0A2b7U=; b=RWGnAnvd5Lp76tMdFpNH1+zuCs711HvTmjeeqWExWdLO0b+IYvl8hseJy7bQVsA/yQ WbWgdjz9odSgS33tA7SyJrG23HtPbcQQ2sqTeDLN0z+XNW/U1+B04f29pxuTIBAo0Bwr 1kuUI0qew0RRwWEdSqeHxrYPCuM0lKcyAQQHVJyqk0NDK5lndU4kJ0nEntK7Gw/b+6ds NINAxQFY1xV9pWKvIAxegfc8BATcwAptMc23jyb2HlWegaJKMJtRw94gvpud1QRadkKB gA/bzBYbBksOIuoqgqduz/XaFVcQDSEIQm1NvRkC4MArUYBfjsPwupbm8iuKYDaYWWMx dfRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=i0HfMD/wRChzzw+H0j5SIQI+XYlsyfomuEvjB0A2b7U=; b=Y73t2uoAIYlI+0GF8nA0owpOjuUH6uejWehXDuo9TRDmiz0s1dv8MzkCFsizq5qUnP ARFI81DJfOXsnfFs8TVy1FTv6IPF52jYLFUW3vXKUAo6vkOTgwhqBMRV4oM6Fis6/t8c b/CBmSzl83YL9iL3v2vF0QSCF8BN6NLwJsva+RYxaQoDRV6UQ5VyAEGvjUOX+OBCRX8w fENs97QAeisAfGxGwwHCOI7pmDTN72/JMXKH+InGGYFDIpTE59u6Ecmcau/k/hw04U1H mLWnB+e+xm/kLPxyY79WcVnM8PsKBach1+7uxwm2XKirHNoc5zGzZVT6TAry111jMqAx OV9w== X-Gm-Message-State: AOAM530sRKZF1RqZBP685LCbnywl2c7EUN+9R6KwVpbfvNZmTJ/ILpFP Ib1/6YQ7JTkVdWwr09GUS22GqDoL4LHJV1EJRmE= X-Google-Smtp-Source: ABdhPJyWpX0TYRebf3Rkf2Yh1c8ADAskEKEgvpC4cZTbopj2J6pmYFQCkigTg2srbz/p2P1Qt1W0jVbIt5KqdOEhaLA= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a25:cc89:: with SMTP id l131mr12649555ybf.154.1602549152704; Mon, 12 Oct 2020 17:32:32 -0700 (PDT) Date: Mon, 12 Oct 2020 17:31:51 -0700 In-Reply-To: <20201013003203.4168817-1-samitolvanen@google.com> Message-Id: <20201013003203.4168817-14-samitolvanen@google.com> Mime-Version: 1.0 References: <20201013003203.4168817-1-samitolvanen@google.com> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog Subject: [PATCH v6 13/25] kbuild: lto: merge module sections From: Sami Tolvanen To: Masahiro Yamada , Steven Rostedt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201013_013240_419943_D23BF01A X-CRM114-Status: GOOD ( 11.93 ) X-Spam-Score: -9.6 (---------) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-9.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:b49 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender 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@vger.kernel.org, x86@kernel.org, Kees Cook , "Paul E. McKenney" , kernel-hardening@lists.openwall.com, Peter Zijlstra , Greg Kroah-Hartman , linux-kbuild@vger.kernel.org, Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Sami Tolvanen , linux-pci@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org LLD always splits sections with LTO, which increases module sizes. This change adds linker script rules to merge the split sections in the final module. Suggested-by: Nick Desaulniers Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- scripts/module.lds.S | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 69b9b71a6a47..037120173a22 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -25,5 +25,33 @@ SECTIONS { __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } } +#ifdef CONFIG_LTO_CLANG +/* + * 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_]*) } +} +#endif + /* bring in arch-specific sections */ #include