public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Cc: Indu Bhagat <indu.bhagat@oracle.com>
Subject: [PATCH 09/12] objdump/readelf: adjust for SFRAME_VERSION_2
Date: Tue, 27 Jun 2023 14:20:25 -0700	[thread overview]
Message-ID: <20230627212028.2138604-10-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20230627212028.2138604-1-indu.bhagat@oracle.com>

Make adjustments to account for a new format version and its name.
Also shuffle some code to make it more readable and use the available
APIs rather than direct access.

objdump/readelf will show the following message to the user if .sframe
section in SFRAME_VERSION_1 format is seen:

 "No further information can be displayed.  SFrame version not
 supported."

In other words, like the rest of the binutils, only the current SFrame
format version, i.e., SFRAME_VERSION_2 is supported by the textual dump
facilities.

libsframe/
	* sframe-dump.c (dump_sframe_header): Add support for
	SFRAME_VERSION_2.
	(dump_sframe): Inform user if SFrame section in SFRAME_VERSION_1
	format is seen.
---
 libsframe/sframe-dump.c | 42 +++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 4799652f727..bb83528bc79 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -43,27 +43,33 @@ is_sframe_abi_arch_aarch64 (sframe_decoder_ctx *sfd_ctx)
 static void
 dump_sframe_header (sframe_decoder_ctx *sfd_ctx)
 {
-  const char *verstr = NULL;
+  uint8_t ver;
+  uint8_t flags;
+  char *flags_str;
+  const char *ver_str = NULL;
   const sframe_header *header = &(sfd_ctx->sfd_header);
 
   /* Prepare SFrame section version string.  */
   const char *version_names[]
     = { "NULL",
-	"SFRAME_VERSION_1" };
-  unsigned char ver = header->sfh_preamble.sfp_version;
+	"SFRAME_VERSION_1",
+	"SFRAME_VERSION_2" };
+
+  /* PS: Keep SFRAME_HEADER_FLAGS_STR_MAX_LEN in sync if adding more members to
+     this array.  */
+  const char *flag_names[]
+    = { "SFRAME_F_FDE_SORTED",
+	"SFRAME_F_FRAME_POINTER" };
+
+  ver = sframe_decoder_get_version (sfd_ctx);
   if (ver <= SFRAME_VERSION)
-    verstr = version_names[ver];
+    ver_str = version_names[ver];
 
   /* Prepare SFrame section flags string.  */
-  unsigned char flags = header->sfh_preamble.sfp_flags;
-  char *flags_str
-    = (char*) calloc (sizeof (char), SFRAME_HEADER_FLAGS_STR_MAX_LEN);
+  flags = header->sfh_preamble.sfp_flags;
+  flags_str = (char*) calloc (sizeof (char), SFRAME_HEADER_FLAGS_STR_MAX_LEN);
   if (flags)
     {
-      const char *flag_names[]
-	= { "SFRAME_F_FDE_SORTED",
-	    "SFRAME_F_FRAME_POINTER" };
-      unsigned char flags = header->sfh_preamble.sfp_flags;
       if (flags & SFRAME_F_FDE_SORTED)
 	strcpy (flags_str, flag_names[0]);
       if (flags & SFRAME_F_FRAME_POINTER)
@@ -80,9 +86,9 @@ dump_sframe_header (sframe_decoder_ctx *sfd_ctx)
   printf ("\n");
   printf ("  %s :\n", subsec_name);
   printf ("\n");
-  printf ("    Version: %s\n", verstr);
+  printf ("    Version: %s\n", ver_str);
   printf ("    Flags: %s\n", flags_str);
-  printf ("    Num FDEs: %d\n", header->sfh_num_fdes);
+  printf ("    Num FDEs: %d\n", sframe_decoder_get_num_fidx (sfd_ctx));
   printf ("    Num FREs: %d\n", header->sfh_num_fres);
 
   free (flags_str);
@@ -203,6 +209,14 @@ dump_sframe_functions (sframe_decoder_ctx *sfd_ctx, uint64_t sec_addr)
 void
 dump_sframe (sframe_decoder_ctx *sfd_ctx, uint64_t sec_addr)
 {
+  uint8_t ver;
+
   dump_sframe_header (sfd_ctx);
-  dump_sframe_functions (sfd_ctx, sec_addr);
+
+  ver = sframe_decoder_get_version (sfd_ctx);
+  if (ver == SFRAME_VERSION)
+    dump_sframe_functions (sfd_ctx, sec_addr);
+  else
+    printf ("\n No further information can be displayed.  %s",
+	    "SFrame version not supported\n");
 }
-- 
2.39.2


  parent reply	other threads:[~2023-06-27 21:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 21:20 [PATCH 00/12] SFrame Version 2 - definition and support Indu Bhagat
2023-06-27 21:20 ` [PATCH 01/12] sframe.h: format bump to SFrame version 2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 02/12] gas: generate SFrame section with version SFRAME_VERSION_2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 03/12] libsframe: add new APIs to get SFrame version Indu Bhagat
2023-06-27 21:20 ` [PATCH 04/12] libsframe: add new APIs to add and get SFrame FDE in SFrame version 2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 05/12] libsframe: adjust version check in sframe_header_sanity_check_p Indu Bhagat
2023-06-27 21:20 ` [PATCH 06/12] libsframe: testsuite: fixes for SFRAME_VERSION_2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 07/12] bfd: linker: add support for rep_block_size for pltN entries Indu Bhagat
2023-06-27 21:20 ` [PATCH 08/12] bfd: linker: generate SFrame sections with version SFRAME_VERSION_2 Indu Bhagat
2023-06-27 21:20 ` Indu Bhagat [this message]
2023-06-28 23:04   ` [PATCH 09/12] objdump/readelf: adjust for SFRAME_VERSION_2 Hans-Peter Nilsson
2023-06-29  6:41     ` Indu Bhagat
2023-06-27 21:20 ` [PATCH 10/12] doc: sframe: update specification " Indu Bhagat
2023-06-27 21:20 ` [PATCH 11/12] doc: sframe: add details about alignment in the SFrame format Indu Bhagat
2023-06-27 21:20 ` [PATCH 12/12] binutils/NEWS: announce SFrame version 2 as the new default Indu Bhagat

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=20230627212028.2138604-10-indu.bhagat@oracle.com \
    --to=indu.bhagat@oracle.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).