-4

I have a 64-bit binary (modfied version of sqlite, but this shouldn't mattrr):

> file /home/aromanov/IdeaProjects/sqlite/sqlite3
/home/aromanov/IdeaProjects/sqlite/sqlite3: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x39a2db352d3bc451ed621ad0588eec3008df034b, not stripped

produced with GCC 4.7.4. However, debugging code in it outputs just 8 hex digits (32 bits) for %p in format string, where I expected 16. Is this normal?

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487

1 Answers1

1

At least on linux/glibc, the %pformat specifier does not do left padding with zeroes. Thus a pointer to e.g. address 0x000000000000ffff is formatted simply as "0xffff". You can use %.16p if you want 16 digits in the output.

nos
  • 223,662
  • 58
  • 417
  • 506
  • 2
    AFAIK `"%.16p"` is gnu specific. – Jabberwocky Jan 19 '17 at 13:43
  • 1
    Looking at the POSIX specification of [`printf()`](http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html), there is nothing in the wording about the `p` conversion specification to indicate that the flags, width and precision are not allowed, though since the format it implementation-defined, the effect of those modifiers is likewise unclear. – Jonathan Leffler Jan 19 '17 at 15:26