This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: section placement q
Andrew Morton wrote:
>
> > > void __attribute__ ((__section__ (".some_section"))) foo(void)
> > > {
> > > bar("hello, world\n");
> > > }
> > >
> > > The string goes into .rodata. We'd like it in <where?>
> >
> > i don't know where you'd like to have it, but it _must_ default to
> > .rodata (for obvious reasons -- the pointer might stick around)
>
> Sure, the default shouldn't be altered.
>
> What would be ideal is the ability to alter the default for a particular
> scope:
>
> void __attribute__ ( (__section__ (".some_section")),
> (__strings__(".some_string_section")))
> foo(void)
> {
> bar("hello");
> }
>
> So during the scope of the __strings__ attribute, the old (".rodata")
> section identifier is stacked and replaced with ".some_string_section".
But would this really solve the problem? Yes, it could reduce the
ugliness a bit, but is potentialy dangerous. As you still have to
make sure no "local" strings are used later, i'm not convinced this
is actually an improvement over the conservative approach.
> > Saved a few dozen kb, but was
> > ugly enough that i decided it wasn't worth maintaining.
>
> mm.. A "few dozen kb" is fairly attractive, actually.
yep, that's why i did it. Most of it are strings that never get
accessed (fatal err msgs etc) or are only used once, but aren't
freed wasting precious unswappable memory.
I've put up the patch vs 2.3.40pre1 at
http://www.geocities.com/SiliconValley/Heights/6494/sw/patch-initstr.gz
It really is ugly as hell, but i'm not sure it can be made cleaner by
any compiler extension (flipping the default could be too dangerous)