Subject: Re: gcc -fPIC/-fpic and 'const'
To: =?ISO-8859-1?Q?Jarom=EDr_Dolecek?= <firstname.lastname@example.org>
From: Todd Vierling <email@example.com>
Date: 03/01/2001 17:26:04
On Thu, 1 Mar 2001, Jaromír Dolecek wrote:
: Similarily, if I compare e.g. errlist.so and errlist.o from
: libc build (i386), I get:
: text data bss dec hex filename
: 2428 0 0 2428 97c errlist.o
: 2108 320 0 2428 97c errlist.so
The const data here *is* in the text segment; it's all const data, so the
presence of 2108 bytes in text there should key you in.
The difference here is that errlist.c also contains an array of pointers,
which has to be relocated at runtime into physical addresses. Hence these
actually need to be modifiable at runtime, and are in the read-write data
segment. If you look even closer, you'll note that 320 bytes ==
sizeof(const char *) * 80, and there are 80 entries in that array. :)
-- Todd Vierling <firstname.lastname@example.org> * Wasabi NetBSD: Run with it.
-- NetBSD 1.5 now available on CD-ROM -- http://www.wasabisystems.com/