[PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
Hi,

When running the gdb testsuite with target board unix/-fPIE/-pie, the
resulting ada executables are not PIE executables, because gnatmake doesn't
recognize -pie, and consequently doesn't pass it to gnatlink.

Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
gdb_default_target_compile, and doing the same for -no-pie.

Tested on x86_64-linux.

OK for trunk?

Thanks,
- Tom

[gdb/testsuite] Fix ada tests with -fPIE/-pie

gdb/testsuite/ChangeLog:

2019-08-07  Tom de Vries  <[hidden email]>

        PR testsuite/24888
        * lib/future.exp (gdb_default_target_compile): Route -pie/-no-pie to
        gnatlink for ada.

---
 gdb/testsuite/lib/future.exp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
index 122e652858..e26e49af91 100644
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -530,7 +530,19 @@ proc gdb_default_target_compile {source destfile type options} {
     }
 
     if {[board_info $dest exists multilib_flags]} {
- append add_flags " [board_info $dest multilib_flags]"
+ if { $compiler_type == "ada" } {
+    foreach op [board_info $dest multilib_flags] {
+ if { $op == "-pie" || $op == "-no-pie" } {
+    # Pretend gnatmake supports -pie/-no-pie, route it to
+    # linker.
+    append add_flags " -largs $op -margs"
+ } else {
+    append add_flags " $op"
+ }
+    }
+ } else {
+    append add_flags " [board_info $dest multilib_flags]"
+ }
     }
 
     verbose "doing compile"
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom Tromey-2
>>>>> "Tom" == Tom de Vries <[hidden email]> writes:

Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
Tom> recognize -pie, and consequently doesn't pass it to gnatlink.

Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
Tom> gdb_default_target_compile, and doing the same for -no-pie.

I think this is a good idea overall.

However, is gdb_default_target_compile still used?  And if so, by what
path?  My understanding is that with a "new enough" dejagnu, it won't be
used -- so some users might still see the old behavior.

Basically gdb_default_target_compile is all a big monkeypatching hack
and it would be way better to have some kind of more principled approach
upstream.  I don't know what that would look like.  And of course to get
there we'd probably need even more monkeypatching.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
On 07-08-19 16:18, Tom Tromey wrote:

>>>>>> "Tom" == Tom de Vries <[hidden email]> writes:
>
> Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
> Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
> Tom> recognize -pie, and consequently doesn't pass it to gnatlink.
>
> Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
> Tom> gdb_default_target_compile, and doing the same for -no-pie.
>
> I think this is a good idea overall.
>
> However, is gdb_default_target_compile still used?  And if so, by what
> path?

I'm using dejagnu 1.6.1, and that one does not have find_go_linker. So,
use_gdb_compile is set to 1 and we get:
...
if {$use_gdb_compile} {
    catch {rename default_target_compile {}}
    rename gdb_default_target_compile default_target_compile
}
...

>  My understanding is that with a "new enough" dejagnu, it won't be
> used -- so some users might still see the old behavior.
>

AFAIU, yes. Hmm, that's not good.

> Basically gdb_default_target_compile is all a big monkeypatching hack

/me reads https://en.wikipedia.org/wiki/Monkey_patch

> and it would be way better to have some kind of more principled approach
> upstream.

Agreed.

> I don't know what that would look like.  And of course to get
> there we'd probably need even more monkeypatching.

The following uses the approach taken in lib/cell.exp.

Is this any better?

Thanks,
- Tom

diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
index 1345c747c5..6a3fd33240 100644
--- a/gdb/testsuite/lib/ada.exp
+++ b/gdb/testsuite/lib/ada.exp
@@ -19,11 +19,36 @@

 proc target_compile_ada_from_dir {builddir source dest type options} {
     set saved_cwd [pwd]
+
+    global board
+    set board [target_info name]
+    set save_multilib_flag [board_info $board multilib_flags]
+    set multilib_flag ""
+    foreach op $save_multilib_flag {
+       if { $op == "-pie" || $op == "-no-pie" } {
+           # Pretend gnatmake supports -pie/-no-pie, route it to
+           # linker.
+           append multilib_flag " -largs $op -margs"
+       } else {
+           append multilib_flag " $op"
+       }
+    }
+    if { $multilib_flag != "" } {
+       unset_board_info "multilib_flags"
+       set_board_info multilib_flags "$multilib_flag"
+    }
+
     catch {
         cd $builddir
         return [target_compile $source $dest $type $options]
     } result options
     cd $saved_cwd
+
+    if { $save_multilib_flag != "" } {
+       unset_board_info "multilib_flags"
+       set_board_info multilib_flags $save_multilib_flag
+    }
+
     return -options $options $result
 }

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
On 07-08-19 17:27, Tom de Vries wrote:

> On 07-08-19 16:18, Tom Tromey wrote:
>>>>>>> "Tom" == Tom de Vries <[hidden email]> writes:
>>
>> Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>> Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
>> Tom> recognize -pie, and consequently doesn't pass it to gnatlink.
>>
>> Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
>> Tom> gdb_default_target_compile, and doing the same for -no-pie.
>>
>> I think this is a good idea overall.
>>
>> However, is gdb_default_target_compile still used?  And if so, by what
>> path?
>
> I'm using dejagnu 1.6.1, and that one does not have find_go_linker. So,
> use_gdb_compile is set to 1 and we get:
> ...
> if {$use_gdb_compile} {
>     catch {rename default_target_compile {}}
>     rename gdb_default_target_compile default_target_compile
> }
> ...
>
>>  My understanding is that with a "new enough" dejagnu, it won't be
>> used -- so some users might still see the old behavior.
>>
>
> AFAIU, yes. Hmm, that's not good.
>
>> Basically gdb_default_target_compile is all a big monkeypatching hack
>
> /me reads https://en.wikipedia.org/wiki/Monkey_patch
>
>> and it would be way better to have some kind of more principled approach
>> upstream.
>
> Agreed.
>
>> I don't know what that would look like.  And of course to get
>> there we'd probably need even more monkeypatching.
>
> The following uses the approach taken in lib/cell.exp.
>
> Is this any better?
>
Updated rationale and ChangeLog entry.

OK for trunk?

Thanks,
- Tom


[gdb/testsuite] Fix ada tests with -fPIE/-pie

When running the gdb testsuite with target board unix/-fPIE/-pie, the
resulting ada executables are not PIE executables, because gnatmake doesn't
recognize -pie, and consequently doesn't pass it to gnatlink.

Fix this by replacing "-pie" with "-largs -pie -margs" in
target_compile_ada_from_dir, and doing the same for -no-pie.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-08-08  Tom de Vries  <[hidden email]>

        PR testsuite/24888
        * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to
        gnatlink.

---
 gdb/testsuite/lib/ada.exp | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
index 1345c747c5..6a3fd33240 100644
--- a/gdb/testsuite/lib/ada.exp
+++ b/gdb/testsuite/lib/ada.exp
@@ -19,11 +19,36 @@
 
 proc target_compile_ada_from_dir {builddir source dest type options} {
     set saved_cwd [pwd]
+
+    global board
+    set board [target_info name]
+    set save_multilib_flag [board_info $board multilib_flags]
+    set multilib_flag ""
+    foreach op $save_multilib_flag {
+ if { $op == "-pie" || $op == "-no-pie" } {
+    # Pretend gnatmake supports -pie/-no-pie, route it to
+    # linker.
+    append multilib_flag " -largs $op -margs"
+ } else {
+    append multilib_flag " $op"
+ }
+    }
+    if { $multilib_flag != "" } {
+ unset_board_info "multilib_flags"
+ set_board_info multilib_flags "$multilib_flag"
+    }
+
     catch {
         cd $builddir
         return [target_compile $source $dest $type $options]
     } result options
     cd $saved_cwd
+
+    if { $save_multilib_flag != "" } {
+ unset_board_info "multilib_flags"
+ set_board_info multilib_flags $save_multilib_flag
+    }
+
     return -options $options $result
 }
 
Reply | Threaded
Open this post in threaded view
|

[PING][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
On 08-08-19 12:15, Tom de Vries wrote:

> On 07-08-19 17:27, Tom de Vries wrote:
>> On 07-08-19 16:18, Tom Tromey wrote:
>>>>>>>> "Tom" == Tom de Vries <[hidden email]> writes:
>>> Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>>> Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
>>> Tom> recognize -pie, and consequently doesn't pass it to gnatlink.
>>>
>>> Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
>>> Tom> gdb_default_target_compile, and doing the same for -no-pie.
>>>
>>> I think this is a good idea overall.
>>>
>>> However, is gdb_default_target_compile still used?  And if so, by what
>>> path?
>> I'm using dejagnu 1.6.1, and that one does not have find_go_linker. So,
>> use_gdb_compile is set to 1 and we get:
>> ...
>> if {$use_gdb_compile} {
>>     catch {rename default_target_compile {}}
>>     rename gdb_default_target_compile default_target_compile
>> }
>> ...
>>
>>>  My understanding is that with a "new enough" dejagnu, it won't be
>>> used -- so some users might still see the old behavior.
>>>
>> AFAIU, yes. Hmm, that's not good.
>>
>>> Basically gdb_default_target_compile is all a big monkeypatching hack
>> /me reads https://en.wikipedia.org/wiki/Monkey_patch
>>
>>> and it would be way better to have some kind of more principled approach
>>> upstream.
>> Agreed.
>>
>>> I don't know what that would look like.  And of course to get
>>> there we'd probably need even more monkeypatching.
>> The following uses the approach taken in lib/cell.exp.
>>
>> Is this any better?
>>
> Updated rationale and ChangeLog entry.
>
> OK for trunk?
>

Ping.

Thanks,
- Tom

> 0001-gdb-testsuite-Fix-ada-tests-with-fPIE-pie.patch
>
> [gdb/testsuite] Fix ada tests with -fPIE/-pie
>
> When running the gdb testsuite with target board unix/-fPIE/-pie, the
> resulting ada executables are not PIE executables, because gnatmake doesn't
> recognize -pie, and consequently doesn't pass it to gnatlink.
>
> Fix this by replacing "-pie" with "-largs -pie -margs" in
> target_compile_ada_from_dir, and doing the same for -no-pie.
>
> Tested on x86_64-linux.
>
> gdb/testsuite/ChangeLog:
>
> 2019-08-08  Tom de Vries  <[hidden email]>
>
> PR testsuite/24888
> * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to
> gnatlink.
>
> ---
>  gdb/testsuite/lib/ada.exp | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
> index 1345c747c5..6a3fd33240 100644
> --- a/gdb/testsuite/lib/ada.exp
> +++ b/gdb/testsuite/lib/ada.exp
> @@ -19,11 +19,36 @@
>  
>  proc target_compile_ada_from_dir {builddir source dest type options} {
>      set saved_cwd [pwd]
> +
> +    global board
> +    set board [target_info name]
> +    set save_multilib_flag [board_info $board multilib_flags]
> +    set multilib_flag ""
> +    foreach op $save_multilib_flag {
> + if { $op == "-pie" || $op == "-no-pie" } {
> +    # Pretend gnatmake supports -pie/-no-pie, route it to
> +    # linker.
> +    append multilib_flag " -largs $op -margs"
> + } else {
> +    append multilib_flag " $op"
> + }
> +    }
> +    if { $multilib_flag != "" } {
> + unset_board_info "multilib_flags"
> + set_board_info multilib_flags "$multilib_flag"
> +    }
> +
>      catch {
>          cd $builddir
>          return [target_compile $source $dest $type $options]
>      } result options
>      cd $saved_cwd
> +
> +    if { $save_multilib_flag != "" } {
> + unset_board_info "multilib_flags"
> + set_board_info multilib_flags $save_multilib_flag
> +    }
> +
>      return -options $options $result
>  }
>  
>
Reply | Threaded
Open this post in threaded view
|

[PING^2][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
On 21-08-19 09:15, Tom de Vries wrote:

> On 08-08-19 12:15, Tom de Vries wrote:
>> On 07-08-19 17:27, Tom de Vries wrote:
>>> On 07-08-19 16:18, Tom Tromey wrote:
>>>>>>>>> "Tom" == Tom de Vries <[hidden email]> writes:
>>>> Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>>>> Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
>>>> Tom> recognize -pie, and consequently doesn't pass it to gnatlink.
>>>>
>>>> Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
>>>> Tom> gdb_default_target_compile, and doing the same for -no-pie.
>>>>
>>>> I think this is a good idea overall.
>>>>
>>>> However, is gdb_default_target_compile still used?  And if so, by what
>>>> path?
>>> I'm using dejagnu 1.6.1, and that one does not have find_go_linker. So,
>>> use_gdb_compile is set to 1 and we get:
>>> ...
>>> if {$use_gdb_compile} {
>>>     catch {rename default_target_compile {}}
>>>     rename gdb_default_target_compile default_target_compile
>>> }
>>> ...
>>>
>>>>  My understanding is that with a "new enough" dejagnu, it won't be
>>>> used -- so some users might still see the old behavior.
>>>>
>>> AFAIU, yes. Hmm, that's not good.
>>>
>>>> Basically gdb_default_target_compile is all a big monkeypatching hack
>>> /me reads https://en.wikipedia.org/wiki/Monkey_patch
>>>
>>>> and it would be way better to have some kind of more principled approach
>>>> upstream.
>>> Agreed.
>>>
>>>> I don't know what that would look like.  And of course to get
>>>> there we'd probably need even more monkeypatching.
>>> The following uses the approach taken in lib/cell.exp.
>>>
>>> Is this any better?
>>>
>> Updated rationale and ChangeLog entry.
>>
>> OK for trunk?
>>
>

Hi,

Ping^2.

Thanks,
- Tom

>> 0001-gdb-testsuite-Fix-ada-tests-with-fPIE-pie.patch
>>
>> [gdb/testsuite] Fix ada tests with -fPIE/-pie
>>
>> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>> resulting ada executables are not PIE executables, because gnatmake doesn't
>> recognize -pie, and consequently doesn't pass it to gnatlink.
>>
>> Fix this by replacing "-pie" with "-largs -pie -margs" in
>> target_compile_ada_from_dir, and doing the same for -no-pie.
>>
>> Tested on x86_64-linux.
>>
>> gdb/testsuite/ChangeLog:
>>
>> 2019-08-08  Tom de Vries  <[hidden email]>
>>
>> PR testsuite/24888
>> * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to
>> gnatlink.
>>
>> ---
>>  gdb/testsuite/lib/ada.exp | 25 +++++++++++++++++++++++++
>>  1 file changed, 25 insertions(+)
>>
>> diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
>> index 1345c747c5..6a3fd33240 100644
>> --- a/gdb/testsuite/lib/ada.exp
>> +++ b/gdb/testsuite/lib/ada.exp
>> @@ -19,11 +19,36 @@
>>  
>>  proc target_compile_ada_from_dir {builddir source dest type options} {
>>      set saved_cwd [pwd]
>> +
>> +    global board
>> +    set board [target_info name]
>> +    set save_multilib_flag [board_info $board multilib_flags]
>> +    set multilib_flag ""
>> +    foreach op $save_multilib_flag {
>> + if { $op == "-pie" || $op == "-no-pie" } {
>> +    # Pretend gnatmake supports -pie/-no-pie, route it to
>> +    # linker.
>> +    append multilib_flag " -largs $op -margs"
>> + } else {
>> +    append multilib_flag " $op"
>> + }
>> +    }
>> +    if { $multilib_flag != "" } {
>> + unset_board_info "multilib_flags"
>> + set_board_info multilib_flags "$multilib_flag"
>> +    }
>> +
>>      catch {
>>          cd $builddir
>>          return [target_compile $source $dest $type $options]
>>      } result options
>>      cd $saved_cwd
>> +
>> +    if { $save_multilib_flag != "" } {
>> + unset_board_info "multilib_flags"
>> + set_board_info multilib_flags $save_multilib_flag
>> +    }
>> +
>>      return -options $options $result
>>  }
>>  
>>
Reply | Threaded
Open this post in threaded view
|

[PING^3][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
On 28-08-19 09:18, Tom de Vries wrote:

> On 21-08-19 09:15, Tom de Vries wrote:
>> On 08-08-19 12:15, Tom de Vries wrote:
>>> On 07-08-19 17:27, Tom de Vries wrote:
>>>> On 07-08-19 16:18, Tom Tromey wrote:
>>>>>>>>>> "Tom" == Tom de Vries <[hidden email]> writes:
>>>>> Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>>>>> Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
>>>>> Tom> recognize -pie, and consequently doesn't pass it to gnatlink.
>>>>>
>>>>> Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
>>>>> Tom> gdb_default_target_compile, and doing the same for -no-pie.
>>>>>
>>>>> I think this is a good idea overall.
>>>>>
>>>>> However, is gdb_default_target_compile still used?  And if so, by what
>>>>> path?
>>>> I'm using dejagnu 1.6.1, and that one does not have find_go_linker. So,
>>>> use_gdb_compile is set to 1 and we get:
>>>> ...
>>>> if {$use_gdb_compile} {
>>>>     catch {rename default_target_compile {}}
>>>>     rename gdb_default_target_compile default_target_compile
>>>> }
>>>> ...
>>>>
>>>>>  My understanding is that with a "new enough" dejagnu, it won't be
>>>>> used -- so some users might still see the old behavior.
>>>>>
>>>> AFAIU, yes. Hmm, that's not good.
>>>>
>>>>> Basically gdb_default_target_compile is all a big monkeypatching hack
>>>> /me reads https://en.wikipedia.org/wiki/Monkey_patch
>>>>
>>>>> and it would be way better to have some kind of more principled approach
>>>>> upstream.
>>>> Agreed.
>>>>
>>>>> I don't know what that would look like.  And of course to get
>>>>> there we'd probably need even more monkeypatching.
>>>> The following uses the approach taken in lib/cell.exp.
>>>>
>>>> Is this any better?
>>>>
>>> Updated rationale and ChangeLog entry.
>>>
>>> OK for trunk?
>>>
>>
>

Hi,

Ping^3.

Thanks,
- Tom

>>> 0001-gdb-testsuite-Fix-ada-tests-with-fPIE-pie.patch
>>>
>>> [gdb/testsuite] Fix ada tests with -fPIE/-pie
>>>
>>> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>>> resulting ada executables are not PIE executables, because gnatmake doesn't
>>> recognize -pie, and consequently doesn't pass it to gnatlink.
>>>
>>> Fix this by replacing "-pie" with "-largs -pie -margs" in
>>> target_compile_ada_from_dir, and doing the same for -no-pie.
>>>
>>> Tested on x86_64-linux.
>>>
>>> gdb/testsuite/ChangeLog:
>>>
>>> 2019-08-08  Tom de Vries  <[hidden email]>
>>>
>>> PR testsuite/24888
>>> * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to
>>> gnatlink.
>>>
>>> ---
>>>  gdb/testsuite/lib/ada.exp | 25 +++++++++++++++++++++++++
>>>  1 file changed, 25 insertions(+)
>>>
>>> diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
>>> index 1345c747c5..6a3fd33240 100644
>>> --- a/gdb/testsuite/lib/ada.exp
>>> +++ b/gdb/testsuite/lib/ada.exp
>>> @@ -19,11 +19,36 @@
>>>  
>>>  proc target_compile_ada_from_dir {builddir source dest type options} {
>>>      set saved_cwd [pwd]
>>> +
>>> +    global board
>>> +    set board [target_info name]
>>> +    set save_multilib_flag [board_info $board multilib_flags]
>>> +    set multilib_flag ""
>>> +    foreach op $save_multilib_flag {
>>> + if { $op == "-pie" || $op == "-no-pie" } {
>>> +    # Pretend gnatmake supports -pie/-no-pie, route it to
>>> +    # linker.
>>> +    append multilib_flag " -largs $op -margs"
>>> + } else {
>>> +    append multilib_flag " $op"
>>> + }
>>> +    }
>>> +    if { $multilib_flag != "" } {
>>> + unset_board_info "multilib_flags"
>>> + set_board_info multilib_flags "$multilib_flag"
>>> +    }
>>> +
>>>      catch {
>>>          cd $builddir
>>>          return [target_compile $source $dest $type $options]
>>>      } result options
>>>      cd $saved_cwd
>>> +
>>> +    if { $save_multilib_flag != "" } {
>>> + unset_board_info "multilib_flags"
>>> + set_board_info multilib_flags $save_multilib_flag
>>> +    }
>>> +
>>>      return -options $options $result
>>>  }
>>>  
>>>
Reply | Threaded
Open this post in threaded view
|

[PING^4][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie

Tom de Vries
On 04-09-19 10:17, Tom de Vries wrote:

> On 28-08-19 09:18, Tom de Vries wrote:
>> On 21-08-19 09:15, Tom de Vries wrote:
>>> On 08-08-19 12:15, Tom de Vries wrote:
>>>> On 07-08-19 17:27, Tom de Vries wrote:
>>>>> On 07-08-19 16:18, Tom Tromey wrote:
>>>>>>>>>>> "Tom" == Tom de Vries <[hidden email]> writes:
>>>>>> Tom> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>>>>>> Tom> resulting ada executables are not PIE executables, because gnatmake doesn't
>>>>>> Tom> recognize -pie, and consequently doesn't pass it to gnatlink.
>>>>>>
>>>>>> Tom> Fix this by replacing "-pie" with "-largs -pie -margs" for ada test-cases in
>>>>>> Tom> gdb_default_target_compile, and doing the same for -no-pie.
>>>>>>
>>>>>> I think this is a good idea overall.
>>>>>>
>>>>>> However, is gdb_default_target_compile still used?  And if so, by what
>>>>>> path?
>>>>> I'm using dejagnu 1.6.1, and that one does not have find_go_linker. So,
>>>>> use_gdb_compile is set to 1 and we get:
>>>>> ...
>>>>> if {$use_gdb_compile} {
>>>>>     catch {rename default_target_compile {}}
>>>>>     rename gdb_default_target_compile default_target_compile
>>>>> }
>>>>> ...
>>>>>
>>>>>>  My understanding is that with a "new enough" dejagnu, it won't be
>>>>>> used -- so some users might still see the old behavior.
>>>>>>
>>>>> AFAIU, yes. Hmm, that's not good.
>>>>>
>>>>>> Basically gdb_default_target_compile is all a big monkeypatching hack
>>>>> /me reads https://en.wikipedia.org/wiki/Monkey_patch
>>>>>
>>>>>> and it would be way better to have some kind of more principled approach
>>>>>> upstream.
>>>>> Agreed.
>>>>>
>>>>>> I don't know what that would look like.  And of course to get
>>>>>> there we'd probably need even more monkeypatching.
>>>>> The following uses the approach taken in lib/cell.exp.
>>>>>
>>>>> Is this any better?
>>>>>
>>>> Updated rationale and ChangeLog entry.
>>>>
>>>> OK for trunk?
>>>>
>>>
>>
>
Hi,

Ping^4.

Thanks,
- Tom

>>>> 0001-gdb-testsuite-Fix-ada-tests-with-fPIE-pie.patch
>>>>
>>>> [gdb/testsuite] Fix ada tests with -fPIE/-pie
>>>>
>>>> When running the gdb testsuite with target board unix/-fPIE/-pie, the
>>>> resulting ada executables are not PIE executables, because gnatmake doesn't
>>>> recognize -pie, and consequently doesn't pass it to gnatlink.
>>>>
>>>> Fix this by replacing "-pie" with "-largs -pie -margs" in
>>>> target_compile_ada_from_dir, and doing the same for -no-pie.
>>>>
>>>> Tested on x86_64-linux.
>>>>
>>>> gdb/testsuite/ChangeLog:
>>>>
>>>> 2019-08-08  Tom de Vries  <[hidden email]>
>>>>
>>>> PR testsuite/24888
>>>> * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to
>>>> gnatlink.
>>>>
>>>> ---
>>>>  gdb/testsuite/lib/ada.exp | 25 +++++++++++++++++++++++++
>>>>  1 file changed, 25 insertions(+)
>>>>
>>>> diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
>>>> index 1345c747c5..6a3fd33240 100644
>>>> --- a/gdb/testsuite/lib/ada.exp
>>>> +++ b/gdb/testsuite/lib/ada.exp
>>>> @@ -19,11 +19,36 @@
>>>>  
>>>>  proc target_compile_ada_from_dir {builddir source dest type options} {
>>>>      set saved_cwd [pwd]
>>>> +
>>>> +    global board
>>>> +    set board [target_info name]
>>>> +    set save_multilib_flag [board_info $board multilib_flags]
>>>> +    set multilib_flag ""
>>>> +    foreach op $save_multilib_flag {
>>>> + if { $op == "-pie" || $op == "-no-pie" } {
>>>> +    # Pretend gnatmake supports -pie/-no-pie, route it to
>>>> +    # linker.
>>>> +    append multilib_flag " -largs $op -margs"
>>>> + } else {
>>>> +    append multilib_flag " $op"
>>>> + }
>>>> +    }
>>>> +    if { $multilib_flag != "" } {
>>>> + unset_board_info "multilib_flags"
>>>> + set_board_info multilib_flags "$multilib_flag"
>>>> +    }
>>>> +
>>>>      catch {
>>>>          cd $builddir
>>>>          return [target_compile $source $dest $type $options]
>>>>      } result options
>>>>      cd $saved_cwd
>>>> +
>>>> +    if { $save_multilib_flag != "" } {
>>>> + unset_board_info "multilib_flags"
>>>> + set_board_info multilib_flags $save_multilib_flag
>>>> +    }
>>>> +
>>>>      return -options $options $result
>>>>  }
>>>>  
>>>>