
Hello All,
All instances have been replaced by empty functions with an alias. e.g. void __do_something (args) {} do_something(args) __atttribute__((weak, alias("__do_something")));
Good to know. This doc also helps: http://docs.sun.com/app/docs/doc/817-1984/chapter2-11?l=en&a=view Then,
- we must try to not leave undefined weak symbols at all,
- or check the symbol before invocation for the safety in case of NULL
dereference.
My 2 cents: And here an example from the linux kernel that just does the first option:
Create a default fallback routine that can be used if there is no strong implementation: ------------------------------------------------------------------------------------------- __attribute__((weak)) unsigned long long printk_clock(void) { return sched_clock(); } ------------------------------------------------------------------------------------------- and here is an example of the strong implementation (from the ARM architecture): ------------------------------------------------------------------------------------------- unsigned long long printk_clock(void) { return (unsigned long long)(jiffies - INITIAL_JIFFIES) * (1000000000 / HZ); } -------------------------------------------------------------------------------------------
If the strong implementation is available, the weak is simply discarded during linking, if the strong is omitted, the weak is used as fallback. This is a clean, lean and mean example without complex/superfluous aliases or checks for NULL pointers. It should not get any harder than this...
Kind Regards,
Remy