public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@red-bean.com>
To: binutils@sourceware.org
Subject: readelf: skip 'S' character in CFI 'z' augmentation strings
Date: Mon, 08 Feb 2010 10:16:00 -0000	[thread overview]
Message-ID: <8f2776cb1002080216s56f4e71aibea010a4de8e9189@mail.gmail.com> (raw)

[-- 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++;

             reply	other threads:[~2010-02-08 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 10:16 Jim Blandy [this message]
2010-02-08 11:13 ` Alan Modra
2010-02-08 19:28   ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f2776cb1002080216s56f4e71aibea010a4de8e9189@mail.gmail.com \
    --to=jimb@red-bean.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).