This is the mail archive of the
mailing list for the eCos project.
Re: [ECOS] raw output to serial port and dataflash + legacy API questions
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Evgeniy Dushistov <dushistov at mail dot ru>
- Cc: Dave Milter <davemilter at gmail dot com>, ecos-discuss at ecos dot sourceware dot org, ecos-devel at ecos dot sourceware dot org
- Date: Mon, 11 May 2009 21:03:53 +0200
- Subject: Re: [ECOS] raw output to serial port and dataflash + legacy API questions
- References: <firstname.lastname@example.org> <20090511172638.GA27330@rain> <20090511175743.GA4940@lunn.ch> <20090511181726.GA29238@rain>
> > If something is not referenced, the linker will throw it away. It is
> > unwanted bloat.
> The variable that is not referenced is marked as __attribute__((used)).
I _think_ this just stops the warning. The symbol itself is not
changed. This attribute is most often used for parameters passed to a
function where for backward compatibility etc, you don't reference one
of the parameters passed in.
> So compiler doesn't inform linker that there is no need to throw it
I don't think so.
> And as you see, actually I not add reference to variable in
> workaround, I add function to which add reference.
> So reference count to flash driver descriptions hasn't changed,
> but linker do not remove it.
This might suggest you are not using --function-sections and
--data-sections. Using these options the compiler puts each function
and variable into its own section and so allows the linker to do finer
grain garbage discard. Without these options it can only throw away
complete files when all symbols in a file are not used. With these
options it can throw away individual unused functions and variables.