public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* readelf: skip 'S' character in CFI 'z' augmentation strings
@ 2010-02-08 10:16 Jim Blandy
  2010-02-08 11:13 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2010-02-08 10:16 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]

The 'readelf' program fails to process 'z' augmentation strings using
the 'S' character, making it unable to display valid FDEs.

A 'z' CFI augmentation string can include an 'S' character, indicating
that the frame is a signal handler. When unwinding an ordinary stack
frame, the PC recovered for the caller is usually that of the
instruction after the call, which causes difficulties if the call is
the last instruction of the function --- presumably to a function the
compiler knows will never return. The 'S' augmentation character
allows unwinders to avoid performing this hack when unwinding from a
signal handler.

The Linux Standards Base 4.0 doesn't mention 'S', but this isn't too
surprising --- the section describing the .eh_frame augmentations
still has simple copy-editing problems and serious omissions unfixed
since LSB 3.0.  The best documentation for 'S' appears to be:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26208

Because readelf doesn't recognize 'S', it may fail to process other
augmentation string characters necessary to parse the FDE, like 'R'.
This patch fixes that.

[-- Attachment #2: skip-S-augmentation.patch --]
[-- Type: text/x-patch, Size: 2158 bytes --]

The 'readelf' program fails to process 'z' augmentation strings using
the 'S' character, making it unable to display valid FDEs.

A 'z' CFI augmentation string can include an 'S' character, indicating
that the frame is a signal handler. When unwinding an ordinary stack
frame, the PC recovered for the caller is usually that of the
instruction after the call, which causes difficulties if the call is
the last instruction of the function --- presumably to a function the
compiler knows will never return. The 'S' augmentation character
allows unwinders to avoid performing this hack when unwinding from a
signal handler.

The Linux Standards Base 4.0 doesn't mention 'S', but this isn't too
surprising --- the section describing the .eh_frame augmentations
still has simple copy-editing problems and serious omissions unfixed
since LSB 3.0.  The best documentation for 'S' appears to be:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26208

Because readelf doesn't recognize 'S', it may fail to process other
augmentation string characters necessary to parse the FDE, like 'R'.
This patch fixes that.


Index: binutils/ChangeLog
===================================================================
RCS file: /cvs/src/src/binutils/ChangeLog,v
retrieving revision 1.1610
diff -u -r1.1610 ChangeLog
--- binutils/ChangeLog	2 Feb 2010 12:37:39 -0000	1.1610
+++ binutils/ChangeLog	8 Feb 2010 09:49:06 -0000
@@ -1,3 +1,8 @@
+2010-02-08  Jim Blandy  <jimb@red-bean.com>
+
+	* dwarf.c (display_debug_frames): Skip the 'S' character in CFI
+	'z' augmentation strings.
+
 2010-02-02  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* readelf.c (get_note_type): Handle NT_X86_XSTATE.
Index: binutils/dwarf.c
===================================================================
RCS file: /cvs/src/src/binutils/dwarf.c,v
retrieving revision 1.61
diff -u -r1.61 dwarf.c
--- binutils/dwarf.c	14 Jan 2010 09:19:56 -0000	1.61
+++ binutils/dwarf.c	8 Feb 2010 09:49:06 -0000
@@ -4114,6 +4114,8 @@
 		    q += 1 + size_of_encoded_value (*q);
 		  else if (*p == 'R')
 		    fc->fde_encoding = *q++;
+                  else if (*p == 'S')
+                    ;
 		  else
 		    break;
 		  p++;

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

* Re: readelf: skip 'S' character in CFI 'z' augmentation strings
  2010-02-08 10:16 readelf: skip 'S' character in CFI 'z' augmentation strings Jim Blandy
@ 2010-02-08 11:13 ` Alan Modra
  2010-02-08 19:28   ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2010-02-08 11:13 UTC (permalink / raw)
  To: Jim Blandy; +Cc: binutils

On Mon, Feb 08, 2010 at 02:16:11AM -0800, Jim Blandy wrote:
> +	* dwarf.c (display_debug_frames): Skip the 'S' character in CFI
> +	'z' augmentation strings.

OK.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: readelf: skip 'S' character in CFI 'z' augmentation strings
  2010-02-08 11:13 ` Alan Modra
@ 2010-02-08 19:28   ` Jim Blandy
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Blandy @ 2010-02-08 19:28 UTC (permalink / raw)
  To: Jim Blandy, binutils

On Mon, Feb 8, 2010 at 3:12 AM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Feb 08, 2010 at 02:16:11AM -0800, Jim Blandy wrote:
>> +     * dwarf.c (display_debug_frames): Skip the 'S' character in CFI
>> +     'z' augmentation strings.
>
> OK.

Committed; thanks.

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

end of thread, other threads:[~2010-02-08 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-08 10:16 readelf: skip 'S' character in CFI 'z' augmentation strings Jim Blandy
2010-02-08 11:13 ` Alan Modra
2010-02-08 19:28   ` Jim Blandy

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