Fix gdb.arch/amd64-invalid-stack-*.exp failures

Message ID 1fb66984-cea8-6615-9b1a-5e5df57c924d@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi Aug. 27, 2018, 3:26 p.m. UTC
  On 2018-08-27 09:38 AM, Jan Vrany wrote:
> Commit 6d52907e226a (MI: Print frame architecture when printing frames
> on an MI channel) broke amd64-invalid-stack-middle.exp and
> amd64-invalid-stack-middle.exp because regexps were not updated.
> 
> Fix it by updating regexps to accommodate new "arch" field.

In the other thread, you mentioned not being able to run the -middle.exp test
because of:

  gdb compile failed, /usr/bin/ld: /home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/outputs/gdb.arch/amd64-invalid-stack-middle/amd64-invalid-stack-middle0.o: relocation R_X86_64_32 against
  `.rodata' can not be used when making a PIE object; recompile with -fPIC

That's probably because you have a "recent" toolchain that tries to build PIE executables
by default.  However, the assembly file has been generated without the position-independent
code switch (-fPIC), so it includes code that can't end up in a position-independent
executable.

I see 3 solutions:

1. Re-generate the file using the command in amd64-invalid-stack-middle.S, but with
   -fPIC.  That's a bit risky, because we need to make sure the new compiler emits
   code that would trigger the same bug the test has been written for.
2. Manually change amd64-invalid-stack-middle.S to remove things relying on .rodata.
   That may be a bit tedious and risky too.
3. Add the -no-pie linker switch to force generating position-dependent executables.

Solution #3 is easy and safe, so I would lean towards that, it's a one-liner:



---

With that, you should be able to run the test and confirm your patch works.
It does fix the failures when I run it locally, and the patch LGTM.

If you want to make a proper patch to add the -no-pie flag, you are welcome
to.

Thanks,

Simon
  

Comments

Jan Vrany Aug. 27, 2018, 9:05 p.m. UTC | #1
On Mon, 2018-08-27 at 11:26 -0400, Simon Marchi wrote:
> On 2018-08-27 09:38 AM, Jan Vrany wrote:
> > Commit 6d52907e226a (MI: Print frame architecture when printing frames
> > on an MI channel) broke amd64-invalid-stack-middle.exp and
> > amd64-invalid-stack-middle.exp because regexps were not updated.
> > 
> > Fix it by updating regexps to accommodate new "arch" field.
> 
> In the other thread, you mentioned not being able to run the -middle.exp test
> because of:
> 
>   gdb compile failed, /usr/bin/ld: /home/jv/Projects/gdb/users_jv_patches/gdb/testsuite/outputs/gdb.arch/amd64-invalid-stack-middle/amd64-invalid-stack-middle0.o: relocation R_X86_64_32 against
>   `.rodata' can not be used when making a PIE object; recompile with -fPIC
> 
> That's probably because you have a "recent" toolchain that tries to build PIE executables
> by default.  However, the assembly file has been generated without the position-independent
> code switch (-fPIC), so it includes code that can't end up in a position-independent
> executable.
> 
> I see 3 solutions:
> 
> 1. Re-generate the file using the command in amd64-invalid-stack-middle.S, but with
>    -fPIC.  That's a bit risky, because we need to make sure the new compiler emits
>    code that would trigger the same bug the test has been written for.
> 2. Manually change amd64-invalid-stack-middle.S to remove things relying on .rodata.
>    That may be a bit tedious and risky too.
> 3. Add the -no-pie linker switch to force generating position-dependent executables.
> 
> Solution #3 is easy and safe, so I would lean towards that, it's a one-liner:
> 
> diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
> index c00bfa10bd1b..b17eea59edc2 100644
> --- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
> +++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
> @@ -27,7 +27,7 @@
>  # run twice, and we restart gdb before testing each different command to
>  # ensure that nothing is being cached.
> 
> -set opts {}
> +set opts {ldflags=-no-pie}
>  standard_testfile .S
> 
>  if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
> 
> 
> ---
> 
> With that, you should be able to run the test and confirm your patch works.

Yes, with you patch amd64-invalid-stack-middle.exp passes here. Thanks!
 
> It does fix the failures when I run it locally, and the patch LGTM.
> 
> If you want to make a proper patch to add the -no-pie flag, you are welcome
> to.

I'll do tomorrow. 

Thanks, Jan

> 
> Thanks,
> 
> Simon
  

Patch

diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
index c00bfa10bd1b..b17eea59edc2 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
@@ -27,7 +27,7 @@ 
 # run twice, and we restart gdb before testing each different command to
 # ensure that nothing is being cached.

-set opts {}
+set opts {ldflags=-no-pie}
 standard_testfile .S

 if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {