Originally Posted by
john.c
It's storing the string data as "immediate" data.
7935471345745880427 decimal is, in hex, with associated ascii-per-byte:
Code:
6E 20 75 25 20 79 65 6B
n u % y e k
which is
"key %u n", the first part of the string, backwards, due to being stored little endian.
^ this. I think it's also important to note that if you compile with optimisation (-O1, -O2 etc, including -Os) gcc doesn't store the string as immediate data. E.g. given:
Code:
#include <stdio.h>
void foo(void)
{
const char *p1 = "key %u not found\n";
//const char p1[] = "key %u not found\n";
printf("%s (%p)\n", p1, p1);
}
void bar(void)
{
const char *p2 = "key %u not found\n";
//const char p2[] = "key %u not found\n";
printf("%s (%p)\n", p2, p2);
}
int main(void)
{
foo();
bar();
return 0;
}
Compiled with any level of optimization produces:
Code:
.text
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "key %u not found\n"