@@ -115,6 +115,17 @@ run_readelf() {
115
115
ELF_SYMS=$( echo " ${out} " | sed -n ' /Symbol table .* contains [0-9]* entries:/,$p' )
116
116
}
117
117
118
+ check_vmlinux () {
119
+ # vmlinux uses absolute addresses in the section table rather than
120
+ # section offsets.
121
+ IS_VMLINUX=0
122
+ local file_type=$( echo " ${ELF_FILEHEADER} " |
123
+ ${AWK} ' $1 == "Type:" { print $2; exit }' )
124
+ if [[ $file_type = " EXEC" ]] || [[ $file_type == " DYN" ]]; then
125
+ IS_VMLINUX=1
126
+ fi
127
+ }
128
+
118
129
__faddr2line () {
119
130
local objfile=$1
120
131
local func_addr=$2
@@ -125,8 +136,6 @@ __faddr2line() {
125
136
local func_offset=${func_addr#* +}
126
137
func_offset=${func_offset%/* }
127
138
local user_size=
128
- local file_type
129
- local is_vmlinux=0
130
139
[[ $func_addr =~ " /" ]] && user_size=${func_addr#*/ }
131
140
132
141
if [[ -z $sym_name ]] || [[ -z $func_offset ]] || [[ $sym_name = $func_addr ]]; then
@@ -135,14 +144,6 @@ __faddr2line() {
135
144
return
136
145
fi
137
146
138
- # vmlinux uses absolute addresses in the section table rather than
139
- # section offsets.
140
- local file_type=$( echo " ${ELF_FILEHEADER} " |
141
- ${AWK} ' $1 == "Type:" { print $2; exit }' )
142
- if [[ $file_type = " EXEC" ]] || [[ $file_type == " DYN" ]]; then
143
- is_vmlinux=1
144
- fi
145
-
146
147
# Go through each of the object's symbols which match the func name.
147
148
# In rare cases there might be duplicates, in which case we print all
148
149
# matches.
@@ -260,7 +261,7 @@ __faddr2line() {
260
261
# Pass section address to addr2line and strip absolute paths
261
262
# from the output:
262
263
local args=" --functions --pretty-print --inlines --exe=$objfile "
263
- [[ $is_vmlinux = 0 ]] && args=" $args --section=$sec_name "
264
+ [[ $IS_VMLINUX = 0 ]] && args=" $args --section=$sec_name "
264
265
local output=$( ${ADDR2LINE} $args $addr | sed " s; $dir_prefix \(\./\)*; ;" )
265
266
[[ -z $output ]] && continue
266
267
@@ -305,6 +306,8 @@ run_readelf $objfile
305
306
306
307
echo " ${ELF_SECHEADERS} " | ${GREP} -q ' \.debug_info' || die " CONFIG_DEBUG_INFO not enabled"
307
308
309
+ check_vmlinux
310
+
308
311
DIR_PREFIX=supercalifragilisticexpialidocious
309
312
find_dir_prefix $objfile
310
313
0 commit comments