[U-Boot] [PATCH v3] Switch from archive libraries to partial linking

Sebastien Carlier
2010-11-19T08:04:19Z

On 2010-11-19 07:36:05, Albert ARIBAUD wrote:
>
> Le 18/11/2010 23:33, Wolfgang Denk a ?crit :
> >
> > I see two possible reasons: 1) whay you describe is a new feature in
> > binutils 2.20; I'm currently using 2.17.50 (with ELDk 4.2); or 2) the
> > linker does not realize it because it's actually different file names:
> > for example, vsprintf() gets included in the linker script directly
> > through lib/vsprintf.o, and throught he command line as
> > lib/libgeneric.o ==> two different file names.
>
> Most probably 2); mentioning a file in the linker script either with or
> without mentioning it on the command line has certainly been done for
> some time, so I doubt the feature is new; and certainly the doc is about
> files, not symbols in different files.

Sounds right, reason 2) completely makes sense.

> And, to get back to possible solutions, I don't know that the linker can
> map selected symbols onto specific regions; it can only place whole
> object files.

Could we place the object files in distinct sections, and then map these
sections into specific regions?

> The simplest, though not cleanest, way I can think of is to put
> conditionals to not compile vsprintf() in lib/generic, and set those
> conditions from the board config file -- and same for anything else.
> Ugly, but it will work.

Perhaps an even simpler solution would be to go back to archive
libraries and use ld --whole-archives. It would leave object names
intact and thus avoid double-inclusions.

> A second solution, a bit more intrusive, would be to split lib/generic
> in two files; a "small" one which could be mapped in the small area, and
> the rest, which would map with the rest of the image.

Perhaps section declarations could be used to achieve this without
having to split the files? It seems challenging to come up with a way
to do this to optimally fill a given sector, though.

Regards,
--
Sebastien