From: "H . J . Lu" <hjl@lucon.org>
To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Cc: binutils@sourceware.cygnus.com
Subject: Re: PATCH: Add bfd_sprintf_vma/bfd_fprintf_vma
Date: Thu, 09 Aug 2001 09:03:00 -0000 [thread overview]
Message-ID: <20010809090341.A18066@lucon.org> (raw)
In-Reply-To: <20010808150631.A2336@lucon.org>
On Wed, Aug 08, 2001 at 03:06:31PM -0700, H . J . Lu wrote:
>
> Here is the first step to implement it. After it is checked in, I will
> replace as many sprintf_vma/fprintf_vma with _sprintf_vma/bfd_fprintf_vma
> as I can to fix it. Any comments?
>
I checked in the following patch. I am coverting sprintf_vma/fprintf_vma
to _sprintf_vma/bfd_fprintf_vma.
H.J.
----
2001-08-09 H.J. Lu <hjl@gnu.org>
* bfd-in.h (bfd_sprintf_vma): New prototype.
(bfd_fprintf_vma): Likewise.
(bfd_elf_sprintf_vma): Likewise.
(bfd_elf_fprintf_vma): Likewise.
(bfd_printf_vma): New. Defined with bfd_fprintf_vma.
* bfd-in2.h: Regenerated.
* bfd.c (bfd_sprintf_vma): New. Defined.
(bfd_fprintf_vma): Likewise.
* elf.c (bfd_elf_sprintf_vma): New. Defined.
(bfd_elf_fprintf_vma): Likewise.
Index: bfd-in.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/bfd-in.h,v
retrieving revision 1.25
diff -u -p -r1.25 bfd-in.h
--- bfd-in.h 2001/06/19 17:57:39 1.25
+++ bfd-in.h 2001/08/09 15:37:29
@@ -183,7 +183,13 @@ typedef unsigned long bfd_size_type;
#endif /* not BFD64 */
+extern void bfd_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
+extern void bfd_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
+extern void bfd_elf_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
+extern void bfd_elf_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
+
#define printf_vma(x) fprintf_vma(stdout,x)
+#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
typedef unsigned int flagword; /* 32 bits of flags */
typedef unsigned char bfd_byte;
Index: bfd-in2.h
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/bfd-in2.h,v
retrieving revision 1.74
diff -u -p -r1.74 bfd-in2.h
--- bfd-in2.h 2001/07/12 15:35:22 1.74
+++ bfd-in2.h 2001/08/09 15:37:29
@@ -183,7 +183,13 @@ typedef unsigned long bfd_size_type;
#endif /* not BFD64 */
+extern void bfd_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
+extern void bfd_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
+extern void bfd_elf_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
+extern void bfd_elf_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
+
#define printf_vma(x) fprintf_vma(stdout,x)
+#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x)
typedef unsigned int flagword; /* 32 bits of flags */
typedef unsigned char bfd_byte;
Index: bfd.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/bfd.c,v
retrieving revision 1.1.1.11
diff -u -p -r1.1.1.11 bfd.c
--- bfd.c 2001/07/03 16:39:26 1.1.1.11
+++ bfd.c 2001/08/09 15:37:29
@@ -1250,3 +1250,25 @@ bfd_record_phdr (abfd, type, flags_valid
return true;
}
+
+void
+bfd_sprintf_vma (abfd, buf, value)
+ bfd *abfd;
+ char *buf;
+ bfd_vma value;
+{
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ return bfd_elf_sprintf_vma (abfd, buf, value);
+ sprintf_vma (buf, value);
+}
+
+void
+bfd_fprintf_vma (abfd, stream, value)
+ bfd *abfd;
+ PTR stream;
+ bfd_vma value;
+{
+ if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+ return bfd_elf_fprintf_vma (abfd, stream, value);
+ fprintf_vma ((FILE *) stream, value);
+}
Index: elf.c
===================================================================
RCS file: /work/cvs/gnu/binutils/bfd/elf.c,v
retrieving revision 1.58
diff -u -p -r1.58 elf.c
--- elf.c 2001/08/03 15:55:46 1.58
+++ elf.c 2001/08/09 15:37:29
@@ -5986,3 +5986,54 @@ bfd_get_elf_phdrs (abfd, phdrs)
return num_phdrs;
}
+
+void
+bfd_elf_sprintf_vma (abfd, buf, value)
+ bfd *abfd;
+ char *buf;
+ bfd_vma value;
+{
+ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
+
+ i_ehdrp = elf_elfheader (abfd);
+ if (i_ehdrp == NULL)
+ sprintf_vma (buf, value);
+ else
+ {
+ if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64)
+#if BFD_HOST_64BIT_LONG
+ sprintf (buf, "%016lx", value);
+#else
+ sprintf (buf, "%08lx%08lx", _bfd_int64_high (value),
+ _bfd_int64_low (value));
+#endif
+ else
+ sprintf (buf, "%08lx", (unsigned long) (value & 0xffffffff));
+ }
+}
+
+void
+bfd_elf_fprintf_vma (abfd, stream, value)
+ bfd *abfd;
+ PTR stream;
+ bfd_vma value;
+{
+ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
+
+ i_ehdrp = elf_elfheader (abfd);
+ if (i_ehdrp == NULL)
+ fprintf_vma ((FILE *) stream, value);
+ else
+ {
+ if (i_ehdrp->e_ident[EI_CLASS] == ELFCLASS64)
+#if BFD_HOST_64BIT_LONG
+ fprintf ((FILE *) stream, "%016lx", value);
+#else
+ fprintf ((FILE *) stream, "%08lx%08lx",
+ _bfd_int64_high (value), _bfd_int64_low (value));
+#endif
+ else
+ fprintf ((FILE *) stream, "%08lx",
+ (unsigned long) (value & 0xffffffff));
+ }
+}
next prev parent reply other threads:[~2001-08-09 9:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-08 15:06 H . J . Lu
2001-08-09 9:03 ` H . J . Lu [this message]
2001-08-09 9:27 ` Doug Evans
2001-08-09 9:48 ` H . J . Lu
2001-08-09 14:12 ` H . J . Lu
2001-08-10 1:05 ` Alan Modra
2001-08-10 1:09 ` Maciej W. Rozycki
2001-08-10 9:38 ` H . J . Lu
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=20010809090341.A18066@lucon.org \
--to=hjl@lucon.org \
--cc=binutils@sourceware.cygnus.com \
--cc=macro@ds2.pg.gda.pl \
/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).