public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] readelf: Warn if ptr_size is not 4 or 8 bytes.
@ 2014-11-17 22:04 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2014-11-17 22:04 UTC (permalink / raw)
  To: elfutils-devel

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

Just warn and don't call print_cfa_program in that case. Bad things will
happen and the result is mostly bogus.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog | 5 +++++
 src/readelf.c | 9 ++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 737c674..96f21fd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-17  Mark Wielaard  <mjw@redhat.com>
+
+	* readelf.c (print_debug_frame_section): Warn if ptr_size is not 4
+	or 8 instead of just calling print_cfa_program.
+
 2014-11-16  Mark Wielaard  <mjw@redhat.com>
 
 	* readelf (process_elf_file): Set phnum to zero if there aren't
diff --git a/src/readelf.c b/src/readelf.c
index 583b5da..bd97ca6 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -5626,9 +5626,12 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
 	}
 
       /* Handle the initialization instructions.  */
-      print_cfa_program (readp, cieend, vma_base, code_alignment_factor,
-			 data_alignment_factor, version, ptr_size,
-			 dwflmod, ebl, dbg);
+      if (ptr_size != 4 && ptr_size !=8)
+	printf ("invalid CIE pointer size (%u), must be 4 or 8.\n", ptr_size);
+      else
+	print_cfa_program (readp, cieend, vma_base, code_alignment_factor,
+			   data_alignment_factor, version, ptr_size,
+			   dwflmod, ebl, dbg);
       readp = cieend;
     }
 }
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-11-17 22:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-17 22:04 [COMMITTED] readelf: Warn if ptr_size is not 4 or 8 bytes Mark Wielaard

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