Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1930189pxu; Sun, 13 Dec 2020 07:57:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFGC3PhD5kdntbEmNBBRWWLNjMBStnRWfI8tShNhewRJf853ibH5N/Zr/EQJMbyxuy/2WN X-Received: by 2002:a17:906:7687:: with SMTP id o7mr19357137ejm.209.1607875032248; Sun, 13 Dec 2020 07:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607875032; cv=none; d=google.com; s=arc-20160816; b=v0jCymP4xmI6NzQmmWAljYGmlyj1qOpwNbNDAZ4h6ENyxdrJ5n1G6Kz+q0+VkXAOz6 J5pVTLfAPGMqCG2Hn+b4rpqZFpho3gmK51c4eY28qerHfMs4xMBraxkDv5ZHk/fkXUke XCEGnmN1soQbR9rPWU081V3nyepQ3jbgEGFF6NziN0n/Vak20fqK4NcnHvK9Nv+Vt+fD TezQFcNgRoucdxwUnIR1rxMwOCXp4HQRgrVd89ftT0NA0Ze7LjPCiG1pBkqVHlg9RmuS NCqanhCqB3RMIev+zJeZFwU/ofDK1RBP0niRgSylialVgy/AjUzKJhmYiQzxBCukF1PC ycZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iVFtuDnRTBchBNGcp8rnhcp3PvraLw1PGTlClJ8cxSk=; b=Hs5SABg6uAXE5247tU+cOqAPPSA7W8sqOqqfEe5qq174nkRItzMx2mDTTv8IwLaxcr iQ2378eFAypD9kOqrIbZa/Cik/yGTc+7IM0s9m/z/re85yaNeOfLXLZ6QyjpVdOPAPBB wUGIjv64pc1VARc6p9uHOJVQV6hksuTZxGwRAOlJsSghJh5sH6wFWqLTDC0z9sqqrv39 S365zJKf9sy4oWAT1QjEowQLYH9yFV4RMlbKF0HeJdHmKqmx/af/P8pvhWeHLz6HEOaN AKkWJLTQY2Zkn6iZwYllVBz7aIiIn0Fzd9HkQ19ut/aAgcRM3ZbJupQQZt9cc6eN/UaS 29DA== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si8596599edc.354.2020.12.13.07.56.49; Sun, 13 Dec 2020 07:57:12 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407472AbgLLQMA (ORCPT + 99 others); Sat, 12 Dec 2020 11:12:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:57718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439400AbgLLQJ4 (ORCPT ); Sat, 12 Dec 2020 11:09:56 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masahiro Yamada , Sami Tolvanen , Sasha Levin , linux-kbuild@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 22/23] kbuild: avoid split lines in .mod files Date: Sat, 12 Dec 2020 11:08:03 -0500 Message-Id: <20201212160804.2334982-22-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201212160804.2334982-1-sashal@kernel.org> References: <20201212160804.2334982-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 7d32358be8acb119dcfe39b6cf67ec6d94bf1fe7 ] "xargs echo" is not a safe way to remove line breaks because the input may exceed the command line limit and xargs may break it up into multiple invocations of echo. This should never happen because scripts/gen_autoksyms.sh expects all undefined symbols are placed in the second line of .mod files. One possible way is to replace "xargs echo" with "sed ':x;N;$!bx;s/\n/ /g'" or something, but I rewrote the code by using awk because it is more readable. This issue was reported by Sami Tolvanen; in his Clang LTO patch set, $(multi-used-m) is no longer an ELF object, but a thin archive that contains LLVM bitcode files. llvm-nm prints out symbols for each archive member separately, which results a lot of dupications, in some places, beyond the system-defined limit. This problem must be fixed irrespective of LTO, and we must ensure zero possibility of having this issue. Link: https://lkml.org/lkml/2020/12/1/1658 Reported-by: Sami Tolvanen Signed-off-by: Masahiro Yamada Reviewed-by: Sami Tolvanen Signed-off-by: Sasha Levin --- scripts/Makefile.build | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a467b93234424..80953d5cce80f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -252,6 +252,9 @@ objtool_dep = $(objtool_obj) \ ifdef CONFIG_TRIM_UNUSED_KSYMS cmd_gen_ksymdeps = \ $(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd + +# List module undefined symbols +undefined_syms = $(NM) $< | $(AWK) '$$1 == "U" { printf("%s%s", x++ ? " " : "", $$2) }'; endif define rule_cc_o_c @@ -271,13 +274,6 @@ define rule_as_o_S $(call cmd,modversions_S) endef -# List module undefined symbols (or empty line if not enabled) -ifdef CONFIG_TRIM_UNUSED_KSYMS -cmd_undef_syms = $(NM) $< | sed -n 's/^ *U //p' | xargs echo -else -cmd_undef_syms = echo -endif - # Built-in and composite module parts $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE $(call if_changed_rule,cc_o_c) @@ -285,7 +281,7 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE cmd_mod = { \ echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \ - $(cmd_undef_syms); \ + $(undefined_syms) echo; \ } > $@ $(obj)/%.mod: $(obj)/%.o FORCE -- 2.27.0