From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Carlier Date: Fri, 05 Nov 2010 13:40:59 +0100 Subject: [U-Boot] Weak symbols: request for comments In-Reply-To: <20101105121407.654B412A81E2@gemini.denx.de> References: <4CD3DEFC.7010104@gmail.com> <20101105121407.654B412A81E2@gemini.denx.de> Message-ID: <4CD3FB5B.7060300@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Wolfgang, On 11/05/2010 01:14 PM, Wolfgang Denk wrote: >> 1.1) Stop using weak symbols; use pre-initialized function pointers >> instead (possibly grouped in a struct, for cleanliness). >> This has the benefit of offering a clear interface and being >> independent of toolchain details. >> > And where would the "pre-initialized function pointers" come from? > Without adding a hell of #ifdef's ? > It would not be pretty, and, as pointed out by Joakim Tjernlund, it would not work before relocation. >> 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 realy practicable, as the code is distributed all over the place, > and should remain where it logically belongs. > Each module could have its own "defaults.c" for overridable implementations, and the build system could collect all of these. It is not a pain-free solution. >> 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. >> > Close. I think stop using a library archives and do what Linux does > instead is the way to go. > Partial linking with ld -r ? That does seem like a fairly simple change. Regards, Sebastien Carlier