
Dear Reinhard,
On 11/05/2010 12:16 PM, Reinhard Meyer wrote:
1.2) Use regular (non-weak) extern declarations for overridable stuff; collect all default weak symbols into a separate library archive, to be supplied last to the linker.
Not very practical, that would require that each driver etc. would be in two parts, the main part and the "weak" part. It would no need weak functions, however.
You are entirely correct. It would be slightly inconvenient for drivers that provide overridable stuff, but no non-standard feature is needed and the benefit of static linking is preserved.
1.3) Stop using a library archive for the board specific stuff. Instead, collect and link all the object files to produce the output binary. Only Makefile changes are involved, but correct behavior depends on all boards doing the right thing.
I don't like the "weak" concept :)
It does seem like weak symbols were designed with other uses in mind, such as C++ class members defined within a class declaration, or to weak the dependencies between libraries... but not really to allow overridable definitions (what if two objects want to override the same weak symbol in different ways?).
1.4) Link u-boot into a board-agnostic dynamic library, link the board-specific stuff into an executable embedding a dynamic linker, and package all this stuff somehow.
That is too complex. Besides there are few board-agnostic parts in u-boot, many functions rely in included defines that are board specific.
Agreed.
Are there better options? Which one would you prefer to see implemented?
Yes. The old-fashioned #define CONFIG_BOARD_INIT_F and friends method. I would prefer that one. Its not beautiful but still widely used and bullet-proof.
Could you please elaborate? I have looked for things like this in the code base but I could not find what you are referring to.
Regards,
Sebastien Carlier