Re: [committed][gdb/testsuite] Fix exec_is_pie with gold linker

Pedro Alves
2020-05-25T14:54:14Z

On 5/25/20 11:02 AM, Tom de Vries wrote:
> Hi,
>
> 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.

Seems like a Gold bug? A comment in exec_is_pie explaining why we don't
do the more obvious thing would be helpful, IMO.

> @@ -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
> }
>

Thanks,
Pedro Alves