🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Kevin Dalley Sat, 12 Dec 1992 04:33
patch for binutils/size.c to print unsigned long rather than ints
#1163
Author: Kevin Dalley
Date: Sat, 12 Dec 1992 04:33
74 lines
2726 bytes
In many cases, size print ints rather than unsigned ints, which can
produce negative sizes in the output.  Sometimes longs are used for
sizes, other times standard ints are used.  I converted to unsigned
ints.  One could argue that bfd_size_type is more appropriate in some
situations.  Since it hadn't been used in other parts of size, I
didn't use it.


RCS file: /usr/local/src/CVS/binutils/binutils/size.c,v
retrieving revision 1.1.1.1
co warning: redefinition of -V option
diff -u -r1.1.1.1 size.c
--- 1.1.1.1	92/11/26 02:12:39
+++ size.c	92/12/11 11:42:23
@@ -229,18 +229,20 @@
 /* This is what lexical functions are for */
 void
 lprint_number (width, num)
-     int width, num;
+     int width;
+     unsigned long num;
 {
-  printf ((radix == decimal ? "%-*d\t" :
-	   ((radix == octal) ? "%-*o\t" : "%-*x\t")), width, num);
+  printf ((radix == decimal ? "%-*lu\t" :
+	   ((radix == octal) ? "%-*lo\t" : "%-*lx\t")), width, num);
 }
 
 void
 rprint_number(width, num)
-     int width, num;
+     int width;
+     unsigned long num;
 {
-  printf ((radix == decimal ? "%*d\t" :
-	   ((radix == octal) ? "%*o\t" : "%*x\t")), width, num);
+  printf ((radix == decimal ? "%*lu\t" :
+	   ((radix == octal) ? "%*lo\t" : "%*lx\t")), width, num);
 }
 
 static char *bss_section_name = ".bss";
@@ -297,7 +299,8 @@
   lprint_number (7, textsize);
   lprint_number (7, datasize);
   lprint_number (7, bsssize);
-  printf (((radix == octal) ? "%-7o\t%-7x\t" : "%-7d\t%-7x\t"), total, total);
+  printf (((radix == octal) ? "%-7lo\t%-7lx\t"
+	   : "%-7ld\t%-7lx\t"), total, total);
 
   fputs(bfd_get_filename(abfd), stdout);
   if (abfd->my_archive) printf (" (ex %s)", abfd->my_archive->filename);
@@ -304,7 +307,7 @@
 }
 
 /* I REALLY miss lexical functions! */
-int svi_total = 0;
+unsigned int svi_total = 0;
 
 void
 sysv_internal_printer(file, sec, ignore)
@@ -312,7 +315,7 @@
      sec_ptr sec;
      PTR ignore;
 {
-  int size = bfd_section_size (file, sec);
+  unsigned long size = bfd_section_size (file, sec);
   if (sec!= &bfd_abs_section 
       && sec!= &bfd_com_section
       && sec!=&bfd_und_section) 

--
Kevin Dalley
Toshiba America MRI, Inc.
kevin@tamri.com
Re: patch for binutils/size.c to print unsigned long rather than ints
#1190
Author: bothner
Date: Mon, 14 Dec 1992 14:58
131 lines
4073 bytes
> One could argue that bfd_size_type is more appropriate in some
> situations.

I think so, so that is what I did.
Please try the appended patch instead.

	--Per Bothner
Cygnus Support     bothner@cygnus.com

===================================================================
RCS file: /rel/cvsfiles/devo/binutils/size.c,v
retrieving revision 1.11
diff -c -r1.11 size.c
*** 1.11	1992/11/05 12:01:43
--- size.c	1992/12/15 06:53:20
***************
*** 234,251 ****
  /* This is what lexical functions are for */
  void
  lprint_number (width, num)
!      int width, num;
  {
!   printf ((radix == decimal ? "%-*d\t" :
! 	   ((radix == octal) ? "%-*o\t" : "%-*x\t")), width, num);
  }
  
  void
  rprint_number(width, num)
!      int width, num;
  {
!   printf ((radix == decimal ? "%*d\t" :
! 	   ((radix == octal) ? "%*o\t" : "%*x\t")), width, num);
  }
  
  static char *bss_section_name = ".bss";
--- 234,253 ----
  /* This is what lexical functions are for */
  void
  lprint_number (width, num)
!      int width;
!      bfd_size_type num;
  {
!   printf ((radix == decimal ? "%-*ld\t" :
! 	   ((radix == octal) ? "%-*lo\t" : "%-*lx\t")), width, (long)num);
  }
  
  void
  rprint_number(width, num)
!      int width;
!      bfd_size_type num;
  {
!   printf ((radix == decimal ? "%*ld\t" :
! 	   ((radix == octal) ? "%*lo\t" : "%*lx\t")), width, (long)num);
  }
  
  static char *bss_section_name = ".bss";
***************
*** 260,269 ****
    sec_ptr bsssection = NULL;
    sec_ptr datasection = NULL;
    sec_ptr textsection = NULL;
!   unsigned long bsssize = 0;
!   unsigned long datasize = 0;
!   unsigned long textsize = 0;
!   unsigned long total = 0;
  
    
    if ((textsection = bfd_get_section_by_name (abfd, text_section_name))
--- 262,271 ----
    sec_ptr bsssection = NULL;
    sec_ptr datasection = NULL;
    sec_ptr textsection = NULL;
!   bfd_size_type bsssize = 0;
!   bfd_size_type datasize = 0;
!   bfd_size_type textsize = 0;
!   bfd_size_type total = 0;
  
    
    if ((textsection = bfd_get_section_by_name (abfd, text_section_name))
***************
*** 302,308 ****
    lprint_number (7, textsize);
    lprint_number (7, datasize);
    lprint_number (7, bsssize);
!   printf (((radix == octal) ? "%-7o\t%-7x\t" : "%-7d\t%-7x\t"), total, total);
  
    fputs(bfd_get_filename(abfd), stdout);
    if (abfd->my_archive) printf (" (ex %s)", abfd->my_archive->filename);
--- 304,311 ----
    lprint_number (7, textsize);
    lprint_number (7, datasize);
    lprint_number (7, bsssize);
!   printf (((radix == octal) ? "%-7lo\t%-7lx\t" : "%-7ld\t%-7lx\t"),
! 	  (long)total, (long)total);
  
    fputs(bfd_get_filename(abfd), stdout);
    if (abfd->my_archive) printf (" (ex %s)", abfd->my_archive->filename);
***************
*** 309,315 ****
  }
  
  /* I REALLY miss lexical functions! */
! int svi_total = 0;
  
  void
  sysv_internal_printer(file, sec, ignore)
--- 312,318 ----
  }
  
  /* I REALLY miss lexical functions! */
! bfd_size_type svi_total = 0;
  
  void
  sysv_internal_printer(file, sec, ignore)
***************
*** 317,323 ****
       sec_ptr sec;
       PTR ignore;
  {
!   int size = bfd_section_size (file, sec);
    if (sec!= &bfd_abs_section 
        && sec!= &bfd_com_section
        && sec!=&bfd_und_section) 
--- 320,326 ----
       sec_ptr sec;
       PTR ignore;
  {
!   bfd_size_type size = bfd_section_size (file, sec);
    if (sec!= &bfd_abs_section 
        && sec!= &bfd_com_section
        && sec!=&bfd_und_section) 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads