@
raptium 是在.rodata段中, gcc 4.6
-----
[lithium@ubuntu:~/code/gcc/test]
> cat t.c
#include <stdio.h>
char* t() {
char* p = "this is a test prog";
return p;
}
int main(int argc, char *argv[]) {
char* p = t();
printf("Addr p: %x\n", p);
return 0;
}
[lithium@ubuntu:~/code/gcc/test]
> ./a.out
Addr p: 40063c
[lithium@ubuntu:~/code/gcc/test]
> objdump -hs a.out | grep ".rodata" -3
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .fini 0000000e 0000000000400628 0000000000400628 00000628 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .rodata 00000024 0000000000400638 0000000000400638 00000638 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .eh_frame_hdr 00000034 000000000040065c 000000000040065c 0000065c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
--
400620 83c4085b 5dc39090 ...[]...
Contents of section .fini:
400628 4883ec08 e82ffeff ff4883c4 08c3 H..../...H....
Contents of section .rodata:
400638 01000200 74686973 20697320 61207465 ....this is a te
400648 73742070 726f6700 41646472 20703a20 st prog.Addr p:
400658 25780a00 %x..