This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: printing scalars with objdump --debugging
- From: "H.J. Lu" <hjl at lucon dot org>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: Greg McGary <gkm at work dot mcgary dot org>, binutils at sourceware dot org, greg at mcgary dot org
- Date: Fri, 4 Jan 2008 09:22:17 -0800
- Subject: Re: printing scalars with objdump --debugging
- References: <E1J5SKv-0003HK-Hb@work.mcgary.org> <477E3CC0.3030702@redhat.com>
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.