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]

Re: XCOFF 64 function address wrong?


Hi David,

But how could coff64-rs6000.c file #defining a value influence coffgen.c
(unless there's some autogeneration going on here)?

It can't. You have uncovered a bug.


Shouldn't this be
in a .h file? Is there a better test for XCOFF64/32 status than a
compile time ifdef - surely we'd want mixed capability?

Exactly. The idea was that XCOFF64 was defined in coff64-rs6000.c which then included coffcode.h. If support for 32-bit COFF targets was also being included in the bfd library then their *.c files would include coffcode.h without defining XCOFF64 and so both 32-bit and 64-bit formats would be supported.


As you have discovered this does not work with the current way that the coff_print_symbol() function is coded in coffgen.c.

Would you like to try the attached, untested patch ? It is at best a workaround since all it really does is to try to make sure that if a symbol has a 64-bit value then it is displayed as such, but at least this is better than displaying a truncated version.

Cheers
  Nick



Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.48
diff -c -3 -p -r1.48 coffgen.c
*** bfd/coffgen.c	21 Feb 2005 11:21:29 -0000	1.48
--- bfd/coffgen.c	10 Mar 2005 10:03:45 -0000
*************** coff_print_symbol (abfd, filep, symbol, 
*** 1991,2018 ****
  	  else
  	    val = combined->u.syment.n_value - (unsigned long) root;
  
- #ifndef XCOFF64
  	  fprintf (file,
! 		   "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%08lx %s",
  		   combined->u.syment.n_scnum,
  		   combined->u.syment.n_flags,
  		   combined->u.syment.n_type,
  		   combined->u.syment.n_sclass,
! 		   combined->u.syment.n_numaux,
! 		   (unsigned long) val,
! 		   symbol->name);
! #else
! 	  /* Print out the wide, 64 bit, symbol value */
! 	  fprintf (file,
! 		   "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) 0x%016llx %s",
! 		   combined->u.syment.n_scnum,
! 		   combined->u.syment.n_flags,
! 		   combined->u.syment.n_type,
! 		   combined->u.syment.n_sclass,
! 		   combined->u.syment.n_numaux,
! 		   val,
! 		   symbol->name);
! #endif
  
  	  for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
  	    {
--- 1991,2019 ----
  	  else
  	    val = combined->u.syment.n_value - (unsigned long) root;
  
  	  fprintf (file,
! 		   "(sec %2d)(fl 0x%02x)(ty %3x)(scl %3d) (nx %d) ",
  		   combined->u.syment.n_scnum,
  		   combined->u.syment.n_flags,
  		   combined->u.syment.n_type,
  		   combined->u.syment.n_sclass,
! 		   combined->u.syment.n_numaux);
! 
! 	  /* We used to test for XCOFF64 being defined here in order to
! 	     determine whether we are displaying 64-bit or 32-bit symbol
! 	     values.  But this does not work because XCOFF64 is only defined
! 	     in coff64-rs6000.c just before it includes coffcode.h.  Instead
! 	     we check the symbols's value and see if any of the top 32 bits
! 	     are set.  This is not ideal since it can lead to mixed styles
! 	     in the output, but it does at least mean that 64-bit symbols will
! 	     not be displayed in a truncated fashion.  */
! 	  if (val <= 0xFFFFFFFFULL)
! 	    fprintf (file, "0x%08lx", (unsigned long) val);
! 	  else
! 	    /* Print out the wide, 64 bit, symbol value.  */
! 	    fprintf (file, "0x%016llx", val);
! 
! 	  fprintf (file, " %s", symbol->name);
  
  	  for (aux = 0; aux < combined->u.syment.n_numaux; aux++)
  	    {

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