printing scalars with objdump --debugging

Nick Clifton
Sat Jan 5 17:38:00 GMT 2008

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.

> Before I get involved with writing the configure test, I'd like to know if
> you agree that the configure test is necessary, then if so, if this patch
> will be acceptable when submitted with such test.

Yes the test is necessary.  Yes the patch would be acceptable with such a test 


More information about the Binutils mailing list