Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1303340ybt; Thu, 2 Jul 2020 01:58:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV+I0zrlbMp76uWdJe7E1eZzHe/qb1MsXnxbCrBY/ulhs1jmgWnDj7EUe5vH5ydySU/7ZU X-Received: by 2002:a17:906:f202:: with SMTP id gt2mr26289093ejb.70.1593680287720; Thu, 02 Jul 2020 01:58:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593680287; cv=none; d=google.com; s=arc-20160816; b=QaBwHNfa3GKKnsczNcGVVF2FGXfGEyVgJ0VSTGVSW4o4MtDncyUh+X44jsujBn7T+1 FkLP0g8p99YDHMeFnCQK57U8a0HNJUfDyiOocHNfqaQBblO37BjxTy+I0ehFofteSmd1 KB+WyME0tS6cx63C4BZrn/2+x8TdWv2dmzaiirR0xw5Uvyuycq6iuzDeUENErgbz1xht YNEjk4e4YvKhUfyWZUgZZnPYdjJ8OsEmeixCjlLecrGkUoECB0fA5PR3Q2Fe9IKVC5Dv NnHiJGV22ejovF6ONQMFY4IWV9Y2dO5Htj4DnQ0JC2d+TZPI4w212Ypnzi8Q0VKJ212B 5XpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=s7+5045RDL/6bm3EmBYWa1nF0teYes17mVjN68BsV4s=; b=fzdAhDOXEeaifNNd/6Wdgx1STAp3AkMpkfhi6iNd/NFGVRTGu2xIRc++AkQtQxWcQU VIAI6b/OOkoFNJjp9CmVX+9C97+r8ptvzV+gQNfmerhvwNAT01RS188GJJyvVKjNgg7M eONEbLdNlk2KGXbY64M3qQWFWfKzvDUn4sS3gP5JJOuXNUqPc0LNqrCNL1CETZq0UOkL Jm02iXnxrl38KBd4Tr+vUq0+5YW/XDkGlGkCk5d6o59yFbg4CFkZKlkR4+OvPpkiNcI7 YFH2hPaoGD5bwapNWKDAIjv0ghvlcuwyg51uoqOSCv5/TnY+H6sY0XVwv03xhAm/nlDd 5PBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kdrag0n.dev header.s=fm1 header.b=MEUQxuCJ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=uIwJGEKl; 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=kdrag0n.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si5848967ejl.52.2020.07.02.01.57.44; Thu, 02 Jul 2020 01:58:07 -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=@kdrag0n.dev header.s=fm1 header.b=MEUQxuCJ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=uIwJGEKl; 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=kdrag0n.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbgGBI5R (ORCPT + 99 others); Thu, 2 Jul 2020 04:57:17 -0400 Received: from wnew1-smtp.messagingengine.com ([64.147.123.26]:46763 "EHLO wnew1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgGBI5Q (ORCPT ); Thu, 2 Jul 2020 04:57:16 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 38122A00; Thu, 2 Jul 2020 04:57:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 02 Jul 2020 04:57:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kdrag0n.dev; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=s7+5045RDL/6bm3EmBYWa1nF0t eYes17mVjN68BsV4s=; b=MEUQxuCJJ1r4h/+JpF2w5cBdcKo6cDBS0qRTs19J75 ehTV09Hy2WMOV7jwHl1Q028sdcT3iloru0DPf/OAV+zF0Tc8YHCbQnMezjrQ8SBl 8JXqnEnayyz1lMXeKqxS6saV5yo+tnfbbljChCpicXScJkaVZMmS70AbU51AhOrf 2lPuOgWC8+NoaL9yUZwEsoizZe8tBXv38R2Yi28b44EcGFsh/I+fBuasnGQd8JHU hnAO0XP4qnzzLiSXes9lkelCifwYLwtb+TkyOd7hagtijYzMNNAVDv4jtJP2loN6 pPDlKhli20iC2ZK5jF/eovd+4QerMRwWgN9lQquNWlug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=s7+5045RDL/6bm3Em BYWa1nF0teYes17mVjN68BsV4s=; b=uIwJGEKl9OOX7XH8TGS0ED0QdtB9UaPg5 RRmSP3NzkSLLkhg/BmQFJXHUNlsGbiApl5d3zM6CEh039IzO6lWl9ZioOjfWJuci XgG+V3wUuU787MzEjfZCDBjPcfAAH0yueAWkbhD84pl5IRyeNdv5znqWhzfZlHbn 79jzloU/Lhd9lRGLlXon+DPLGCsDHC5tRZVTCtCLFraCpVj8avbHatr7aDrP9YgS mVt86StWW4vTo361/uoMyRCgTjTw0M+Yp/3g1xdgY3NlVN6LP4eTelTB9hUhJyQM JQs/Fb/T9AdvU417ZVIo8nqDTLVBj+UCG+MiJPgfmeyZaDkNEOYlQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrtdeggddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepffgrnhhnhicunfhi nhcuoegurghnnhihsehkughrrghgtdhnrdguvghvqeenucggtffrrghtthgvrhhnpedtvd etffeukeefuefffeeufedvtddvieegvefffeejfefhtdevjeetfefhgfehheenucffohhm rghinhepghhithhhuhgsrdgtohhmpdhlphgsgidruggrthgrnecukfhppedugeelrddvge ekrdefkedruddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepuggrnhhnhieskhgurhgrghdtnhdruggvvh X-ME-Proxy: Received: from pinwheel.localdomain (vsrv_sea01.kdrag0n.dev [149.248.38.11]) by mail.messagingengine.com (Postfix) with ESMTPA id CB7AC306005C; Thu, 2 Jul 2020 04:57:12 -0400 (EDT) From: Danny Lin To: Arnd Bergmann Cc: Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Kees Cook , Fangrui Song , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Danny Lin , stable@vger.kernel.org Subject: [PATCH] vmlinux.lds.h: Coalesce transient LLVM dead code elimination sections Date: Thu, 2 Jul 2020 01:54:00 -0700 Message-Id: <20200702085400.2643527-1-danny@kdrag0n.dev> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent LLVM 11 commit [1] made LLD stop implicitly coalescing some temporary LLVM sections, namely .{data,bss}..compoundliteral.XXX: [30] .data..compoundli PROGBITS ffffffff9ac9a000 19e9a000 000000000000cea0 0000000000000000 WA 0 0 32 [31] .rela.data..compo RELA 0000000000000000 40965440 0000000000001d88 0000000000000018 I 2238 30 8 [32] .data..compoundli PROGBITS ffffffff9aca6ea0 19ea6ea0 00000000000033c0 0000000000000000 WA 0 0 32 [33] .rela.data..compo RELA 0000000000000000 409671c8 0000000000000948 0000000000000018 I 2238 32 8 [...] [2213] .bss..compoundlit NOBITS ffffffffa3000000 1d85c000 00000000000000a0 0000000000000000 WA 0 0 32 [2214] .bss..compoundlit NOBITS ffffffffa30000a0 1d85c000 0000000000000040 0000000000000000 WA 0 0 32 [...] While these extra sections don't typically cause any breakage, they do inflate the vmlinux size due to the overhead of storing metadata for thousands of extra sections. It's also worth noting that for some reason, some downstream Android kernels can't boot at all if these sections aren't coalesced. This issue isn't limited to any specific architecture; it affects arm64 and x86 if CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is forced on. Example on x86 allyesconfig: Before: 2241 sections, 1170972 KiB After: 56 sections, 1171169 KiB [1] https://github.com/llvm/llvm-project/commit/9e33c096476ab5e02ab1c8442cc3cb4e32e29f17 Link: https://github.com/ClangBuiltLinux/linux/issues/958 Cc: stable@vger.kernel.org # v4.4+ Suggested-by: Fangrui Song Signed-off-by: Danny Lin --- include/asm-generic/vmlinux.lds.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index db600ef218d7..18968cba87c7 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -94,10 +94,10 @@ */ #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* .data..compoundliteral* #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral* #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* #else #define TEXT_MAIN .text -- 2.27.0