This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: Update nm.c for 64bit BFD on 32bit ELF files.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]