Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp284616lqp; Wed, 22 May 2024 04:48:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXdZnpsxK2Gbj/l6gkhIa5msQMWUjoxLE02/w3O/kdpbym/VcKg191U+Jf2R4IytA49QmgXVG7JU87VNI1OvCSmzBopvS2RUqKvph0qQQ== X-Google-Smtp-Source: AGHT+IHjmch7TERuSdUA+TnTC1H9bLUQOTMbvw5AQJ9ME5lWDgJud6MEGNfwwCAzdw1WxVD2d4m9 X-Received: by 2002:a9d:6c81:0:b0:6f1:1b18:7442 with SMTP id 46e09a7af769-6f666f7d387mr1681983a34.17.1716378508473; Wed, 22 May 2024 04:48:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716378508; cv=pass; d=google.com; s=arc-20160816; b=AMRmj17soVOQa16Jcfcmd1qY53wo0jwzOL1FjrA8FKpmpFMGO3LdYQRsMQmGQRYvQo CnGsogR5eD1JvzMXsAasp9GMruf6ywn5Vzy4+EddEJMDThC49d7EVgHj578pRZ9aMJbq GcLFk2uPAhFPNrE2sitE2hOJzWs6AqHSPR2unFVJSTRA77brBTQBgzVHPa7C9GOGWgLd 5IzHePxm24J63hFE4LfoybQKs/Klqz4/D/rUBeWL8AO64k0PgJPY6evgxJNR2plgl1yx WWOHgnnSqpWSL11o4UeinigxbGku4ZwDlsz5ppEf5tOaOQWh6V19WN5XyyFBiMDY+XSU AmbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/cBdbPvNv9ae8EatT3ch2D9OTQ+5fHnCTDOYKqwQHYI=; fh=6DdgBs5XFtSYYCv64YluhNL6tS5QdFvpwTAju8sM5RM=; b=HnaOjN9E7u5GRBEi/h4h6A5Ub1P0NyOctBEAOkeOuGk+rCKh/zFPlIhkjMDyfRvAR2 2nNlQ7g13Wz62zxQe+mh6zs7MdfHtqIPydkAHQrqbgMRRx4z03zy7+vJxfQ9QYGRagoz 7UXXnSL9JCLszsB/PLbKnqmlVTVZVgmFMDPv+LaDD68+Q/ySSRVtC6lBW1aP5gErdsJ7 5+ftz7xuV4MjlcdFZLlS1JMrgsFLTKy7lTCujPwfFiZaGmv6a2abj5isoDTby0gk1Hzy 7saxxhZ0OV5xWODQtp2wbSEv64xfDjAJsNBt+MxFxlN7pmJGJo/hK879HdaRQx2cWshw VHbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Io03li2v; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-186167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186167-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-634103f7273si2720407a12.423.2024.05.22.04.48.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 04:48:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Io03li2v; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-186167-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186167-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EA450284475 for ; Wed, 22 May 2024 11:48:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 240EF13D621; Wed, 22 May 2024 11:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Io03li2v" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43BE413D603; Wed, 22 May 2024 11:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716378487; cv=none; b=cIBTYsgMhjRA+DksSY5CjIYuw05lUYGXleXtTt5H8xVGK5labkf5Z4K+3j40KV99KI5q98Yn5h+Hky8ldUyngQYdR5N/xBtw6Or0V3LUCi70LuRbAczHtI8ktQBrbSuX3auc7r1E0XJvpKd7zu2kEklcnfudUS37F9N5D1JFF7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716378487; c=relaxed/simple; bh=lzIbvF3gIVq9T/Px5pSVLJh5s4Do0AkEJBg/Djx/IT0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nR0WpVcDlwFflcrwPQCcJO1UTcV993w4qIJlJY+7tXrxu2o0Z/KU3YzxnLhmGcNh33dR7xJE9ml+ZkH7OQHOffsS5++9xIDdUaNVjMRzDnaaOK/dZsuMkozu8HIYKxIr+xAJhnmXn8CxsWYLk5AB564dcpSpN0tKb79pkk/5kjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Io03li2v; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51847C32782; Wed, 22 May 2024 11:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716378486; bh=lzIbvF3gIVq9T/Px5pSVLJh5s4Do0AkEJBg/Djx/IT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Io03li2vndpRai2B2w81A9r1/7/HmnXSRzph6/swmGT3gk3x6hZomrV2RhmJRVkHG cRECv72bDbFw/xNvWytQd/+A6yJZsj7CBtaWd0KYHJ0TgPiwYVCI8M80p0VwV68OBh xdQsrDkVlSED2wjAKp0Qy/iJOvh7b6qTi6uICpoY8fAZ4yUtf9YtDdlAmzZZQYY/96 8kCCnyKpoIyceSEZHZ7CckqyWGI6CDRBJOhOTQaFGfibvHI7yyAud+lLXa/nQBaIOr yf7aUIPWBB/dB3kS6bzOOQcyepAToACpWPvizd7TSwomWAjGrMK5fbQWUhNHYNVtbp Nio0fgh856jAw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Ard Biesheuvel , Masahiro Yamada , Nathan Chancellor , Nicolas Schier Subject: [PATCH 1/3] kbuild: refactor variables in scripts/link-vmlinux.sh Date: Wed, 22 May 2024 20:47:53 +0900 Message-Id: <20240522114755.318238-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240522114755.318238-1-masahiroy@kernel.org> References: <20240522114755.318238-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Clean up the variables in scripts/link-vmlinux.sh - Specify the extra objects directly in vmlinux_link() - Move the AS rule to kallsyms() - Set kallsymso and btf_vmlinux_bin_o where they are generated - Remove unneeded variable, kallsymso_prev No functional change intended. Signed-off-by: Masahiro Yamada --- scripts/link-vmlinux.sh | 48 +++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 46ce5d04dbeb..b16967d33f1c 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -45,7 +45,6 @@ info() # Link of vmlinux # ${1} - output file -# ${2}, ${3}, ... - optional extra .o files vmlinux_link() { local output=${1} @@ -101,7 +100,7 @@ vmlinux_link() ${ld} ${ldflags} -o ${output} \ ${wl}--whole-archive ${objs} ${wl}--no-whole-archive \ ${wl}--start-group ${libs} ${wl}--end-group \ - $@ ${ldlibs} + ${kallsymso} ${btf_vmlinux_bin_o} ${ldlibs} } # generate .BTF typeinfo from DWARF debuginfo @@ -142,9 +141,11 @@ gen_btf() et_rel='\1\0' fi printf "${et_rel}" | dd of=${2} conv=notrunc bs=1 seek=16 status=none + + btf_vmlinux_bin_o=${2} } -# Create ${2} .S file with all symbols from the ${1} object file +# Create ${2}.o file with all symbols from the ${1} object file kallsyms() { local kallsymopt; @@ -165,27 +166,25 @@ kallsyms() kallsymopt="${kallsymopt} --lto-clang" fi - info KSYMS ${2} - scripts/kallsyms ${kallsymopt} ${1} > ${2} + info KSYMS "${2}.S" + scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S" + + info AS "${2}.o" + ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \ + ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} -c -o "${2}.o" "${2}.S" + + kallsymso=${2}.o } # Perform one step in kallsyms generation, including temporary linking of # vmlinux. kallsyms_step() { - kallsymso_prev=${kallsymso} kallsyms_vmlinux=.tmp_vmlinux.kallsyms${1} - kallsymso=${kallsyms_vmlinux}.o - kallsyms_S=${kallsyms_vmlinux}.S - vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o} - mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms - kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S} - - info AS ${kallsymso} - ${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \ - ${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \ - -c -o ${kallsymso} ${kallsyms_S} + vmlinux_link "${kallsyms_vmlinux}" + mksysmap "${kallsyms_vmlinux}" "${kallsyms_vmlinux}.syms" + kallsyms "${kallsyms_vmlinux}.syms" "${kallsyms_vmlinux}" } # Create map file with all symbols from ${1} @@ -223,19 +222,17 @@ fi ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init init/version-timestamp.o -btf_vmlinux_bin_o="" +kallsymso= +btf_vmlinux_bin_o= + if is_enabled CONFIG_DEBUG_INFO_BTF; then - btf_vmlinux_bin_o=.btf.vmlinux.bin.o - if ! gen_btf .tmp_vmlinux.btf $btf_vmlinux_bin_o ; then + if ! gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then echo >&2 "Failed to generate BTF for vmlinux" echo >&2 "Try to disable CONFIG_DEBUG_INFO_BTF" exit 1 fi fi -kallsymso="" -kallsymso_prev="" -kallsyms_vmlinux="" if is_enabled CONFIG_KALLSYMS; then # kallsyms support @@ -262,10 +259,9 @@ if is_enabled CONFIG_KALLSYMS; then # ${kallsymso}. kallsyms_step 1 - kallsyms_step 2 + size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso}) - # step 3 - size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev}) + kallsyms_step 2 size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso}) if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then @@ -273,7 +269,7 @@ if is_enabled CONFIG_KALLSYMS; then fi fi -vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} +vmlinux_link vmlinux # fill in BTF IDs if is_enabled CONFIG_DEBUG_INFO_BTF && is_enabled CONFIG_BPF; then -- 2.40.1