* PATCH: Update nm.c for 64bit BFD on 32bit ELF files.
@ 2001-08-24 15:35 H . J . Lu
2001-08-24 16:14 ` Andrew Cagney
2001-08-25 1:55 ` Nick Clifton
0 siblings, 2 replies; 4+ messages in thread
From: H . J . Lu @ 2001-08-24 15:35 UTC (permalink / raw)
To: binutils
With the new bfd_?printf_vma, now I got
# nm /tmp/u.o
U foo
00000000 t gcc2_compiled.
00000000 T main
when I used nm with the 64bit BFD on a 32bit ELF file. Here is a patch.
.
H.J.
----
2001-08-24 H.J. Lu <hjl@gnu.org>
* nm.c (print_width): New.
(display_rel_file): Set `print_width' according to
bfd_sprintf_vma.
(print_symbol_info_bsd): Check `print_width' instead of BFD64.
Index: nm.c
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/nm.c,v
retrieving revision 1.17
diff -u -p -r1.17 nm.c
--- nm.c 2001/08/10 17:02:45 1.17
+++ nm.c 2001/08/24 22:24:33
@@ -245,6 +245,11 @@ static char value_format[] = "%016lx";
/* We don't use value_format for this case. */
#endif
#endif
+#ifdef BFD64
+static int print_width = 16;
+#else
+static int print_width = 8;
+#endif
static int print_radix = 16;
/* Print formats for printing stab info. */
static char other_format[] = "%02x";
@@ -940,6 +945,7 @@ display_rel_file (abfd, archive_bfd)
PTR minisyms;
unsigned int size;
struct size_sym *symsizes;
+ char buf[30];
if (! dynamic)
{
@@ -960,6 +966,9 @@ display_rel_file (abfd, archive_bfd)
return;
}
+ bfd_sprintf_vma (abfd, buf, (bfd_vma) -1);
+ print_width = strlen (buf);
+
/* Discard the symbols we don't want to print.
It's OK to do this in place; we'll free the storage anyway
(after printing). */
@@ -1476,9 +1485,8 @@ print_symbol_info_bsd (info, abfd)
{
if (bfd_is_undefined_symclass (info->type))
{
-#ifdef BFD64
- printf (" ");
-#endif
+ if (print_width == 16)
+ printf (" ");
printf (" ");
}
else
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Update nm.c for 64bit BFD on 32bit ELF files.
2001-08-24 15:35 PATCH: Update nm.c for 64bit BFD on 32bit ELF files H . J . Lu
@ 2001-08-24 16:14 ` Andrew Cagney
2001-08-24 16:45 ` H . J . Lu
2001-08-25 1:55 ` Nick Clifton
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2001-08-24 16:14 UTC (permalink / raw)
To: H . J . Lu; +Cc: binutils
> + char buf[30];
>
> if (! dynamic)
> {
> @@ -960,6 +966,9 @@ display_rel_file (abfd, archive_bfd)
> return;
> }
>
> + bfd_sprintf_vma (abfd, buf, (bfd_vma) -1);
> + print_width = strlen (buf);
> +
Hmm, the most popular security hole and a generally popular bug is
buffer overrun on the stack. Is hardwiring a buffer allocated of the
stack and then sprintf() into it really a good idea?
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Update nm.c for 64bit BFD on 32bit ELF files.
2001-08-24 16:14 ` Andrew Cagney
@ 2001-08-24 16:45 ` H . J . Lu
0 siblings, 0 replies; 4+ messages in thread
From: H . J . Lu @ 2001-08-24 16:45 UTC (permalink / raw)
To: Andrew Cagney; +Cc: binutils
On Fri, Aug 24, 2001 at 07:14:22PM -0400, Andrew Cagney wrote:
>
> > + char buf[30];
> >
> > if (! dynamic)
> > {
> > @@ -960,6 +966,9 @@ display_rel_file (abfd, archive_bfd)
> > return;
> > }
> >
> > + bfd_sprintf_vma (abfd, buf, (bfd_vma) -1);
> > + print_width = strlen (buf);
> > +
>
> Hmm, the most popular security hole and a generally popular bug is
> buffer overrun on the stack. Is hardwiring a buffer allocated of the
> stack and then sprintf() into it really a good idea?
We know bfd_sprintf_vma will at most print a 64bit address in hex.
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Update nm.c for 64bit BFD on 32bit ELF files.
2001-08-24 15:35 PATCH: Update nm.c for 64bit BFD on 32bit ELF files H . J . Lu
2001-08-24 16:14 ` Andrew Cagney
@ 2001-08-25 1:55 ` Nick Clifton
1 sibling, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2001-08-25 1:55 UTC (permalink / raw)
To: H . J . Lu; +Cc: binutils
Hi H.J.
> 2001-08-24 H.J. Lu <hjl@gnu.org>
>
> * nm.c (print_width): New.
> (display_rel_file): Set `print_width' according to
> bfd_sprintf_vma.
> (print_symbol_info_bsd): Check `print_width' instead of BFD64.
Approved.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-08-25 1:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-24 15:35 PATCH: Update nm.c for 64bit BFD on 32bit ELF files H . J . Lu
2001-08-24 16:14 ` Andrew Cagney
2001-08-24 16:45 ` H . J . Lu
2001-08-25 1:55 ` Nick Clifton
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).