mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Revert "scripts/faddr2line: Combine three readelf calls into one"
@ 2026-09-05  1:24 Srikar Dronamraju
  0 siblings, 0 replies; only message in thread
From: Srikar Dronamraju @ 2026-09-05  1:24 UTC (permalink / raw)
  To: Josh Poimboeuf, Brian Johannesmeyer
  Cc: Madhavan Srinivasan, linuxppc-dev, Srikar Dronamraju, linux-kernel

This reverts commit b8d9d9496c1e ("scripts/faddr2line: Combine three
readelf calls into one")

scripts/faddr2line stopped working on PowerPc systems with this commit.

Output  of scripts/faddr2line on latest kernel sources
$ scripts/faddr2line ./vmlinux need_active_balance+0x1d4/0x21c
$
Output of scripts/faddr2line with revert
$ scripts/faddr2line ./vmlinux need_active_balance+0x1d4/0x21c
need_active_balance+0x1d4/0x21c:
imbalanced_active_balance at kernel/sched/fair.c:12047
(inlined by) need_active_balance at kernel/sched/fair.c:12061
$

readelf on Powerpc when passed with --file-header --section-headers
--symbol --wide option doesnt show the line
 "There are 62 section headers, starting at offset 0x16f1a850:"

Hence faddr2line parsing gets broken.

It could be a bug in Powerpc readelf that this line doesnt get printed.
However since its breaking with existing readelf, its better to be
reverted.

With the revert, we end up calling readelf three times but this should
still be fine since calling faddr2line is a debug tool.

Fixes: b8d9d9496c1e ("scripts/faddr2line: Combine three readelf calls into one")
Signed-off-by: Srikar Dronamraju <srikar@linux.ibm.com>
---
 scripts/faddr2line | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/scripts/faddr2line b/scripts/faddr2line
index 622875396bcf..bf2098beefbe 100755
--- a/scripts/faddr2line
+++ b/scripts/faddr2line
@@ -111,19 +111,10 @@ find_dir_prefix() {
 
 run_readelf() {
 	local objfile=$1
-	local tmpfile
-	tmpfile=$(mktemp)
 
-	${READELF} --file-header --section-headers --symbols --wide "$objfile" > "$tmpfile"
-
-	# This assumes that readelf first prints the file header, then the section headers, then the symbols.
-	# Note: It seems that GNU readelf does not prefix section headers with the "There are X section headers"
-	# line when multiple options are given, so let's also match with the "Section Headers:" line.
-	ELF_FILEHEADER=$(sed -n '/There are [0-9]* section headers, starting at offset\|Section Headers:/q;p' "$tmpfile")
-	ELF_SECHEADERS=$(sed -n '/There are [0-9]* section headers, starting at offset\|Section Headers:/,$p' "$tmpfile" | sed -n '/Symbol table .* contains [0-9]* entries:/q;p')
-	ELF_SYMS=$(sed -n '/Symbol table .* contains [0-9]* entries:/,$p' "$tmpfile")
-
-	rm -f -- "$tmpfile"
+	ELF_FILEHEADER=$(${READELF} --file-header $objfile)
+	ELF_SECHEADERS=$(${READELF} --section-headers --wide $objfile)
+	ELF_SYMS=$(${READELF} --symbols --wide $objfile)
 }
 
 check_vmlinux() {
-- 
2.52.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-05  1:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-05  1:24 [PATCH] Revert "scripts/faddr2line: Combine three readelf calls into one" Srikar Dronamraju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®