we ended up calling 0
Fixes bug #1033
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
#endif /* !SHARED */
+/* Defeat compiler optimization which assumes function addresses are never NULL */
+static __always_inline int not_null_ptr(const void *p)
+{
+ const void *q;
+ asm (""
+ : "=r" (q) /* output */
+ : "0" (p) /* input */
+ );
+ return q != 0;
+}
+
/*
* Prototypes.
*/
#ifdef __UCLIBC_HAS_LOCALE__
/* Initialize the global locale structure. */
- if (likely(_locale_init!=NULL))
+ if (likely(not_null_ptr(_locale_init)))
_locale_init();
#endif
* Thus we get a nice size savings because the stdio functions
* won't be pulled into the final static binary unless used.
*/
- if (likely(_stdio_init != NULL))
+ if (likely(not_null_ptr(_stdio_init)))
_stdio_init();
}