From nobody Sun Feb 8 00:35:10 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 8CF4C80635; Mon, 8 Jul 2024 11:49:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720439372; cv=none; b=JA1AOq0VmKNuM59MTNph1aT/Sr+sOY6iSrNX4MuvIgA+5Zl+IkKdp1olvNV6L8/DBisLieK1Xec7FVGhwX8EeAahtn6fKwMs/G2hVVHRQeka6FSyh1ZFXoVH1Kea8xfuafSRSESGoqp3W/K6Jz6NwSiYxvE5HGIQ+N6uz5UlSDU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720439372; c=relaxed/simple; bh=jBlkyAPNtd0Ap7FtDbpc2YGw+ApdIthKTQelheuVDz4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=DP2PUAocnpAaO7YJ3s0KOXD1mYNKEi5bxnQY8K4oJTKYD7hzazJJWInifl4gVf8NCWT3TbdywH51jB0s13Mu3vMuHVvU5mFYjHq3mmqbEHUTV6pwfu6I7YeNDzPNbY5i0Olx5CYaOeEFsu3jgzMdS50MzbhIRN3WVlfxm5YQrPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fWn/hygu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=jCzD+Sm8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fWn/hygu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jCzD+Sm8" Date: Mon, 08 Jul 2024 11:49:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1720439366; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbsZ3rfk8ZW6MPYXF75BfnIMxeAowy+66UhB+KjF1u0=; b=fWn/hygu3ohl7VcJ4lhtBtNfM+ISK2omEfSn1jrkt2ttGlXcEZiHhhiCcWy5S5iacuFCf3 dI2hioWRValVXZLRzqzRXJmgJthguXclTcaD4VYt5E4qGp0UlCIvuyQ6IT40SAcf02mKoZ cmj1Q6cE3VeVDFm6WkvQbKJ43+94uGDTYv0js9js7E1gg+D+KI27lEaywFZolK/qpmc/gw bSCEGhTrvJKMGviIKsJy/XKb6DLteC7JWxY+wPmrktC7io+0KZplR+BzQomfF9hbWgYl/P 3fKfivPX2y+PULN3v+Rx+RbzTewyn/VPuriUFjgyxJrjW+4p5P7jIFGSKUaaSA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1720439366; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PbsZ3rfk8ZW6MPYXF75BfnIMxeAowy+66UhB+KjF1u0=; b=jCzD+Sm8TqenIuckhcf4yvRyABs6ge6+HuLbfTTdQPC5yccV+iK60cVNEXqk9aPcX2uGVf yTJIiuUlNUIc/5Cw== From: "tip-bot2 for Brian Johannesmeyer" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] scripts/faddr2line: Reduce number of readelf calls to three Cc: Brian Johannesmeyer , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240415145538.1938745-2-bjohannesmeyer@gmail.com> References: <20240415145538.1938745-2-bjohannesmeyer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172043936631.2215.8839438073789084491.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the objtool/core branch of tip: Commit-ID: 39cf650d68289d41d484f4c29fea0124df2e09aa Gitweb: https://git.kernel.org/tip/39cf650d68289d41d484f4c29fea0124d= f2e09aa Author: Brian Johannesmeyer AuthorDate: Mon, 15 Apr 2024 16:55:32 +02:00 Committer: Josh Poimboeuf CommitterDate: Tue, 02 Jul 2024 23:38:36 -07:00 scripts/faddr2line: Reduce number of readelf calls to three Rather than calling readelf several times for each invocation of __faddr2line, call readelf only three times at the beginning, and save its result for future use. Signed-off-by: Brian Johannesmeyer Link: https://lore.kernel.org/r/20240415145538.1938745-2-bjohannesmeyer@gma= il.com Signed-off-by: Josh Poimboeuf --- scripts/faddr2line | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/faddr2line b/scripts/faddr2line index 587415a..bf394bf 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -87,7 +87,7 @@ command -v ${ADDR2LINE} >/dev/null 2>&1 || die "${ADDR2LI= NE} isn't installed" find_dir_prefix() { local objfile=3D$1 =20 - local start_kernel_addr=3D$(${READELF} --symbols --wide $objfile | sed 's= /\[.*\]//' | + local start_kernel_addr=3D$(echo "${ELF_SYMS}" | sed 's/\[.*\]//' | ${AWK} '$8 =3D=3D "start_kernel" {printf "0x%s", $2}') [[ -z $start_kernel_addr ]] && return =20 @@ -103,6 +103,14 @@ find_dir_prefix() { return 0 } =20 +run_readelf() { + local objfile=3D$1 + + ELF_FILEHEADER=3D$(${READELF} --file-header $objfile) + ELF_SECHEADERS=3D$(${READELF} --section-headers --wide $objfile) + ELF_SYMS=3D$(${READELF} --symbols --wide $objfile) +} + __faddr2line() { local objfile=3D$1 local func_addr=3D$2 @@ -125,7 +133,7 @@ __faddr2line() { =20 # vmlinux uses absolute addresses in the section table rather than # section offsets. - local file_type=3D$(${READELF} --file-header $objfile | + local file_type=3D$(echo "${ELF_FILEHEADER}" | ${AWK} '$1 =3D=3D "Type:" { print $2; exit }') if [[ $file_type =3D "EXEC" ]] || [[ $file_type =3D=3D "DYN" ]]; then is_vmlinux=3D1 @@ -143,8 +151,7 @@ __faddr2line() { local sec_name =20 # Get the section size: - sec_size=3D$(${READELF} --section-headers --wide $objfile | - sed 's/\[ /\[/' | + sec_size=3D$(echo "${ELF_SECHEADERS}" | sed 's/\[ /\[/' | ${AWK} -v sec=3D$sym_sec '$1 =3D=3D "[" sec "]" { print "0x" $6; exit }= ') =20 if [[ -z $sec_size ]]; then @@ -154,8 +161,7 @@ __faddr2line() { fi =20 # Get the section name: - sec_name=3D$(${READELF} --section-headers --wide $objfile | - sed 's/\[ /\[/' | + sec_name=3D$(echo "${ELF_SECHEADERS}" | sed 's/\[ /\[/' | ${AWK} -v sec=3D$sym_sec '$1 =3D=3D "[" sec "]" { print $2; exit }') =20 if [[ -z $sec_name ]]; then @@ -197,7 +203,7 @@ __faddr2line() { found=3D2 break fi - done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK= } -v sec=3D$sym_sec '$7 =3D=3D sec' | sort --key=3D2) + done < <(echo "${ELF_SYMS}" | sed 's/\[.*\]//' | ${AWK} -v sec=3D$sym_se= c '$7 =3D=3D sec' | sort --key=3D2) =20 if [[ $found =3D 0 ]]; then warn "can't find symbol: sym_name: $sym_name sym_sec: $sym_sec sym_addr= : $sym_addr sym_elf_size: $sym_elf_size" @@ -278,7 +284,7 @@ __faddr2line() { =20 DONE=3D1 =20 - done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK}= -v fn=3D$sym_name '$8 =3D=3D fn') + done < <(echo "${ELF_SYMS}" | sed 's/\[.*\]//' | ${AWK} -v fn=3D$sym_name= '$8 =3D=3D fn') } =20 [[ $# -lt 2 ]] && usage @@ -291,7 +297,9 @@ LIST=3D0 [[ ! -f $objfile ]] && die "can't find objfile $objfile" shift =20 -${READELF} --section-headers --wide $objfile | ${GREP} -q '\.debug_info' |= | die "CONFIG_DEBUG_INFO not enabled" +run_readelf $objfile + +echo "${ELF_SECHEADERS}" | ${GREP} -q '\.debug_info' || die "CONFIG_DEBUG_= INFO not enabled" =20 DIR_PREFIX=3Dsupercalifragilisticexpialidocious find_dir_prefix $objfile