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]
Other format: [Raw text]

readelf: Handle symbols with large values.


Hi Guys,

  Here is a patch to readelf to slightly improve its displaying of
  symbols with large values.  At the moment readelf will print out a
  large negative number like this:

   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
     4: 0000000000000000     4 OBJECT  LOCAL  DEFAULT    3 I
     5: 0000000000000004     4 OBJECT  LOCAL  DEFAULT    3 J
     6: 0000000000000008 -1894967300 OBJECT  LOCAL  DEFAULT    3 N

  With the patch applied this becomes:

   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    2
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
     4: 0000000000000000     4 OBJECT  LOCAL  DEFAULT    3 I
     5: 0000000000000004     4 OBJECT  LOCAL  DEFAULT    3 J
     6: 0000000000000008 0x8f0d17fc OBJECT  LOCAL  DEFAULT    3 N

  Which I think is better.

Cheers
        Nick

2003-06-19  Nick Clifton  <nickc@redhat.com>

	* readelf.c (print_vma): When printing DEC_5 values, if the
	number is bigger than 99999 switch to using hexadecimal
	notation.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.209
diff -c -3 -p -r1.209 readelf.c
*** binutils/readelf.c	3 Jun 2003 22:27:22 -0000	1.209
--- binutils/readelf.c	19 Jun 2003 10:16:28 -0000
*************** print_vma (vma, mode)
*** 624,636 ****
      {
        switch (mode)
  	{
! 	case FULL_HEX: printf ("0x"); /* drop through */
! 	case LONG_HEX: printf ("%8.8lx", (unsigned long) vma); break;
! 	case PREFIX_HEX: printf ("0x"); /* drop through */
! 	case HEX: printf ("%lx", (unsigned long) vma); break;
! 	case DEC: printf ("%ld", (unsigned long) vma); break;
! 	case DEC_5: printf ("%5ld", (long) vma); break;
! 	case UNSIGNED: printf ("%lu", (unsigned long) vma); break;
  	}
      }
  #ifdef BFD64
--- 624,657 ----
      {
        switch (mode)
  	{
! 	case FULL_HEX:
! 	  printf ("0x");
! 	  /* Drop through.  */
! 	case LONG_HEX:
! 	  printf ("%8.8lx", (unsigned long) vma);
! 	  break;
! 
! 	case DEC_5:
! 	  if (vma <= 99999)
! 	    {
! 	      printf ("** %5ld", (long) vma);
! 	      break;
! 	    }
! 	  /* Drop through.  */
! 	case PREFIX_HEX:
! 	  printf ("0x");
! 	  /* Drop through.  */
! 	case HEX:
! 	  printf ("%lx", (unsigned long) vma);
! 	  break;
! 
! 	case DEC:
! 	  printf ("%ld", (unsigned long) vma);
! 	  break;
! 
! 	case UNSIGNED:
! 	  printf ("%lu", (unsigned long) vma);
! 	  break;
  	}
      }
  #ifdef BFD64
*************** print_vma (vma, mode)
*** 640,646 ****
  	{
  	case FULL_HEX:
  	  printf ("0x");
! 	  /* drop through */
  
  	case LONG_HEX:
  	  printf_vma (vma);
--- 661,667 ----
  	{
  	case FULL_HEX:
  	  printf ("0x");
! 	  /* Drop through.  */
  
  	case LONG_HEX:
  	  printf_vma (vma);
*************** print_vma (vma, mode)
*** 648,654 ****
  
  	case PREFIX_HEX:
  	  printf ("0x");
! 	  /* drop through */
  
  	case HEX:
  #if BFD_HOST_64BIT_LONG
--- 669,675 ----
  
  	case PREFIX_HEX:
  	  printf ("0x");
! 	  /* Drop through.  */
  
  	case HEX:
  #if BFD_HOST_64BIT_LONG
*************** print_vma (vma, mode)
*** 675,687 ****
  
  	case DEC_5:
  #if BFD_HOST_64BIT_LONG
! 	  printf ("%5ld", vma);
  #else
  	  if (_bfd_int64_high (vma))
  	    /* ugg */
  	    printf ("++%ld", _bfd_int64_low (vma));
! 	  else
  	    printf ("%5ld", _bfd_int64_low (vma));
  #endif
  	  break;
  
--- 696,713 ----
  
  	case DEC_5:
  #if BFD_HOST_64BIT_LONG
! 	  if (vma <= 99999)
! 	    printf ("%5ld", vma);
! 	  else
! 	    printf ("%#lx", vma);
  #else
  	  if (_bfd_int64_high (vma))
  	    /* ugg */
  	    printf ("++%ld", _bfd_int64_low (vma));
! 	  else if (vma <= 99999)
  	    printf ("%5ld", _bfd_int64_low (vma));
+ 	  else
+ 	    printf ("%#lx", _bfd_int64_low (vma));
  #endif
  	  break;
  
        


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