public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: binutils@sourceware.org
Subject: Commit: ld: Add ability to print hex values in the linker map
Date: Thu, 27 Apr 2023 13:01:48 +0100	[thread overview]
Message-ID: <87354lr0sz.fsf@redhat.com> (raw)

Hi Guys,

  Whilst working on an enhancement to the linker map output I found it
  frustrating that I could not print hex values that were not addresses,
  so I am applying the patch below.  It adds support for "%x" and "%lx"
  to the formats allowed with the vinfo() function.

Cheers
  Nick

ld/ChangeLog
2023-04-27  Nick Clifton  <nickc@redhat.com>

	* ldmisc.c (vfinfo): Add support for %x and %lx.

diff --git a/ld/ldmisc.c b/ld/ldmisc.c
index 5d7012e50b1..ef46ad665e9 100644
--- a/ld/ldmisc.c
+++ b/ld/ldmisc.c
@@ -52,6 +52,7 @@
  %d integer, like printf
  %ld long, like printf
  %lu unsigned long, like printf
+ %lx unsigned long, like printf
  %p native (host) void* pointer, like printf
  %pA section name from a section
  %pB filename from a bfd
@@ -63,6 +64,7 @@
  %s arbitrary string, like printf
  %u integer, like printf
  %v hex bfd_vma, no leading zeros
+ %x integer, like printf
 */
 
 void
@@ -152,11 +154,12 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
 
 	    case 'd':
 	    case 'u':
+	    case 'x':
 	      arg_type = Int;
 	      break;
 
 	    case 'l':
-	      if (*scan == 'd' || *scan == 'u')
+	      if (*scan == 'd' || *scan == 'u' || *scan == 'x')
 		{
 		  ++scan;
 		  arg_type = Long;
@@ -544,6 +547,12 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
 	      ++arg_count;
 	      break;
 
+	    case 'x':
+	      /* unsigned integer, like printf */
+	      fprintf (fp, "%x", args[arg_no].i);
+	      ++arg_count;
+	      break;
+
 	    case 'l':
 	      if (*fmt == 'd')
 		{
@@ -559,6 +568,13 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
 		  ++fmt;
 		  break;
 		}
+	      else if (*fmt == 'x')
+		{
+		  fprintf (fp, "%lx", args[arg_no].l);
+		  ++arg_count;
+		  ++fmt;
+		  break;
+		}
 	      /* Fallthru */
 
 	    default:


                 reply	other threads:[~2023-04-27 12:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87354lr0sz.fsf@redhat.com \
    --to=nickc@redhat.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).