linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le
@ 2022-09-27  7:52 Srikar Dronamraju
  2022-09-27 11:19 ` Thadeu Lima de Souza Cascardo
  2022-11-16  9:57 ` [tip: objtool/urgent] " tip-bot2 for Srikar Dronamraju
  0 siblings, 2 replies; 6+ messages in thread
From: Srikar Dronamraju @ 2022-09-27  7:52 UTC (permalink / raw)
  To: LKML
  Cc: Srikar Dronamraju, Naveen N. Rao, Jiri Olsa,
	Thadeu Lima de Souza Cascardo, Josh Poimboeuf, Peter Zijlstra,
	linuxppc-dev

Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
can cause scripts/faddr2line to fail on ppc64le machines on few
distributions, while working on other distributions. The failure can be
attributed to difference in readelf output on various distributions.

$ ./scripts/faddr2line vmlinux find_busiest_group+0x00
no match for find_busiest_group+0x00

Expected output was:
$ ./scripts/faddr2line vmlinux find_busiest_group+0x00
find_busiest_group+0x00/0x3d0:
find_busiest_group at kernel/sched/fair.c:9595

On ppc64le, readelf adds localentry tag before the symbol name on few
distributions and adds the localentry tag after the symbol name on few
other distributions. This problem has been discussed in the reference
URL given below. This problem can be overcome by filtering out
localentry tags in readelf output. Similar fixes are already present in
kernel by way of commits:

1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")

Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
Reference: https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
 scripts/faddr2line | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/faddr2line b/scripts/faddr2line
index 5514c23f45c2..0e73aca4f908 100755
--- a/scripts/faddr2line
+++ b/scripts/faddr2line
@@ -74,7 +74,8 @@ command -v ${ADDR2LINE} >/dev/null 2>&1 || die "${ADDR2LINE} isn't installed"
 find_dir_prefix() {
 	local objfile=$1
 
-	local start_kernel_addr=$(${READELF} --symbols --wide $objfile | ${AWK} '$8 == "start_kernel" {printf "0x%s", $2}')
+	local start_kernel_addr=$(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' |
+		${AWK} '$8 == "start_kernel" {printf "0x%s", $2}')
 	[[ -z $start_kernel_addr ]] && return
 
 	local file_line=$(${ADDR2LINE} -e $objfile $start_kernel_addr)
@@ -178,7 +179,7 @@ __faddr2line() {
 				found=2
 				break
 			fi
-		done < <(${READELF} --symbols --wide $objfile | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2)
+		done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2)
 
 		if [[ $found = 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"
@@ -259,7 +260,7 @@ __faddr2line() {
 
 		DONE=1
 
-	done < <(${READELF} --symbols --wide $objfile | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
+	done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
 }
 
 [[ $# -lt 2 ]] && usage

base-commit: bf682942cd26ce9cd5e87f73ae099b383041e782
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le
  2022-09-27  7:52 [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le Srikar Dronamraju
@ 2022-09-27 11:19 ` Thadeu Lima de Souza Cascardo
  2022-09-30 10:09   ` Naveen N. Rao
  2022-11-16  9:57 ` [tip: objtool/urgent] " tip-bot2 for Srikar Dronamraju
  1 sibling, 1 reply; 6+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2022-09-27 11:19 UTC (permalink / raw)
  To: Srikar Dronamraju
  Cc: LKML, Naveen N. Rao, Jiri Olsa, Josh Poimboeuf, Peter Zijlstra,
	linuxppc-dev

On Tue, Sep 27, 2022 at 01:22:11PM +0530, Srikar Dronamraju wrote:
> Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
> can cause scripts/faddr2line to fail on ppc64le machines on few
> distributions, while working on other distributions. The failure can be
> attributed to difference in readelf output on various distributions.
> 
> $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
> no match for find_busiest_group+0x00
> 
> Expected output was:
> $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
> find_busiest_group+0x00/0x3d0:
> find_busiest_group at kernel/sched/fair.c:9595
> 
> On ppc64le, readelf adds localentry tag before the symbol name on few
> distributions and adds the localentry tag after the symbol name on few
> other distributions. This problem has been discussed in the reference
> URL given below. This problem can be overcome by filtering out
> localentry tags in readelf output. Similar fixes are already present in
> kernel by way of commits:
> 
> 1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
> aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")
> 
> Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
> Reference: https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
> Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Reviewed-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

The other instances of readelf --wide on faddr2line use --section-headers and
should not required the same mangling.

Cascardo.

> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>
> Cc: LKML <linux-kernel@vger.kernel.org>
> Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
>  scripts/faddr2line | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/faddr2line b/scripts/faddr2line
> index 5514c23f45c2..0e73aca4f908 100755
> --- a/scripts/faddr2line
> +++ b/scripts/faddr2line
> @@ -74,7 +74,8 @@ command -v ${ADDR2LINE} >/dev/null 2>&1 || die "${ADDR2LINE} isn't installed"
>  find_dir_prefix() {
>  	local objfile=$1
>  
> -	local start_kernel_addr=$(${READELF} --symbols --wide $objfile | ${AWK} '$8 == "start_kernel" {printf "0x%s", $2}')
> +	local start_kernel_addr=$(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' |
> +		${AWK} '$8 == "start_kernel" {printf "0x%s", $2}')
>  	[[ -z $start_kernel_addr ]] && return
>  
>  	local file_line=$(${ADDR2LINE} -e $objfile $start_kernel_addr)
> @@ -178,7 +179,7 @@ __faddr2line() {
>  				found=2
>  				break
>  			fi
> -		done < <(${READELF} --symbols --wide $objfile | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2)
> +		done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2)
>  
>  		if [[ $found = 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"
> @@ -259,7 +260,7 @@ __faddr2line() {
>  
>  		DONE=1
>  
> -	done < <(${READELF} --symbols --wide $objfile | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
> +	done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
>  }
>  
>  [[ $# -lt 2 ]] && usage
> 
> base-commit: bf682942cd26ce9cd5e87f73ae099b383041e782
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le
  2022-09-27 11:19 ` Thadeu Lima de Souza Cascardo
@ 2022-09-30 10:09   ` Naveen N. Rao
  2022-11-14 12:21     ` Christophe Leroy
  0 siblings, 1 reply; 6+ messages in thread
From: Naveen N. Rao @ 2022-09-30 10:09 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo, Srikar Dronamraju
  Cc: Jiri Olsa, Josh Poimboeuf, LKML, linuxppc-dev, Peter Zijlstra

Thadeu Lima de Souza Cascardo wrote:
> On Tue, Sep 27, 2022 at 01:22:11PM +0530, Srikar Dronamraju wrote:
>> Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
>> can cause scripts/faddr2line to fail on ppc64le machines on few
>> distributions, while working on other distributions. The failure can be
>> attributed to difference in readelf output on various distributions.
>> 
>> $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
>> no match for find_busiest_group+0x00
>> 
>> Expected output was:
>> $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
>> find_busiest_group+0x00/0x3d0:
>> find_busiest_group at kernel/sched/fair.c:9595
>> 
>> On ppc64le, readelf adds localentry tag before the symbol name on few
>> distributions and adds the localentry tag after the symbol name on few
>> other distributions. This problem has been discussed in the reference
>> URL given below. This problem can be overcome by filtering out
>> localentry tags in readelf output. Similar fixes are already present in
>> kernel by way of commits:
>> 
>> 1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
>> aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")
>> 
>> Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
>> Reference: https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
>> Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
>> Cc: Jiri Olsa <jolsa@kernel.org>
>> Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> 
> Reviewed-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
> 
> The other instances of readelf --wide on faddr2line use --section-headers and
> should not required the same mangling.

There's one usage of readelf with --file-header in faddr2line which also 
doesn't need this. The extra information being printed is from st_other 
and is very specific to the symbol table.

Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>


- Naveen


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le
  2022-09-30 10:09   ` Naveen N. Rao
@ 2022-11-14 12:21     ` Christophe Leroy
  2022-11-14 19:30       ` Josh Poimboeuf
  0 siblings, 1 reply; 6+ messages in thread
From: Christophe Leroy @ 2022-11-14 12:21 UTC (permalink / raw)
  To: Josh Poimboeuf, Ingo Molnar
  Cc: Peter Zijlstra, Naveen N. Rao, linuxppc-dev, LKML, Jiri Olsa,
	Josh Poimboeuf, Srikar Dronamraju, Thadeu Lima de Souza Cascardo

Gentle ping ... Can this fix be merged ?

Thanks

Le 30/09/2022 à 12:09, Naveen N. Rao a écrit :
> Thadeu Lima de Souza Cascardo wrote:
>> On Tue, Sep 27, 2022 at 01:22:11PM +0530, Srikar Dronamraju wrote:
>>> Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text 
>>> section failures")
>>> can cause scripts/faddr2line to fail on ppc64le machines on few
>>> distributions, while working on other distributions. The failure can be
>>> attributed to difference in readelf output on various distributions.
>>>
>>> $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
>>> no match for find_busiest_group+0x00
>>>
>>> Expected output was:
>>> $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
>>> find_busiest_group+0x00/0x3d0:
>>> find_busiest_group at kernel/sched/fair.c:9595
>>>
>>> On ppc64le, readelf adds localentry tag before the symbol name on few
>>> distributions and adds the localentry tag after the symbol name on few
>>> other distributions. This problem has been discussed in the reference
>>> URL given below. This problem can be overcome by filtering out
>>> localentry tags in readelf output. Similar fixes are already present in
>>> kernel by way of commits:
>>>
>>> 1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
>>> aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")
>>>
>>> Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text 
>>> section failures")
>>> Reference: https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
>>> Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
>>> Cc: Jiri Olsa <jolsa@kernel.org>
>>> Cc: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
>>
>> Reviewed-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
>>
>> The other instances of readelf --wide on faddr2line use 
>> --section-headers and
>> should not required the same mangling.
> 
> There's one usage of readelf with --file-header in faddr2line which also 
> doesn't need this. The extra information being printed is from st_other 
> and is very specific to the symbol table.
> 
> Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> 
> 
> - Naveen
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le
  2022-11-14 12:21     ` Christophe Leroy
@ 2022-11-14 19:30       ` Josh Poimboeuf
  0 siblings, 0 replies; 6+ messages in thread
From: Josh Poimboeuf @ 2022-11-14 19:30 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Josh Poimboeuf, Ingo Molnar, Thadeu Lima de Souza Cascardo,
	Srikar Dronamraju, Peter Zijlstra, LKML, Jiri Olsa,
	Naveen N. Rao, linuxppc-dev

On Mon, Nov 14, 2022 at 12:21:33PM +0000, Christophe Leroy wrote:
> Gentle ping ... Can this fix be merged ?

Thanks for the reminder.  Looks good, I'll go ahead and take it.

-- 
Josh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: objtool/urgent] scripts/faddr2line: Fix regression in name resolution on ppc64le
  2022-09-27  7:52 [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le Srikar Dronamraju
  2022-09-27 11:19 ` Thadeu Lima de Souza Cascardo
@ 2022-11-16  9:57 ` tip-bot2 for Srikar Dronamraju
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Srikar Dronamraju @ 2022-11-16  9:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Srikar Dronamraju, Naveen N. Rao, Thadeu Lima de Souza Cascardo,
	Josh Poimboeuf, Peter Zijlstra, x86, linux-kernel

The following commit has been merged into the objtool/urgent branch of tip:

Commit-ID:     2d77de1581bb5b470486edaf17a7d70151131afd
Gitweb:        https://git.kernel.org/tip/2d77de1581bb5b470486edaf17a7d70151131afd
Author:        Srikar Dronamraju <srikar@linux.vnet.ibm.com>
AuthorDate:    Tue, 27 Sep 2022 13:22:11 +05:30
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 16 Nov 2022 10:42:10 +01:00

scripts/faddr2line: Fix regression in name resolution on ppc64le

Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section
failures") can cause faddr2line to fail on ppc64le on some
distributions, while it works fine on other distributions. The failure
can be attributed to differences in the readelf output.

  $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
  no match for find_busiest_group+0x00

On ppc64le, readelf adds the localentry tag before the symbol name on
some distributions, and adds the localentry tag after the symbol name on
other distributions. This problem has been discussed previously:

  https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/

This problem can be overcome by filtering out the localentry tags in the
readelf output. Similar fixes are already present in the kernel by way
of the following commits:

  1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
  aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")

[jpoimboe: rework commit log]

Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Reviewed-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Link: https://lore.kernel.org/r/20220927075211.897152-1-srikar@linux.vnet.ibm.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 scripts/faddr2line | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/faddr2line b/scripts/faddr2line
index 5514c23..0e73aca 100755
--- a/scripts/faddr2line
+++ b/scripts/faddr2line
@@ -74,7 +74,8 @@ command -v ${ADDR2LINE} >/dev/null 2>&1 || die "${ADDR2LINE} isn't installed"
 find_dir_prefix() {
 	local objfile=$1
 
-	local start_kernel_addr=$(${READELF} --symbols --wide $objfile | ${AWK} '$8 == "start_kernel" {printf "0x%s", $2}')
+	local start_kernel_addr=$(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' |
+		${AWK} '$8 == "start_kernel" {printf "0x%s", $2}')
 	[[ -z $start_kernel_addr ]] && return
 
 	local file_line=$(${ADDR2LINE} -e $objfile $start_kernel_addr)
@@ -178,7 +179,7 @@ __faddr2line() {
 				found=2
 				break
 			fi
-		done < <(${READELF} --symbols --wide $objfile | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2)
+		done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2)
 
 		if [[ $found = 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"
@@ -259,7 +260,7 @@ __faddr2line() {
 
 		DONE=1
 
-	done < <(${READELF} --symbols --wide $objfile | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
+	done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn')
 }
 
 [[ $# -lt 2 ]] && usage

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-16  9:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27  7:52 [PATCH] scripts/faddr2line: Fix regression in name resolution on ppc64le Srikar Dronamraju
2022-09-27 11:19 ` Thadeu Lima de Souza Cascardo
2022-09-30 10:09   ` Naveen N. Rao
2022-11-14 12:21     ` Christophe Leroy
2022-11-14 19:30       ` Josh Poimboeuf
2022-11-16  9:57 ` [tip: objtool/urgent] " tip-bot2 for Srikar Dronamraju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).