Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp673029pxb; Wed, 18 Nov 2020 14:10:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVbjv6tl3EbcXo8EaUNoufQPQAnbvh++d9O3ReS0ktwsijizFDsKJz9zU+u3fCGEhxY6Fs X-Received: by 2002:a17:906:b003:: with SMTP id v3mr27336279ejy.290.1605737447724; Wed, 18 Nov 2020 14:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605737447; cv=none; d=google.com; s=arc-20160816; b=zA6UAa5SSzrNh5KFH2BKpq1UUnivd5Vhr2AzAXBg7uDNBjVx05RtnwMRVm4I/M1Y7S xYHKRBRXcONtq7iwxbIxn//avIJ5gef7q711lBokWdQ6kydTrM4455suTrQnshaWqTFy iIj2FlC4Vxj20W1afllEs9RPwpNRJDy5ZU0v4gNrlb3lTku4MsOeU2QXnuDCRWi9Jk17 1P9JMsyM+AGKMwyq6y10EU5OBL9iA5+SA1m9cqzKrUMLPiSDa6/zZEAB6+lh6yG2bzz/ C7Pgr0bPA3yFC74E/elVMPK0Alxn4k+RTTzOAmVFvhfNfdQvax72BMa4soVHWCt8Nsef 2EKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=7xcmRRx6qvqOlAhBXvPUxdlcJiFGDszFPn6Uy8LsYGg=; b=N5vgzLRm7e7X+fiIZz2fqXHWvmIfY+mp775lauy8eW+LwVnNn+nt1rHAExx1b2iUoE UrM6a/gBdXXxrESEc5TTFj/0RBgoiYr4Uhj7Gq/1yeZKeYThO54GEjH9KJiSwqsqIXqF y6E2j05wPxr5zRFByHlGlgDr3KDouoqPy+X9INcPhVOxbx5zXyU2tVM12sabZFUBxTJG vzObjTpp5YCZpNoOt6SGBfqmHb2ON24cFWEm9JAazluPOx5NTXtyHJ9g5swK1Vwl5rwW 41Ri+gUEgsQmkY8bGpcdUlXIii+or/phE/7jWc3MwO0vR1XJC01e3mAfhaO7LWBTvpEj lJkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="JUEhAG5/"; 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 dx21si3854049ejb.627.2020.11.18.14.10.19; Wed, 18 Nov 2020 14:10:47 -0800 (PST) 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="JUEhAG5/"; 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 S1727321AbgKRWHr (ORCPT + 99 others); Wed, 18 Nov 2020 17:07:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727276AbgKRWHo (ORCPT ); Wed, 18 Nov 2020 17:07:44 -0500 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0343AC061A52 for ; Wed, 18 Nov 2020 14:07:44 -0800 (PST) Received: by mail-qk1-x749.google.com with SMTP id c18so2823400qkl.15 for ; Wed, 18 Nov 2020 14:07:43 -0800 (PST) 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=7xcmRRx6qvqOlAhBXvPUxdlcJiFGDszFPn6Uy8LsYGg=; b=JUEhAG5/26jx0k7UneLL1f8TdMXEdBCuTZJVLjQZ+iZWRpM2bbt0EXRlMyK8xh/rhj JL4aCETLnrd/8DvtoDDkLX34DHCsBE1h9hQQTOHP3TNRNJUaUtVu/5oPiKBq0scCRP6Z +kh1Oyf9NPyMM2Lo7bgcXU9P4bjc/YYA21H9WcxDydQqHpZaclET/mWLe+Q6TCvtF3wo mKxhKgjFnSmEhpPgl/7XzG7iiLKXi7xIewYjRRnbWXMkQNf1t/hl5/7hnFoxRkDw2MOb rVfAfcrlGtLV3PMRjEVyZEJWFeaaAKgzOew1LFSh6KyTd7yH/s0nFEbQGjmL0toalfsR lLAQ== 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=7xcmRRx6qvqOlAhBXvPUxdlcJiFGDszFPn6Uy8LsYGg=; b=TQJ7By1/7s3eYcDeiyfTrQ39WIy7KYEovFHXE/alp6bAmUK1Q8gGZ0EjQWh2SCJFVb ODlLRE8qPLhQGy3EXUTPttoifTaeHN4XStEjHbl2F+7b+Dbg1V3bCoXBUkr+vVjM9oIU PLsMGXnhxROuzVac0kCfLsyF/NWZWSiy+SQ5jQj3uCRgkAsl1/DEOC6nVO/Z6b2ZBzr8 4PYCBh2G7vlf+QJRAin9BZJIW2EApNjFfcCEug3Y6Zb7XNkvI0D6McRmRe6qa6tbKyWq iUO6CWUmDKFot6rnzI0rd1SI5bNbRURt6lU2ZvSPfz76CoYkAzzXLV0MWCKy3l+oFrTD tyyw== X-Gm-Message-State: AOAM5303TSvFvpozgTCTeHnMK3qjMajRO7DhgJZGpLCFv56a7mda7L4X r8XExN+QL5Wn8RZe7t/S84Myh+BO+jKY+gmoSvE= Sender: "samitolvanen via sendgmr" X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f693:9fff:fef4:1b6d]) (user=samitolvanen job=sendgmr) by 2002:a0c:8004:: with SMTP id 4mr7501644qva.5.1605737263123; Wed, 18 Nov 2020 14:07:43 -0800 (PST) Date: Wed, 18 Nov 2020 14:07:19 -0800 In-Reply-To: <20201118220731.925424-1-samitolvanen@google.com> Message-Id: <20201118220731.925424-6-samitolvanen@google.com> Mime-Version: 1.0 References: <20201118220731.925424-1-samitolvanen@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v7 05/17] kbuild: lto: merge module sections From: Sami Tolvanen To: Masahiro Yamada , Steven Rostedt , Will Deacon Cc: Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 69b9b71a6a47..18d5b8423635 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -23,6 +23,30 @@ SECTIONS { .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) } __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } + + __patchable_function_entries : { *(__patchable_function_entries) } + + /* + * 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. + */ + .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_]*) } } /* bring in arch-specific sections */ -- 2.29.2.299.gdc1121823c-goog