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.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 288D3C433E0 for ; Wed, 24 Jun 2020 20:36:10 +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 A5C15206C0 for ; Wed, 24 Jun 2020 20:36:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IME+RagJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="VR9flySj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5C15206C0 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+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: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=4RYi+bRPKjON1/zxsuoPxEyKeeLyRV4EAlIA8yOxxKk=; b=IME+RagJxy8gc5J37XzWMGRyW Mlk2AxWTyQAabgAfgzKI2VbVvfOxmQrnXBQkmPxZS4gvh+L5cNq0Va7lzrJIh5HncupkqHcMJQ+OT wXfM62Ck54T1kEbsKahmCMS2v4zlcRB8C9fixMFgsA+nkx1VoJcydsj7YRbAUJEvsNyl3Le6xvqLI 0GNI8yp2qS9+jWoBzDEOrNehX736s4yjgD66hR9DSxo3P6a2h2+Bs8KE+UvNgOoIOohaHUmT6SN/l OO6EVjwpBMG6ftCp8+72U9LUe4ESNwC5d1Q/yUvcKf5X1Le14YHfKrY3b9WT9paf78rlRzNhVrRuT dZ7/xi+aQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joC5n-0007Sf-N5; Wed, 24 Jun 2020 20:33:59 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joC53-00076i-Su for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 20:33:14 +0000 Received: by mail-qv1-xf49.google.com with SMTP id j18so2518794qvk.1 for ; Wed, 24 Jun 2020 13:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=BYARsb6kk5gBajh2Z9y53LZQA7+hhrma13n1XSCdmOU=; b=VR9flySjUJwP/ToHZH5/xrbg3xtifUP2l8XzNOwvghrmkrOPlt0NBT0Anzq/fEaIeF KEoHKkAEPYQr1ae9axGCAMJQRNQ8Zn+uof7PhiL9L7JyAKcAQBsmFp+OoG91RU7+TJkG Yd8jJUh3wkbN8zyU9bxEpyOLO9sldP4qCwirdkQYZ3Ena38i/lEtgSWPv5cRv7bJRl2N UiX9uZX38aM3TP9J7+dUEiU2tJ3qLNH5BAb5fEeb58kPFpZiXEQBsf9meYLOuEa3jWcW FzXtiDx3izZRRi7FrJm7yt+UOltEWjza1vZCyR1pwcnJuQrqqarBC6T6qstSc9SdhCTJ LIZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BYARsb6kk5gBajh2Z9y53LZQA7+hhrma13n1XSCdmOU=; b=Q3aBA/36DP8WnYT+8Puq0Ls9GJi7hZAsguCEgyFjDozdFYZxL901IHVPYveZzYOSnL 3nE7k3v0rN0KYSqS9b6uv04fsUONnTi0EOXZQExTWTIh/RaigfW6meDi0J7mEFcdqk0f 1SlIwaWk5Fzr198VMdEwOJlQel1uAnjvv26RGLt5D9iZVd8mK333Do0x1AsGuM/suFKg /VyEeNUiVOARmY0xFXTF2EE50o4ndVkGZanYoC5laEhWML2wLvD7nfAD7tHfG1xQxbK7 YuxVxJcclJw3mmAA9eB4r7+yU3XaIXXZbte1Ol7Dqv5yLb9cJ5iN7nqKBgNa7Fbi1fH1 PvBA== X-Gm-Message-State: AOAM532GYFUgtv7uE6y7ShyvQ5eHbJkAxCRQ+VoZSatg/6Ru2SohraVY 0bPSjzZpUOiR0lqIwePB4+GCbMfaowk/0gqP0cw= X-Google-Smtp-Source: ABdhPJxdPEjdTvmHsLqQfGRhGHv9oPLaWCC1GyywhBzfg/9OiO3i8xn63G4zB3hyB9DGHni9+sZkZnE+i9lcXDX/20s= X-Received: by 2002:a0c:9d44:: with SMTP id n4mr20638647qvf.35.1593030790865; Wed, 24 Jun 2020 13:33:10 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:45 -0700 In-Reply-To: <20200624203200.78870-1-samitolvanen@google.com> Message-Id: <20200624203200.78870-8-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 07/22] kbuild: lto: merge module sections From: Sami Tolvanen To: Masahiro Yamada , Will Deacon 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, 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, linux-arm-kernel@lists.infradead.org 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 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. 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel