* [committed][gdb/testsuite] Fix exec_is_pie with gold linker
@ 2020-05-25 10:02 Tom de Vries
2020-05-25 14:54 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2020-05-25 10:02 UTC (permalink / raw)
To: gdb-patches
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.
Instead, use the "Type" field in the readelf -h output.
Tested on x86_64-linux.
Committed to trunk.
Thanks,
- Tom
[gdb/testsuite] Fix exec_is_pie with gold linker
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
PR testsuite/26031
* lib/gdb.exp (exec_is_pie): Test readelf -h output.
---
gdb/testsuite/lib/gdb.exp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f7d20bd94f..7177be941b 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
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [committed][gdb/testsuite] Fix exec_is_pie with gold linker
2020-05-25 10:02 [committed][gdb/testsuite] Fix exec_is_pie with gold linker Tom de Vries
@ 2020-05-25 14:54 ` Pedro Alves
2020-05-25 15:29 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2020-05-25 14:54 UTC (permalink / raw)
To: Tom de Vries, gdb-patches
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [committed][gdb/testsuite] Fix exec_is_pie with gold linker
2020-05-25 14:54 ` Pedro Alves
@ 2020-05-25 15:29 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2020-05-25 15:29 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 755 bytes --]
On 25-05-2020 16:54, Pedro Alves wrote:
> 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?
Yeah, Andreas Schwab had the same comment in bugzilla, so I filed
PR26039 - "gold doesn't add PIE flag" (
https://sourceware.org/bugzilla/show_bug.cgi?id=26039 ).
> A comment in exec_is_pie explaining why we don't
> do the more obvious thing would be helpful, IMO.
>
Fixed in attached patch, committed.
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-testsuite-Add-comment-in-exec_is_pie.patch --]
[-- Type: text/x-patch, Size: 856 bytes --]
[gdb/testsuite] Add comment in exec_is_pie
Add comment to exec_is_pie explaining why readelf -d output is not used.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (exec_is_pie): Add comment.
---
gdb/testsuite/lib/gdb.exp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7177be941b..8e22941f0b 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5509,6 +5509,9 @@ proc exec_is_pie { executable } {
return -1
}
set readelf_program [gdb_find_readelf]
+ # We're not testing readelf -d | grep "FLAGS_1.*Flags:.*PIE"
+ # because the PIE flag is not set by all versions of gold, see PR
+ # binutils/26039.
set res [catch {exec $readelf_program -h $executable} output]
if { $res != 0 } {
return -1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-25 15:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 10:02 [committed][gdb/testsuite] Fix exec_is_pie with gold linker Tom de Vries
2020-05-25 14:54 ` Pedro Alves
2020-05-25 15:29 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox