* [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie @ 2019-08-07 11:07 Tom de Vries 2019-08-07 14:18 ` Tom Tromey 0 siblings, 1 reply; 10+ messages in thread From: Tom de Vries @ 2019-08-07 11:07 UTC (permalink / raw) To: gdb-patches; +Cc: Tom Tromey, Joel Brobecker 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 <tdevries@suse.de> 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" ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-07 11:07 [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie Tom de Vries @ 2019-08-07 14:18 ` Tom Tromey 2019-08-07 15:27 ` Tom de Vries 0 siblings, 1 reply; 10+ messages in thread From: Tom Tromey @ 2019-08-07 14:18 UTC (permalink / raw) To: Tom de Vries; +Cc: gdb-patches, Tom Tromey, Joel Brobecker >>>>> "Tom" == Tom de Vries <tdevries@suse.de> 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-07 14:18 ` Tom Tromey @ 2019-08-07 15:27 ` Tom de Vries 2019-08-08 10:15 ` Tom de Vries 0 siblings, 1 reply; 10+ messages in thread From: Tom de Vries @ 2019-08-07 15:27 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker On 07-08-19 16:18, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries <tdevries@suse.de> 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 } ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-07 15:27 ` Tom de Vries @ 2019-08-08 10:15 ` Tom de Vries 2019-08-21 7:15 ` [PING][PATCH][gdb/testsuite] " Tom de Vries 0 siblings, 1 reply; 10+ messages in thread From: Tom de Vries @ 2019-08-08 10:15 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker [-- Attachment #1: Type: text/plain, Size: 1620 bytes --] On 07-08-19 17:27, Tom de Vries wrote: > On 07-08-19 16:18, Tom Tromey wrote: >>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> 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 [-- Attachment #2: 0001-gdb-testsuite-Fix-ada-tests-with-fPIE-pie.patch --] [-- Type: text/x-patch, Size: 1811 bytes --] [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 <tdevries@suse.de> 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 } ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PING][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-08 10:15 ` Tom de Vries @ 2019-08-21 7:15 ` Tom de Vries 2019-08-28 7:18 ` [PING^2][PATCH][gdb/testsuite] " Tom de Vries 2019-10-09 14:49 ` [PING][PATCH][gdb/testsuite] " Tom Tromey 0 siblings, 2 replies; 10+ messages in thread From: Tom de Vries @ 2019-08-21 7:15 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker 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 <tdevries@suse.de> 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 <tdevries@suse.de> > > 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 > } > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PING^2][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-21 7:15 ` [PING][PATCH][gdb/testsuite] " Tom de Vries @ 2019-08-28 7:18 ` Tom de Vries 2019-09-04 8:17 ` [PING^3][PATCH][gdb/testsuite] " Tom de Vries 2019-10-09 14:49 ` [PING][PATCH][gdb/testsuite] " Tom Tromey 1 sibling, 1 reply; 10+ messages in thread From: Tom de Vries @ 2019-08-28 7:18 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker 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 <tdevries@suse.de> 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 <tdevries@suse.de> >> >> 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 >> } >> >> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PING^3][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-28 7:18 ` [PING^2][PATCH][gdb/testsuite] " Tom de Vries @ 2019-09-04 8:17 ` Tom de Vries 2019-09-13 19:47 ` [PING^4][PATCH][gdb/testsuite] " Tom de Vries 0 siblings, 1 reply; 10+ messages in thread From: Tom de Vries @ 2019-09-04 8:17 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker 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 <tdevries@suse.de> 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 <tdevries@suse.de> >>> >>> 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 >>> } >>> >>> ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PING^4][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-09-04 8:17 ` [PING^3][PATCH][gdb/testsuite] " Tom de Vries @ 2019-09-13 19:47 ` Tom de Vries 0 siblings, 0 replies; 10+ messages in thread From: Tom de Vries @ 2019-09-13 19:47 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker 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 <tdevries@suse.de> 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 <tdevries@suse.de> >>>> >>>> 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 >>>> } >>>> >>>> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PING][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie 2019-08-21 7:15 ` [PING][PATCH][gdb/testsuite] " Tom de Vries 2019-08-28 7:18 ` [PING^2][PATCH][gdb/testsuite] " Tom de Vries @ 2019-10-09 14:49 ` Tom Tromey 2019-10-10 14:03 ` [gdb/testsuite] Compile ada with -lgnarl_pic and -lgnat_pic if required Tom de Vries 1 sibling, 1 reply; 10+ messages in thread From: Tom Tromey @ 2019-10-09 14:49 UTC (permalink / raw) To: Tom de Vries; +Cc: Tom Tromey, gdb-patches, Joel Brobecker >>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: >> 2019-08-08 Tom de Vries <tdevries@suse.de> >> >> PR testsuite/24888 >> * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to >> gnatlink. I'm sorry about the delay on this. I think this is ok. Tom ^ permalink raw reply [flat|nested] 10+ messages in thread
* [gdb/testsuite] Compile ada with -lgnarl_pic and -lgnat_pic if required 2019-10-09 14:49 ` [PING][PATCH][gdb/testsuite] " Tom Tromey @ 2019-10-10 14:03 ` Tom de Vries 0 siblings, 0 replies; 10+ messages in thread From: Tom de Vries @ 2019-10-10 14:03 UTC (permalink / raw) To: Tom Tromey; +Cc: gdb-patches, Joel Brobecker [-- Attachment #1: Type: text/plain, Size: 610 bytes --] [ Re: [PING][PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie ] On 09-10-2019 16:49, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes: > >>> 2019-08-08 Tom de Vries <tdevries@suse.de> >>> >>> PR testsuite/24888 >>> * lib/ada.exp (target_compile_ada_from_dir): Route -pie/-no-pie to >>> gnatlink. > > I'm sorry about the delay on this. Np, thanks for the review. > I think this is ok. Committed. And now that the approach has been deemed acceptable, here's a followup patch that makes gdb.ada work for me on openSUSE Leap 15.1 with -fPIE/-pie. OK for trunk? Thanks, - Tom [-- Attachment #2: 0001-gdb-testsuite-Compile-ada-with-lgnarl_pic-and-lgnat_pic-if-required.patch --] [-- Type: text/x-patch, Size: 5104 bytes --] [gdb/testsuite] Compile ada with -lgnarl_pic and -lgnat_pic if required On openSUSE Leap 15.1, when running the gdb.ada testsuite with target board unix/-fPIE/-pie, I get: ... nr of unexpected failures 158 ... The problem is that although due to commit abcf2cc85a3 "[gdb/testsuite] Fix ada tests with -fPIE/-pie" we try to compile say, hello.adb like so: ... $ gnatmake -fPIE -largs -pie -margs hello.adb ... this is not sufficient, because gnatlink is try to link in libgnat.a, which is not Position Independent Code. This issue has been filed as gcc PR ada/87936 - "gnatlink fails with -pie". Work around this issue by compiling with _pic versions of lgnarl and lgnat: ... $ gnatmake -fPIE -largs -pie -lgnarl_pic -lgnat_pic -margs hello.adb ... if that is required to make hello.adb compile. Using this patch, I get instead: ... nr of unexpected failures 2 ... where one failure also happens with native, and the other has been filed as gdb PR24890. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2019-10-10 Tom de Vries <tdevries@suse.de> PR testsuite/24888 * lib/ada.exp (gdb_simple_compile_ada): New proc. (calculating_ada_needs_libs_pic_suffix): New global, initialized to 0. (gdb_ada_needs_libs_pic_suffix): New caching proc. (target_compile_ada_from_dir): Append -largs -lgnarl_pic -lgnat_pic -margs to multilib_flags if required. (gdb_compile_ada_1): Factor out of ... (gdb_compile_ada): ... here. --- gdb/testsuite/lib/ada.exp | 86 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp index 45c41806a64..4bdb12051ec 100644 --- a/gdb/testsuite/lib/ada.exp +++ b/gdb/testsuite/lib/ada.exp @@ -17,6 +17,78 @@ # after having temporarily changed the current working directory to # BUILDDIR. +proc gdb_simple_compile_ada {name code {type object} {compile_flags {}} {object obj}} { + upvar $object obj + + switch -regexp -- $type { + "executable" { + set postfix "x" + } + "object" { + set postfix "o" + } + "preprocess" { + set postfix "i" + } + "assembly" { + set postfix "s" + } + } + set src [standard_temp_file $name.adb] + set obj [standard_temp_file $name-[pid].$postfix] + set compile_flags [concat $compile_flags {debug nowarnings quiet}] + + gdb_produce_source $src $code + + verbose "$name: compiling testfile $src" 2 + set lines [gdb_compile_ada_1 $src $obj $type $compile_flags] + + if ![string match "" $lines] then { + verbose "$name: compilation failed, returning 0" 2 + return 0 + } + return 1 +} + +global calculating_ada_needs_libs_pic_suffix +set calculating_ada_needs_libs_pic_suffix 0 +gdb_caching_proc gdb_ada_needs_libs_pic_suffix { + global calculating_ada_needs_libs_pic_suffix + if { $calculating_ada_needs_libs_pic_suffix } { + return 0 + } + set ada_hello { + with Ada.Text_IO; + + procedure Hello is + begin + Ada.Text_IO.Put_Line("Hello, world!"); + end Hello; + } + + set calculating_ada_needs_libs_pic_suffix 1 + set res \ + [gdb_simple_compile_ada hello $ada_hello executable] + if { $res == 1 } { + set calculating_ada_needs_libs_pic_suffix 0 + return 0 + } + set flags {} + lappend flags "additional_flags=-largs" + lappend flags "additional_flags=-lgnarl_pic" + lappend flags "additional_flags=-lgnat_pic" + lappend flags "additional_flags=-margs" + set res \ + [gdb_simple_compile_ada hello $ada_hello executable $flags] + if { $res == 1 } { + set calculating_ada_needs_libs_pic_suffix 0 + return 1 + } + + set calculating_ada_needs_libs_pic_suffix 0 + return 0 +} + proc target_compile_ada_from_dir {builddir source dest type options} { set saved_cwd [pwd] @@ -29,6 +101,10 @@ proc target_compile_ada_from_dir {builddir source dest type options} { # Pretend gnatmake supports -pie/-no-pie, route it to # linker. append multilib_flag " -largs $op -margs" + if { $op == "-pie" && [gdb_ada_needs_libs_pic_suffix]} { + # Work around PR gcc/87936 by using libgnat_pic + append multilib_flag " -largs -lgnarl_pic -lgnat_pic -margs" + } } else { append multilib_flag " $op" } @@ -54,7 +130,7 @@ proc target_compile_ada_from_dir {builddir source dest type options} { # Compile some Ada code. -proc gdb_compile_ada {source dest type options} { +proc gdb_compile_ada_1 {source dest type options} { set srcdir [file dirname $source] set gprdir [file dirname $srcdir] @@ -78,6 +154,14 @@ proc gdb_compile_ada {source dest type options} { # We therefore simply check whether the dest file has been created # or not. Unless not present, the build has succeeded. if [file exists $dest] { set result "" } + return $result +} + +# Compile some Ada code. + +proc gdb_compile_ada {source dest type options} { + set result [gdb_compile_ada_1 $source $dest $type $options] + gdb_compile_test $source $result return $result } ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-10-10 14:03 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-08-07 11:07 [PATCH][gdb/testsuite] Fix ada tests with -fPIE/-pie Tom de Vries 2019-08-07 14:18 ` Tom Tromey 2019-08-07 15:27 ` Tom de Vries 2019-08-08 10:15 ` Tom de Vries 2019-08-21 7:15 ` [PING][PATCH][gdb/testsuite] " Tom de Vries 2019-08-28 7:18 ` [PING^2][PATCH][gdb/testsuite] " Tom de Vries 2019-09-04 8:17 ` [PING^3][PATCH][gdb/testsuite] " Tom de Vries 2019-09-13 19:47 ` [PING^4][PATCH][gdb/testsuite] " Tom de Vries 2019-10-09 14:49 ` [PING][PATCH][gdb/testsuite] " Tom Tromey 2019-10-10 14:03 ` [gdb/testsuite] Compile ada with -lgnarl_pic and -lgnat_pic if required 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).