Skip to contentSkip to conversation

faddr2line fixes

PATCH Applied Josh Poimboeuf 3 participants 6 messages Jul 21, 2022 – Aug 2, 2022 FADDR2LINE

lore
Share & tools
lore

Josh Poimboeuf

author maintainer
#0 lore raw

cover faddr2line fixes

Fix faddr2line on arm64, and improve the error message for missing CONFIG_DEBUG_INFO.

Josh Poimboeuf (2):
scripts/faddr2line: Fix vmlinux detection on arm64 scripts/faddr2line: Add CONFIG_DEBUG_INFO check

 scripts/faddr2line | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.36.1
author maintainer
#1 lore raw

PATCH 1/2 scripts/faddr2line: Fix vmlinux detection on arm64

Since commit dcea997beed6 ("faddr2line: Fix overlapping text section failures, the sequel"), faddr2line is completely broken on arm64.

For some reason, on arm64, the vmlinux ELF object file type is ET_DYN rather than ET_EXEC. Check for both when determining whether the object is vmlinux.

Modules and vmlinux.o have type ET_REL on all arches.

Fixes dcea997beed6 ("faddr2line: Fix overlapping text section failures, the sequel")
---
 scripts/faddr2line | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/faddr2line +3 -1
index 94ed98dd899f..57099687e5e1 100755
@@ -112,7 +112,9 @@ __faddr2line() {
 	# section offsets.
 	local file_type=$(${READELF} --file-header $objfile |
 		${AWK} '$1 == "Type:" { print $2; exit }')
-	[[ $file_type = "EXEC" ]] && is_vmlinux=1
+	if [[ $file_type = "EXEC" ]] || [[ $file_type == "DYN" ]]; then
+		is_vmlinux=1
+	fi
 
 	# Go through each of the object's symbols which match the func name.
 	# In rare cases there might be duplicates, in which case we print all
Signature · 1 line
2.36.1
merge bot Applied
#2 lore raw

[tip: perf/urgent] scripts/faddr2line: Fix vmlinux detection on arm64

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

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

Commit-ID:     b6a5068854cfe372da7dee3224dcf023ed5b00cb
Gitweb:        https://git.kernel.org/tip/b6a5068854cfe372da7dee3224dcf023ed5b00cb
Author:        Josh Poimboeuf <[email protected]>
AuthorDate:    Thu, 21 Jul 2022 11:01:23 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 02 Aug 2022 22:08:16 +02:00

scripts/faddr2line: Fix vmlinux detection on arm64

Since commit dcea997beed6 ("faddr2line: Fix overlapping text section failures, the sequel"), faddr2line is completely broken on arm64.

For some reason, on arm64, the vmlinux ELF object file type is ET_DYN rather than ET_EXEC. Check for both when determining whether the object is vmlinux.

Modules and vmlinux.o have type ET_REL on all arches.

---
 scripts/faddr2line | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/faddr2line +3 -1
index 94ed98d..5709968 100755
@@ -112,7 +112,9 @@ __faddr2line() {
 	# section offsets.
 	local file_type=$(${READELF} --file-header $objfile |
 		${AWK} '$1 == "Type:" { print $2; exit }')
-	[[ $file_type = "EXEC" ]] && is_vmlinux=1
+	if [[ $file_type = "EXEC" ]] || [[ $file_type == "DYN" ]]; then
+		is_vmlinux=1
+	fi
 
 	# Go through each of the object's symbols which match the func name.
 	# In rare cases there might be duplicates, in which case we print all
author maintainer
#3 lore raw

PATCH 2/2 scripts/faddr2line: Add CONFIG_DEBUG_INFO check

In reply to Josh Poimboeuf

Otherwise without DWARF it spits out gibberish and gives no indication of what the problem is.

---
 scripts/faddr2line | 3 +++
 1 file changed, 3 insertions(+)
scripts/faddr2line +3 -0
index 57099687e5e1..5514c23f45c2 100755
@@ -61,6 +61,7 @@ die() {
 READELF="${CROSS_COMPILE:-}readelf"
 ADDR2LINE="${CROSS_COMPILE:-}addr2line"
 AWK="awk"
+GREP="grep"
 
 command -v ${AWK} >/dev/null 2>&1 || die "${AWK} isn't installed"
 command -v ${READELF} >/dev/null 2>&1 || die "${READELF} isn't installed"
@@ -271,6 +272,8 @@ LIST=0
 [[ ! -f $objfile ]] && die "can't find objfile $objfile"
 shift
 
+${READELF} --section-headers --wide $objfile | ${GREP} -q '\.debug_info' || die "CONFIG_DEBUG_INFO not enabled"
+
 DIR_PREFIX=supercalifragilisticexpialidocious
 find_dir_prefix $objfile
 
Signature · 1 line
2.36.1
Tested-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] scripts/faddr2line: Add CONFIG_DEBUG_INFO check

Quoted 5 lines · Josh Poimboeuf

Otherwise without DWARF it spits out gibberish and gives no indication of what the problem is.

Seems to work fine, thanks

Quoted 25 lines
---
  scripts/faddr2line | 3 +++
  1 file changed, 3 insertions(+)
scripts/faddr2line +3 -0
index 57099687e5e1..5514c23f45c2 100755
@@ -61,6 +61,7 @@ die() {
  READELF="${CROSS_COMPILE:-}readelf"
  ADDR2LINE="${CROSS_COMPILE:-}addr2line"
  AWK="awk"
+GREP="grep"
 
  command -v ${AWK} >/dev/null 2>&1 || die "${AWK} isn't installed"
  command -v ${READELF} >/dev/null 2>&1 || die "${READELF} isn't installed"
@@ -271,6 +272,8 @@ LIST=0
  [[ ! -f $objfile ]] && die "can't find objfile $objfile"
  shift
 
+${READELF} --section-headers --wide $objfile | ${GREP} -q '\.debug_info' || die "CONFIG_DEBUG_INFO not enabled"
+
  DIR_PREFIX=supercalifragilisticexpialidocious
  find_dir_prefix $objfile
 
merge bot Applied
#5 lore raw

[tip: perf/urgent] scripts/faddr2line: Add CONFIG_DEBUG_INFO check

In reply to Josh Poimboeuf
The following commit has been merged into the perf/urgent branch of tip:

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

Commit-ID:     a41a2e2e34a907bd8979a53c58f44287630616e8
Gitweb:        https://git.kernel.org/tip/a41a2e2e34a907bd8979a53c58f44287630616e8
Author:        Josh Poimboeuf <[email protected]>
AuthorDate:    Thu, 21 Jul 2022 11:01:24 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 02 Aug 2022 22:08:17 +02:00

scripts/faddr2line: Add CONFIG_DEBUG_INFO check

Otherwise without DWARF it spits out gibberish and gives no indication of what the problem is.

---
 scripts/faddr2line | 3 +++
 1 file changed, 3 insertions(+)
scripts/faddr2line +3 -0
index 5709968..5514c23 100755
@@ -61,6 +61,7 @@ die() {
 READELF="${CROSS_COMPILE:-}readelf"
 ADDR2LINE="${CROSS_COMPILE:-}addr2line"
 AWK="awk"
+GREP="grep"
 
 command -v ${AWK} >/dev/null 2>&1 || die "${AWK} isn't installed"
 command -v ${READELF} >/dev/null 2>&1 || die "${READELF} isn't installed"
@@ -271,6 +272,8 @@ LIST=0
 [[ ! -f $objfile ]] && die "can't find objfile $objfile"
 shift
 
+${READELF} --section-headers --wide $objfile | ${GREP} -q '\.debug_info' || die "CONFIG_DEBUG_INFO not enabled"
+
 DIR_PREFIX=supercalifragilisticexpialidocious
 find_dir_prefix $objfile