From 34dafe9f39e61de970c36ed636daa58e1caa386c Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 16 Aug 2019 23:48:28 +0200 Subject: [PATCH] [gdb/testsuite] Fix compare-sections.exp with -fPIE/-pie When running gdb.base/compare-sections.exp with target board -fPIE/-pie, we get: ... FAIL: gdb.base/compare-sections.exp: after run to main: compare-sections -r ... The test expects the read-only sections to have the same contents as in the file: ... # Assume startup code doesn't change read-only sections. compare_sections "-r" ... but that's not the case for PIE executables. Fix this by allowing mismatched read-only sections for PIE executables. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-08-16 Tom de Vries * gdb.base/compare-sections.exp ("after run to main"): Allow mismatched read-only sections for PIE executables. --- gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/compare-sections.exp | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b3c815f29ad..edf7d17801f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-16 Tom de Vries + + * gdb.base/compare-sections.exp ("after run to main"): Allow + mismatched read-only sections for PIE executables. + 2019-08-16 Tom Tromey * lib/tuiterm.exp (_csi_Z): New proc. diff --git a/gdb/testsuite/gdb.base/compare-sections.exp b/gdb/testsuite/gdb.base/compare-sections.exp index 7dbae5b2c29..75667ee25cd 100644 --- a/gdb/testsuite/gdb.base/compare-sections.exp +++ b/gdb/testsuite/gdb.base/compare-sections.exp @@ -21,6 +21,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} { return -1 } +set is_pie [exec_is_pie $binfile] + # Run the compare-sections command along with any options as specified # by OPTIONS, and check that no mismatch is found. proc compare_sections { {options ""} } { @@ -87,8 +89,13 @@ with_test_prefix "after run to main" { gdb_test "compare-sections" \ "MIS-MATCHED.*warning.*One or more sections.*does not match.*loaded file" - # Assume startup code doesn't change read-only sections. - compare_sections "-r" + if { $is_pie == 1 } { + gdb_test "compare-sections -r" \ + "MIS-MATCHED.*warning.*One or more sections.*does not match.*loaded file" + } else { + # Assume startup code doesn't change read-only sections. + compare_sections "-r" + } } # Now test that "compare-sections -r" works as expected. Look for an -- 2.30.2