
In message f8328f7c0806122238p24054afcx5190acfda8a794c6@mail.gmail.com you wrote:
I've played around a bit more and found that if I move my function to an existing file containing functions called from elsewhere, my code gets linked in. Further research shows that a 'feature' of ld is that it won't pull in a module that only has symbols that have already been resolved, even if the previously found version is weak.
Argh...
That's evil, but given the way ld works, I think I can understand it.
IMHO, developers should be able to write board and cpu code to override weak symbols in libraries/drivers without having to worry about whether the intention was obeyed or not. ld has a switch '--whole-archive', that will pull in an entire archive, not just the modules that are referenced elsewhere with strong linkage.
Oh no. Please don;t even mention this...
I propose to wrap both the 'board/$(BOARDDIR)/lib$(BOARD).a' and 'cpu/$(CPU)/lib$(CPU).a' arguments to ld in --whole-module/--no-whole-module in order to accomplish this goal. We definitely don't want to do this across the board because image size will increase quite a bit due to unused code. I believe that the board and cpu code, though, should be mostly free of cruft. If not, it should be restructured with appropriate CONFIGs, either in Makefiles or C code.
No, please do NOT do that. This will become a PITA.
Maybe somebody has a really clever idea, but I'm afraid we might end up having to put all "strong" functions that are supposed to overwrite weak ones into separate modules that get pulled in unconditionally :-(
Best regards,
Wolfgang Denk