This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Why is a const array pointer with -fPIC mapped in ".data"?
- From: "Kazuomi Kato" <kato dot kazuomi at jp dot panasonic dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Mon, 17 May 2004 19:39:16 +0900
- Subject: Why is a const array pointer with -fPIC mapped in ".data"?
I'd like to put an array data in the section ".rodata".
I wish the array data to be unmodified so I used const type for it.
However, inspite of the data specified as const type, I found the case
that the data specified was mapped in the section ".data".
If a const pointer array is compiled with -fPIC option, const type
to the pointer is ignored and the pointer exists in the ".data".
Do you know why this is happening?
Does the -fPIC option have to do with above phenomenon?
I used the gcc v3.2.1 for ARM.
I'd like to show an example bellow.
===
"test.c"
const char const_rodata0[] = "test0";
const char const_rodata1[] = "test1";
const char const_rodata2[] = "test2";
const char const_rodata3[] = "test3";
const char const_rodata4[] = "test4";
const char const_rodata5[] = "test5";
const char * const array_const[BUF][2] = { /* specified const to array_const */
{const_rodata0, const_rodata1},
{const_rodata2, const_rodata3},
{const_rodata4, const_rodata5}
};
===
a) compiled with -fPIC option
$ arm_v4t_le-objdump -T libtest_fpic.so
00000a4c g DO .rodata 00000006 Base const_rodata1
00808ac8 g DO .data 00800000 Base array_const
/* <== exists in ".data" */
b) compliled without -fPIC option
$ arm_v4t_le-objdump -T libtest_nofpic.so
00000a84 g DO .rodata 00000006 Base const_rodata1
00000aac g DO .rodata 00800000 Base array_const
/* <== exits in ".rodata"*/
I`m not too farmiliar with gcc, but I think it looks strange.
The main thing that I want to do is that I'd like to put the unwritable value
into the section ".rodata".
What should I do for putting the array_const in ".rodata"?
Any advice would be appreciated for me,
Kazuomi Kato