On 2007-03-27, Grant Edwards <[email protected]> wrote:
> OK, I've re-written unique_section() in msp430.c.
>
> Now -fdata-sections works correctly with initialized variables
> (and they do get garbage collected properly by the linker).
> However, I can't figure out how to get uninitialized variables
> to work right. Here's the new unique_section() code:
[...]
> I've verified that the ".bss." path is taken for uninitialized
> variables, but it just doesn't work the same as the other three
> paths. The above code makes -fdata-sections work correctly for
> uinitialized variables (both const and regular), but
> uninitialized ones are still in a single .bss section.
I've now got uninitialized variables being correctly
garbage-collected also (which required a change to the linker
script templates in binutils), but there are two more things I
want to fix.
1) As long as I have to touch the linker script templates, I
might as well add the proper KEEP() directives for init code
and interrupt vectors, right?
2) Currently, variables are placed in RAM in the order they
happen to occur in the source file. This means that there
can be a significan number of wasted bytes do to alignment
requirements. When you've only got 256 bytes of RAM, you
can't really afford to waste any of them. ;)
I seem to recall that there's something you can do in the
linker script to fix that: you can tell the linker to sort
objects by size in order to minimize padding wastage. But I
can't quite remember now to do that. I'll try to find a
example of that tomorrow...
--
Grant Edwards grante Yow! I'm ANN LANDERS!! I
at can SHOPLIFT!!
visi.com