Skip to content

Commit b263284

Browse files
Panky-codesopsiff
authored andcommitted
scripts/faddr2line: Fix "Argument list too long" error
[ Upstream commit ff5c046 ] The run_readelf() function reads the entire output of readelf into a single shell variable. For large object files with extensive debug information, the size of this variable can exceed the system's command-line argument length limit. When this variable is subsequently passed to sed via `echo "${out}"`, it triggers an "Argument list too long" error, causing the script to fail. Fix this by redirecting the output of readelf to a temporary file instead of a variable. The sed commands are then modified to read from this file, avoiding the argument length limitation entirely. Signed-off-by: Pankaj Raghav <p.raghav@samsung.com> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit ec73412f61d3d36af5ae97df453871fef839628f) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent ae4b39a commit b263284

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

scripts/faddr2line

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,19 @@ find_dir_prefix() {
107107

108108
run_readelf() {
109109
local objfile=$1
110-
local out=$(${READELF} --file-header --section-headers --symbols --wide $objfile)
110+
local tmpfile
111+
tmpfile=$(mktemp)
112+
113+
${READELF} --file-header --section-headers --symbols --wide "$objfile" > "$tmpfile"
111114

112115
# This assumes that readelf first prints the file header, then the section headers, then the symbols.
113116
# Note: It seems that GNU readelf does not prefix section headers with the "There are X section headers"
114117
# line when multiple options are given, so let's also match with the "Section Headers:" line.
115-
ELF_FILEHEADER=$(echo "${out}" | sed -n '/There are [0-9]* section headers, starting at offset\|Section Headers:/q;p')
116-
ELF_SECHEADERS=$(echo "${out}" | sed -n '/There are [0-9]* section headers, starting at offset\|Section Headers:/,$p' | sed -n '/Symbol table .* contains [0-9]* entries:/q;p')
117-
ELF_SYMS=$(echo "${out}" | sed -n '/Symbol table .* contains [0-9]* entries:/,$p')
118+
ELF_FILEHEADER=$(sed -n '/There are [0-9]* section headers, starting at offset\|Section Headers:/q;p' "$tmpfile")
119+
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')
120+
ELF_SYMS=$(sed -n '/Symbol table .* contains [0-9]* entries:/,$p' "$tmpfile")
121+
122+
rm -f -- "$tmpfile"
118123
}
119124

120125
check_vmlinux() {

0 commit comments

Comments
 (0)