public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
@ 2019-08-16 15:58 Tom de Vries
  2019-08-29 15:04 ` [PING][PATCH][gdb/symtab] " Tom de Vries
  2019-10-09 14:47 ` [PATCH][gdb/symtab] " Tom Tromey
  0 siblings, 2 replies; 7+ messages in thread
From: Tom de Vries @ 2019-08-16 15:58 UTC (permalink / raw)
  To: gdb-patches

Hi,

With gdb.dwarf2/dw2-ranges.exp and target board unix/-fPIE/-pie, we run into:
...
info line main3^M
No line number information available for address 0x55555555464c <main3>^M
(gdb) FAIL: gdb.dwarf2/dw2-ranges.exp: info line main3
...

The main3 function in the executable comes from dw2-ranges3.o, which is
generated like this (leaving out -fPIE -pie for clarity):
...
$ gcc -S dw2-ranges3.c
$ gcc dw2-ranges3.s -o dw2-ranges3.o -gstabs
...
So, main3 is described in stabs format, generated by gas.

The difference between gcc-generated and gas-generated SLINE stabs is that gcc
generates a sequence SO (source), FUN (function), SLINE (source line) whereas
gas generates SO, SLINE.

The problem is that the line address relocation handling in process_one_symbol
assumes an order of SO, FUN, SLINE.

Fix this by also handling SO, SLINE.

This also fixes FAILs in gdb.btrace/instruction_history.exp with
target board stabs/-fPIE/-pie.

Tested on x86_64-linux with target boards unix, unix/-fPIE/-pie, stabs, and
stabs/-fPIE/-pie.

OK for trunk?

Thanks,
- Tom

[gdb/symtab] Handle gas-generated stabs with -fPIE/-pie

gdb/ChangeLog:

2019-08-16  Tom de Vries  <tdevries@suse.de>

	PR symtab/12497
	* dbxread.c (process_one_symbol): Handle relocation of SLINE address
	without preceding FUN/FNAME.

---
 gdb/dbxread.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index e339d1f7ec..e0ab4ec19c 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2626,6 +2626,9 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
 
       /* Relocate for dynamic loading and for ELF acc
          function-relative symbols.  */
+      if (function_start_offset == 0)
+	function_start_offset
+	  = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
       valu += function_start_offset;
 
       /* GCC 2.95.3 emits the first N_SLINE stab somwehere in the

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

* [PING][PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
  2019-08-16 15:58 [PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie Tom de Vries
@ 2019-08-29 15:04 ` Tom de Vries
  2019-09-06 15:31   ` [PING^2][PATCH][gdb/symtab] " Tom de Vries
  2019-10-09 14:47 ` [PATCH][gdb/symtab] " Tom Tromey
  1 sibling, 1 reply; 7+ messages in thread
From: Tom de Vries @ 2019-08-29 15:04 UTC (permalink / raw)
  To: gdb-patches

On 16-08-19 17:57, Tom de Vries wrote:
> Hi,
> 
> With gdb.dwarf2/dw2-ranges.exp and target board unix/-fPIE/-pie, we run into:
> ...
> info line main3^M
> No line number information available for address 0x55555555464c <main3>^M
> (gdb) FAIL: gdb.dwarf2/dw2-ranges.exp: info line main3
> ...
> 
> The main3 function in the executable comes from dw2-ranges3.o, which is
> generated like this (leaving out -fPIE -pie for clarity):
> ...
> $ gcc -S dw2-ranges3.c
> $ gcc dw2-ranges3.s -o dw2-ranges3.o -gstabs
> ...
> So, main3 is described in stabs format, generated by gas.
> 
> The difference between gcc-generated and gas-generated SLINE stabs is that gcc
> generates a sequence SO (source), FUN (function), SLINE (source line) whereas
> gas generates SO, SLINE.
> 
> The problem is that the line address relocation handling in process_one_symbol
> assumes an order of SO, FUN, SLINE.
> 
> Fix this by also handling SO, SLINE.
> 
> This also fixes FAILs in gdb.btrace/instruction_history.exp with
> target board stabs/-fPIE/-pie.
> 
> Tested on x86_64-linux with target boards unix, unix/-fPIE/-pie, stabs, and
> stabs/-fPIE/-pie.
> 
> OK for trunk?
> 

Ping.

Thanks,
- Tom

> [gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
> 
> gdb/ChangeLog:
> 
> 2019-08-16  Tom de Vries  <tdevries@suse.de>
> 
> 	PR symtab/12497
> 	* dbxread.c (process_one_symbol): Handle relocation of SLINE address
> 	without preceding FUN/FNAME.
> 
> ---
>  gdb/dbxread.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/gdb/dbxread.c b/gdb/dbxread.c
> index e339d1f7ec..e0ab4ec19c 100644
> --- a/gdb/dbxread.c
> +++ b/gdb/dbxread.c
> @@ -2626,6 +2626,9 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
>  
>        /* Relocate for dynamic loading and for ELF acc
>           function-relative symbols.  */
> +      if (function_start_offset == 0)
> +	function_start_offset
> +	  = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
>        valu += function_start_offset;
>  
>        /* GCC 2.95.3 emits the first N_SLINE stab somwehere in the
> 

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

* [PING^2][PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
  2019-08-29 15:04 ` [PING][PATCH][gdb/symtab] " Tom de Vries
@ 2019-09-06 15:31   ` Tom de Vries
  2019-09-13 19:51     ` [PING^3][PATCH][gdb/symtab] " Tom de Vries
  0 siblings, 1 reply; 7+ messages in thread
From: Tom de Vries @ 2019-09-06 15:31 UTC (permalink / raw)
  To: gdb-patches

On 29-08-19 17:04, Tom de Vries wrote:
> On 16-08-19 17:57, Tom de Vries wrote:
>> Hi,
>>
>> With gdb.dwarf2/dw2-ranges.exp and target board unix/-fPIE/-pie, we run into:
>> ...
>> info line main3^M
>> No line number information available for address 0x55555555464c <main3>^M
>> (gdb) FAIL: gdb.dwarf2/dw2-ranges.exp: info line main3
>> ...
>>
>> The main3 function in the executable comes from dw2-ranges3.o, which is
>> generated like this (leaving out -fPIE -pie for clarity):
>> ...
>> $ gcc -S dw2-ranges3.c
>> $ gcc dw2-ranges3.s -o dw2-ranges3.o -gstabs
>> ...
>> So, main3 is described in stabs format, generated by gas.
>>
>> The difference between gcc-generated and gas-generated SLINE stabs is that gcc
>> generates a sequence SO (source), FUN (function), SLINE (source line) whereas
>> gas generates SO, SLINE.
>>
>> The problem is that the line address relocation handling in process_one_symbol
>> assumes an order of SO, FUN, SLINE.
>>
>> Fix this by also handling SO, SLINE.
>>
>> This also fixes FAILs in gdb.btrace/instruction_history.exp with
>> target board stabs/-fPIE/-pie.
>>
>> Tested on x86_64-linux with target boards unix, unix/-fPIE/-pie, stabs, and
>> stabs/-fPIE/-pie.
>>
>> OK for trunk?
>>

Ping^2.

Thanks,
- Tom

>> [gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
>>
>> gdb/ChangeLog:
>>
>> 2019-08-16  Tom de Vries  <tdevries@suse.de>
>>
>> 	PR symtab/12497
>> 	* dbxread.c (process_one_symbol): Handle relocation of SLINE address
>> 	without preceding FUN/FNAME.
>>
>> ---
>>  gdb/dbxread.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/gdb/dbxread.c b/gdb/dbxread.c
>> index e339d1f7ec..e0ab4ec19c 100644
>> --- a/gdb/dbxread.c
>> +++ b/gdb/dbxread.c
>> @@ -2626,6 +2626,9 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
>>  
>>        /* Relocate for dynamic loading and for ELF acc
>>           function-relative symbols.  */
>> +      if (function_start_offset == 0)
>> +	function_start_offset
>> +	  = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
>>        valu += function_start_offset;
>>  
>>        /* GCC 2.95.3 emits the first N_SLINE stab somwehere in the
>>

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

* [PING^3][PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
  2019-09-06 15:31   ` [PING^2][PATCH][gdb/symtab] " Tom de Vries
@ 2019-09-13 19:51     ` Tom de Vries
  0 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2019-09-13 19:51 UTC (permalink / raw)
  To: gdb-patches

On 06-09-19 17:31, Tom de Vries wrote:
> On 29-08-19 17:04, Tom de Vries wrote:
>> On 16-08-19 17:57, Tom de Vries wrote:
>>> Hi,
>>>
>>> With gdb.dwarf2/dw2-ranges.exp and target board unix/-fPIE/-pie, we run into:
>>> ...
>>> info line main3^M
>>> No line number information available for address 0x55555555464c <main3>^M
>>> (gdb) FAIL: gdb.dwarf2/dw2-ranges.exp: info line main3
>>> ...
>>>
>>> The main3 function in the executable comes from dw2-ranges3.o, which is
>>> generated like this (leaving out -fPIE -pie for clarity):
>>> ...
>>> $ gcc -S dw2-ranges3.c
>>> $ gcc dw2-ranges3.s -o dw2-ranges3.o -gstabs
>>> ...
>>> So, main3 is described in stabs format, generated by gas.
>>>
>>> The difference between gcc-generated and gas-generated SLINE stabs is that gcc
>>> generates a sequence SO (source), FUN (function), SLINE (source line) whereas
>>> gas generates SO, SLINE.
>>>
>>> The problem is that the line address relocation handling in process_one_symbol
>>> assumes an order of SO, FUN, SLINE.
>>>
>>> Fix this by also handling SO, SLINE.
>>>
>>> This also fixes FAILs in gdb.btrace/instruction_history.exp with
>>> target board stabs/-fPIE/-pie.
>>>
>>> Tested on x86_64-linux with target boards unix, unix/-fPIE/-pie, stabs, and
>>> stabs/-fPIE/-pie.
>>>
>>> OK for trunk?
>>>

Ping^3.

Thanks,
- Tom

>>> [gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
>>>
>>> gdb/ChangeLog:
>>>
>>> 2019-08-16  Tom de Vries  <tdevries@suse.de>
>>>
>>> 	PR symtab/12497
>>> 	* dbxread.c (process_one_symbol): Handle relocation of SLINE address
>>> 	without preceding FUN/FNAME.
>>>
>>> ---
>>>  gdb/dbxread.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/gdb/dbxread.c b/gdb/dbxread.c
>>> index e339d1f7ec..e0ab4ec19c 100644
>>> --- a/gdb/dbxread.c
>>> +++ b/gdb/dbxread.c
>>> @@ -2626,6 +2626,9 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
>>>  
>>>        /* Relocate for dynamic loading and for ELF acc
>>>           function-relative symbols.  */
>>> +      if (function_start_offset == 0)
>>> +	function_start_offset
>>> +	  = ANOFFSET (section_offsets, SECT_OFF_TEXT (objfile));
>>>        valu += function_start_offset;
>>>  
>>>        /* GCC 2.95.3 emits the first N_SLINE stab somwehere in the
>>>

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

* Re: [PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie
  2019-08-16 15:58 [PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie Tom de Vries
  2019-08-29 15:04 ` [PING][PATCH][gdb/symtab] " Tom de Vries
@ 2019-10-09 14:47 ` Tom Tromey
  2019-10-15 10:18   ` [RFC] Do we need to support PIE + stabs? Tom de Vries
  1 sibling, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2019-10-09 14:47 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> The main3 function in the executable comes from dw2-ranges3.o, which is
Tom> generated like this (leaving out -fPIE -pie for clarity):
Tom> ...
Tom> $ gcc -S dw2-ranges3.c
Tom> $ gcc dw2-ranges3.s -o dw2-ranges3.o -gstabs
Tom> ...
Tom> So, main3 is described in stabs format, generated by gas.

Tom> 2019-08-16  Tom de Vries  <tdevries@suse.de>

Tom> 	PR symtab/12497
Tom> 	* dbxread.c (process_one_symbol): Handle relocation of SLINE address
Tom> 	without preceding FUN/FNAME.

I don't know enough about stabs to say whether this change is correct or
whether it will cause problems in some other scenario.  It modifies
"valu" - which isn't then reset, so perhaps it's used in some other way
later.

Do we need to support PIE + stabs?  Can we just declare stabs as mostly
dead and ignore this instead?  On the whole that would be my preference,
if it's possible, because in my view this more closely mirrors
reality...  my understanding is that, last time anybody checked, stabs
were still used by a few programs in a typical distro (for some unknown
reason), but otherwise they are just totally obsolete.

Tom

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

* [RFC] Do we need to support PIE + stabs?
  2019-10-09 14:47 ` [PATCH][gdb/symtab] " Tom Tromey
@ 2019-10-15 10:18   ` Tom de Vries
  2019-10-25 14:39     ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Tom de Vries @ 2019-10-15 10:18 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[ was: Re: [PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie ]

On 09-10-2019 16:46, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> The main3 function in the executable comes from dw2-ranges3.o, which is
> Tom> generated like this (leaving out -fPIE -pie for clarity):
> Tom> ...
> Tom> $ gcc -S dw2-ranges3.c
> Tom> $ gcc dw2-ranges3.s -o dw2-ranges3.o -gstabs
> Tom> ...
> Tom> So, main3 is described in stabs format, generated by gas.
> 
> Tom> 2019-08-16  Tom de Vries  <tdevries@suse.de>
> 
> Tom> 	PR symtab/12497
> Tom> 	* dbxread.c (process_one_symbol): Handle relocation of SLINE address
> Tom> 	without preceding FUN/FNAME.
> 
> I don't know enough about stabs to say whether this change is correct or
> whether it will cause problems in some other scenario.  It modifies
> "valu" - which isn't then reset, so perhaps it's used in some other way
> later.
> 
> Do we need to support PIE + stabs?  Can we just declare stabs as mostly
> dead and ignore this instead?  On the whole that would be my preference,
> if it's possible, because in my view this more closely mirrors
> reality...  my understanding is that, last time anybody checked, stabs
> were still used by a few programs in a typical distro (for some unknown
> reason), but otherwise they are just totally obsolete.

I don't know the answer to that, and I think it's a question broader
than suggested by the current subject, so, promoting the question to the
subject.

Thanks,
- Tom


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

* Re: [RFC] Do we need to support PIE + stabs?
  2019-10-15 10:18   ` [RFC] Do we need to support PIE + stabs? Tom de Vries
@ 2019-10-25 14:39     ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2019-10-25 14:39 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Tom Tromey, gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

>> Do we need to support PIE + stabs?  Can we just declare stabs as mostly
>> dead and ignore this instead?  On the whole that would be my preference,
>> if it's possible, because in my view this more closely mirrors
>> reality...  my understanding is that, last time anybody checked, stabs
>> were still used by a few programs in a typical distro (for some unknown
>> reason), but otherwise they are just totally obsolete.

Tom> I don't know the answer to that, and I think it's a question broader
Tom> than suggested by the current subject, so, promoting the question to the
Tom> subject.

No-one has answered yet...

I still think the answer is "no" for the reasons outlined above.

thanks,
Tom

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

end of thread, other threads:[~2019-10-25 14:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-16 15:58 [PATCH][gdb/symtab] Handle gas-generated stabs with -fPIE/-pie Tom de Vries
2019-08-29 15:04 ` [PING][PATCH][gdb/symtab] " Tom de Vries
2019-09-06 15:31   ` [PING^2][PATCH][gdb/symtab] " Tom de Vries
2019-09-13 19:51     ` [PING^3][PATCH][gdb/symtab] " Tom de Vries
2019-10-09 14:47 ` [PATCH][gdb/symtab] " Tom Tromey
2019-10-15 10:18   ` [RFC] Do we need to support PIE + stabs? Tom de Vries
2019-10-25 14:39     ` Tom Tromey

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).