From: Tom de Vries Date: Mon, 25 May 2020 10:01:52 +0000 (+0200) Subject: [gdb/testsuite] Fix exec_is_pie with gold linker X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=465e1b0f196faea1fc949863af023b762ef86188;p=binutils-gdb.git [gdb/testsuite] Fix exec_is_pie with gold linker When running test-case gdb.base/break-interp.exp with target board gold, we run into: ... gdb compile failed, pie failed to generate PIE executable ... The problem is that the proc exec_is_pie uses the PIE flag in the readelf -d output, which doesn't seem to be set by the gold linker. Instead, use the "Type" field in the readelf -h output. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-25 Tom de Vries PR testsuite/26031 * lib/gdb.exp (exec_is_pie): Test readelf -h output. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 93d5e705808..d372b503909 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-05-25 Tom de Vries + + PR testsuite/26031 + * lib/gdb.exp (exec_is_pie): Test readelf -h output. + 2020-05-25 Tom de Vries * boards/gold.exp: New file. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index f7d20bd94ff..7177be941b4 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5509,11 +5509,12 @@ proc exec_is_pie { executable } { return -1 } set readelf_program [gdb_find_readelf] - set res [catch {exec $readelf_program -d $executable} output] + set res [catch {exec $readelf_program -h $executable} output] if { $res != 0 } { return -1 } - set res [regexp -line {\(FLAGS_1\).*Flags:.* PIE($| )} $output] + set res [regexp -line {^[ \t]*Type:[ \t]*DYN \(Shared object file\)$} \ + $output] if { $res == 1 } { return 1 }