public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp
@ 2023-07-13 14:15 Tom de Vries
  2023-07-24 16:21 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2023-07-13 14:15 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

As reported in PR testsuite/30633, when running test-case
gdb.dwarf2/typeddwarf.exp with target board native-gdbserver on Ubuntu
22.04.2, we run into:
...
(gdb) continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000000001 in ?? ()^M
(gdb) FAIL: gdb.dwarf2/typeddwarf.exp: runto: run to main
...

We run into the FAIL as follows:
- due to using gdbserver, we attach at the point of the first instruction, in
  _start
- we then set a breakpoint at main
- the test-case is a .s file, that has main renamed to _start in the assembly,
  but not in the debuginfo
- setting a breakpoint at main sets the breakpoint at the same instruction
  we're currently stopped at
- continue doesn't hit the breakpoint, and we return out of _start, which
  causes a sigsegv

Note that this is for the amd64 case (using gdb.dwarf2/typeddwarf-amd64.S).
For the i386 case (using gdb.dwarf2/typeddwarf.S), setting a breakpoint in
main sets it one insn after function entry, and consequently the problem does
not occur.

The FAIL is a regression since commit 90cce6c0551 ("[gdb/testsuite] Add nopie
in a few test-cases").

Without nopie the executable is PIE, with nopie it's static instead.

In the PIE case, we attach at the point of _start in the dynamic linker, and
consequently we do not skip the breakpoint in main, and also don't run into
the FAIL.

Fix this by:
- removing the -nostdlib setting, and
- renaming _start to main in both .S files.

The change to use -nostdlib and rename main to _start was originally added
in commit 6edba76fe8b (submitted here:
https://sourceware.org/pipermail/gdb-patches/2011-May/082657.html ) , I assume
to fix the problem now fixed by using nopie.

Tested on x86_64-linux.

Reported-By: Simon Marchi <simon.marchi@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30633
---
 gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S | 8 ++++----
 gdb/testsuite/gdb.dwarf2/typeddwarf.S       | 8 ++++----
 gdb/testsuite/gdb.dwarf2/typeddwarf.exp     | 1 -
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S b/gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S
index eecad231aa1..ac84f4c593f 100644
--- a/gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S
+++ b/gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S
@@ -116,9 +116,9 @@ f4:
 	.cfi_endproc
 .LFE3:
 	.size	f4, .-f4
-	.globl	_start
-	.type	_start, @function
-_start:
+	.globl	main
+	.type	main, @function
+main:
 .LFB4:
 	.loc 1 87 0
 	.cfi_startproc
@@ -170,7 +170,7 @@ _start:
 	ret
 	.cfi_endproc
 .LFE4:
-	.size	_start, .-_start
+	.size	main, .-main
 	.comm	vv,4,4
 	.section	.rodata.cst8,"aM",@progbits,8
 	.align 8
diff --git a/gdb/testsuite/gdb.dwarf2/typeddwarf.S b/gdb/testsuite/gdb.dwarf2/typeddwarf.S
index f9e8e5c1c1e..654372c5dc0 100644
--- a/gdb/testsuite/gdb.dwarf2/typeddwarf.S
+++ b/gdb/testsuite/gdb.dwarf2/typeddwarf.S
@@ -212,9 +212,9 @@ f4:
 	.size	f4, .-f4
 	.section	.text.startup,"ax",@progbits
 	.p2align 4,,15
-	.globl	_start
-	.type	_start, @function
-_start:
+	.globl	main
+	.type	main, @function
+main:
 .LFB4:
 	# typeddwarf.c:87
 .LM37:
@@ -314,7 +314,7 @@ _start:
 # SUCC: EXIT [100.0%] 
 	ret
 .LFE4:
-	.size	_start, .-_start
+	.size	main, .-main
 	.comm	vv,4,4
 	.section	.rodata.cst4,"aM",@progbits,4
 	.align 4
diff --git a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
index 1e46cab03ef..3f96e9687c6 100644
--- a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
+++ b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
@@ -31,7 +31,6 @@ if { [is_x86_like_target] } {
 
 set opts {}
 lappend opts nodebug
-lappend opts additional_flags=-nostdlib
 lappend opts nopie
 
 if { [prepare_for_testing "failed to prepare" "${test}" ${sfile} $opts] } {

base-commit: 22e90ac5af46c01ee4972cf04e835266862bbb35
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp
  2023-07-13 14:15 [PATCH] [gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp Tom de Vries
@ 2023-07-24 16:21 ` Simon Marchi
  2023-07-26 11:47   ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2023-07-24 16:21 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches; +Cc: Tom Tromey

On 7/13/23 10:15, Tom de Vries via Gdb-patches wrote:
> As reported in PR testsuite/30633, when running test-case
> gdb.dwarf2/typeddwarf.exp with target board native-gdbserver on Ubuntu
> 22.04.2, we run into:
> ...
> (gdb) continue^M
> Continuing.^M
> ^M
> Program received signal SIGSEGV, Segmentation fault.^M
> 0x0000000000000001 in ?? ()^M
> (gdb) FAIL: gdb.dwarf2/typeddwarf.exp: runto: run to main
> ...
> 
> We run into the FAIL as follows:
> - due to using gdbserver, we attach at the point of the first instruction, in
>   _start
> - we then set a breakpoint at main
> - the test-case is a .s file, that has main renamed to _start in the assembly,
>   but not in the debuginfo
> - setting a breakpoint at main sets the breakpoint at the same instruction
>   we're currently stopped at
> - continue doesn't hit the breakpoint, and we return out of _start, which
>   causes a sigsegv
> 
> Note that this is for the amd64 case (using gdb.dwarf2/typeddwarf-amd64.S).
> For the i386 case (using gdb.dwarf2/typeddwarf.S), setting a breakpoint in
> main sets it one insn after function entry, and consequently the problem does
> not occur.
> 
> The FAIL is a regression since commit 90cce6c0551 ("[gdb/testsuite] Add nopie
> in a few test-cases").
> 
> Without nopie the executable is PIE, with nopie it's static instead.
> 
> In the PIE case, we attach at the point of _start in the dynamic linker, and
> consequently we do not skip the breakpoint in main, and also don't run into
> the FAIL.
> 
> Fix this by:
> - removing the -nostdlib setting, and
> - renaming _start to main in both .S files.
> 
> The change to use -nostdlib and rename main to _start was originally added
> in commit 6edba76fe8b (submitted here:
> https://sourceware.org/pipermail/gdb-patches/2011-May/082657.html ) , I assume
> to fix the problem now fixed by using nopie.
> 
> Tested on x86_64-linux.
> 
> Reported-By: Simon Marchi <simon.marchi@efficios.com>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30633

I have not dug in the code at all, but I confirm that the patch fixes
the test.  Therefore:

Tested-By: Simon Marchi <simon.marchi@efficios.com>

Thanks,

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp
  2023-07-24 16:21 ` Simon Marchi
@ 2023-07-26 11:47   ` Tom de Vries
  0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-07-26 11:47 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches; +Cc: Tom Tromey

On 7/24/23 18:21, Simon Marchi wrote:
> On 7/13/23 10:15, Tom de Vries via Gdb-patches wrote:
>> As reported in PR testsuite/30633, when running test-case
>> gdb.dwarf2/typeddwarf.exp with target board native-gdbserver on Ubuntu
>> 22.04.2, we run into:
>> ...
>> (gdb) continue^M
>> Continuing.^M
>> ^M
>> Program received signal SIGSEGV, Segmentation fault.^M
>> 0x0000000000000001 in ?? ()^M
>> (gdb) FAIL: gdb.dwarf2/typeddwarf.exp: runto: run to main
>> ...
>>
>> We run into the FAIL as follows:
>> - due to using gdbserver, we attach at the point of the first instruction, in
>>    _start
>> - we then set a breakpoint at main
>> - the test-case is a .s file, that has main renamed to _start in the assembly,
>>    but not in the debuginfo
>> - setting a breakpoint at main sets the breakpoint at the same instruction
>>    we're currently stopped at
>> - continue doesn't hit the breakpoint, and we return out of _start, which
>>    causes a sigsegv
>>
>> Note that this is for the amd64 case (using gdb.dwarf2/typeddwarf-amd64.S).
>> For the i386 case (using gdb.dwarf2/typeddwarf.S), setting a breakpoint in
>> main sets it one insn after function entry, and consequently the problem does
>> not occur.
>>
>> The FAIL is a regression since commit 90cce6c0551 ("[gdb/testsuite] Add nopie
>> in a few test-cases").
>>
>> Without nopie the executable is PIE, with nopie it's static instead.
>>
>> In the PIE case, we attach at the point of _start in the dynamic linker, and
>> consequently we do not skip the breakpoint in main, and also don't run into
>> the FAIL.
>>
>> Fix this by:
>> - removing the -nostdlib setting, and
>> - renaming _start to main in both .S files.
>>
>> The change to use -nostdlib and rename main to _start was originally added
>> in commit 6edba76fe8b (submitted here:
>> https://sourceware.org/pipermail/gdb-patches/2011-May/082657.html ) , I assume
>> to fix the problem now fixed by using nopie.
>>
>> Tested on x86_64-linux.
>>
>> Reported-By: Simon Marchi <simon.marchi@efficios.com>
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30633
> 
> I have not dug in the code at all, but I confirm that the patch fixes
> the test.  Therefore:
> 
> Tested-By: Simon Marchi <simon.marchi@efficios.com>

Thanks for testing, committed.

- Tom


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-26 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 14:15 [PATCH] [gdb/testsuite] Drop -nostdlib in gdb.dwarf2/typeddwarf.exp Tom de Vries
2023-07-24 16:21 ` Simon Marchi
2023-07-26 11:47   ` 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).