This is the mail archive of the binutils@sourceware.org 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: PATCH: Properly dump addend in readelf


On Sat, 2 Oct 2010, Joseph S. Myers wrote:

> Index: nm.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/nm.c,v
> retrieving revision 1.63
> diff -u -p -r1.63 nm.c
> --- nm.c	6 Jan 2010 08:48:19 -0000	1.63
> +++ nm.c	2 Oct 2010 17:02:14 -0000
> @@ -164,7 +164,11 @@ static char value_format_32bit[] = "%08l
>  #if BFD_HOST_64BIT_LONG
>  static char value_format_64bit[] = "%016lx";
>  #elif BFD_HOST_64BIT_LONG_LONG
> +#ifndef __MSVCRT__
>  static char value_format_64bit[] = "%016llx";
> +#else
> +static char value_format_64bit[] = "%016I64x";
> +#endif
>  #endif
>  static int print_width = 0;
>  static int print_radix = 16;
> @@ -284,7 +288,11 @@ set_print_radix (char *radix)
>  #if BFD_HOST_64BIT_LONG
>        value_format_64bit[5] = *radix;
>  #elif BFD_HOST_64BIT_LONG_LONG
> +#ifndef __MSVCRT__
>        value_format_64bit[6] = *radix;
> +#else
> +      value_format_64bit[7] = *radix;
> +#endif
>  #endif
>        other_format[3] = desc_format[3] = *radix;
>        break;

 Hmm, how about using:

	value_format_64bit[sizeof (value_format_64bit) - 2] = *radix;

and getting rid of the fragile #ifdef mess?  Likewise the variable might 
only be defined once, e.g.:

#if BFD_HOST_64BIT_LONG
# define NM_64BIT_FMT "%016lx"
#elif BFD_HOST_64BIT_LONG_LONG && !defined (__MSVCRT__)
# define NM_64BIT_FMT "%016llx"
#else
# define NM_64BIT_FMT "%016I64x"
#endif
static char value_format_64bit[] = NM_64BIT_FMT;

It would seem cleaner to me this way.

  Maciej


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