|
From: Danny S. <dan...@cl...> - 2003-10-05 09:42:26
|
GCC 3.4 stage 2 closes in about 11 days.
I have a patch that changes the way GCC handles initialized
data consts. Currently it puts these in .text -- most of the time.
CC1PLUS put artificial data consts--vtables and such--into named
.rdata$foo sections. Likewise, -fdata-sections puts initialized consts
into .rdata$foo sections. But in neither of these cases does it set
the section flags correctly. Ordinary "const int foo = 3;' goes
into text. A bit inconsistent
The patch fixes the way gcc handles named .rdata$ sections and also
tells gcc to put userland data consts into .rdata too. Literal strings
(as in
printf ("Hello world\n") ) also end up in rdata.
MS compiler uses the .rdata section for initialized data consts (just
check out the section headers in exes and dll in system32 folder).
I don't have any evidence that it improves performance. In some case it
may lose performamce because it adds another section just for a few data
symbols.
One place where it would have an advantage is when linking to dll's
without an import lib. Having data constants in rdata rather than text
makes it easy to tell if a symbol is a function or variable.
Bootstrap and regtests of gcc show no new failures. Although, until
recently,
there was a bug with the way gas handles 'r' section flag, the patched
gcc
is still compatible with older gas versions.
Do we (mingw and cygwin - I assume Chris is listening) want this for
gcc-3.4? Or should I wait for 3.5 to submit patch.
Danny
|