On 2011-08-05, William "Chops" Westfield <[email protected]> wrote:
>
> On Aug 4, 2011, at 8:18 AM, Peter Bigot wrote:
>
>> --gc-sections should now be fixed
>>    :
>>  Use of "msp430-ar" will work as expected
>
> Hmm.  So is there a tool that will take a source module
> (with multiple functions) compiled with the relevant compiler
> options (-ffunction-sections and -fdata-sections) and produce
> a random-access library of the sort you would have gotten if
> you had broken down the source to file-per-function?

No, that's not possible in the general case [see below].

> That way you'd get benefit with or without special linker
> support...

Not really.

One of the great things about the --gc-sections method is that you can
have private data/functions that are shared by all of the public
functions in a file.  Let's say you split the file up into separate
files: one for each function (private or public) and one for each
global or file-scope variable.  The result?  You have to make all of
the functions publically visible and all of the data shared by those
fuctions publically visible.

For example, my "module" may consist of 5 publically visible
functions, 1 publically visible variable, 7 private functions, and 12
priviate variables.  Using --gc-sections I have one object file which
exposes 6 global symbols.  Splitting it up would create 25 object
files and 25 global symbols, and all of the module's private data and
fuctions are now visible to the rest of the program.

It's all about encapsulation and controlling namespace clutter.

It could be easily argued that those features should have been
provided by the C language design, and I wouldn't disagree.  But, they
weren't.  We're pretty much stuck with C, and --gc-sections goes a
long ways in patching a major hole in C's design.

Personally, I think Modula-2/3 or Ada are all probably better suited
for embedded systems use than C, but that's pretty much a moot point.
C++ tried to fix some of C's encapsulation and namespace shortcomings,
but the result was a complete dog's breakfast.

-- 
Grant Edwards               grant.b.edwards        Yow! Is it 1974?  What's
                                  at               for SUPPER?  Can I spend
                              gmail.com            my COLLEGE FUND in one
                                                   wild afternoon??


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to