This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[ld, testsuite] Don't print to stdin for "readelf -w" to avoid buffer overflow
- From: Jiong Wang <jiong dot wang at foss dot arm dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 3 Feb 2017 11:15:14 +0000
- Subject: [ld, testsuite] Don't print to stdin for "readelf -w" to avoid buffer overflow
- Authentication-results: sourceware.org; auth=none
The following failures from ld-elf/compress.exp on arm-none-eabi are because all
of them are using "readelf -w" while "-w" output is really huge as it's
outputing all dwarf information (> 60000 lines for each of the following tests
on arm-none-eabi). The output size seems has overflowed dejagnu internal buffer
in remote.exp/local_exec, that further test actions are stopped.
All these tests actually relies on file diff, so I think it's not necessary to
print the output on stdin.
This patch fixed this.
No regression on arm-none-eabi cross/native check-ld and x86 native check-ld, ld.log
for x86 reduced from ~40000 lines to ~26000.
OK for master?
UNRESOLVED: Link with zlib compressed debug output
UNRESOLVED: Link with zlib compressed debug output
FAIL: Link with zlib compressed debug output
UNRESOLVED: Link with zlib-gnu compressed debug output
FAIL: Link with zlib-gnu compressed debug output
UNRESOLVED: Link with zlib-gabi compressed debug output
FAIL: Link with zlib-gabi compressed debug output
ld/
2017-02-03 Jiong Wang <jiong.wang@arm.com>
* testsuite/ld-elf/compress.exp: Don't print to stdin for all
"readelf -w".
diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp
index 5620f3c..3fb4bd7 100644
--- a/ld/testsuite/ld-elf/compress.exp
+++ b/ld/testsuite/ld-elf/compress.exp
@@ -171,7 +171,7 @@ if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rt] } then {
set test_name "Link with zlib compressed debug output"
set test normal
send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
-set got [remote_exec host "$READELF -w tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
+set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
unresolved "$test_name"
@@ -180,7 +180,7 @@ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
set test_name "Link with zlib compressed debug output"
set test zlibnormal
send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
-set got [remote_exec host "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\"" "" "/dev/null" "tmpdir/$test.out"]
+set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
unresolved "$test_name"
@@ -206,7 +206,7 @@ if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
set test_name "Link with zlib-gnu compressed debug output"
set test gnunormal
send_log "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out\n"
-set got [remote_exec host "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\"" "" "/dev/null" "tmpdir/$test.out"]
+set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test | sed -e \"s/.zdebug_/.debug_/\" > tmpdir/$test.out"]] "" "/dev/null"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
unresolved "$test_name"
@@ -232,7 +232,7 @@ if { [regexp_diff tmpdir/$test.out $srcdir/$subdir/$test.rS] } then {
set test gabinormal
set test_name "Link with zlib-gabi compressed debug output"
send_log "$READELF -w tmpdir/$test > tmpdir/$test.out\n"
-set got [remote_exec host "$READELF -w tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
+set got [remote_exec host [concat sh -c [list "$READELF -w tmpdir/$test > tmpdir/$test.out"]] "" "/dev/null"]
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
send_log "$got\n"
unresolved "$test_name"