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: printing scalars with objdump --debugging


On Fri, Jan 04, 2008 at 02:03:44PM +0000, Nick Clifton wrote:
> Hi Greg,
>
>> "objdump --debugging" handles scalars as the type VMA.  If VMA fits
>> within a host's long, scalars are printf'ed with "%lx", "%lu" or "%ld"
>> according to type.   If VMA doesn't fit in the host's long, scalars are
>> all printed as full-width hex.  This causes trouble for scripts that
>> digest the output, since output format depends on the cross-host where
>> objdump runs, e.g. ix86 vs. x86_64.  A naive fix is this:
>
>>  	sprintf (buf, "%ld", (long) vma);
>>      }
>> +  if (sizeof (vma) <= sizeof (unsigned long long))
>> +    {
>> +      if (hexp)
>> +	sprintf (buf, "0x%llx", (unsigned long long) vma);
>> +      else if (unsignedp)
>> +	sprintf (buf, "%llu", (unsigned long long) vma);
>> +      else
>> +	sprintf (buf, "%lld", (long long) vma);
>> +    }
>
>> I'll guess this is a potential portability problem for hosts that don't
>> support %ll formats, so it should be conditional on a flag generated
>> by configure.
>
> Correct.  Have a look at readelf.c where the %llx format string is also used.
>

Can't we just use bfd_sprintf_vma/sprintf_vma?


H.J.


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