To optimize out calls to undefined functions in PBL at compile-time instead of link time, let's define stubs for the functions that are referenced in obj-pbl-y files, but inside function sections that are ultimately unreferenced. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- include/stdio.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/include/stdio.h b/include/stdio.h index 4edadf5c16be..03cd3d281890 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -17,12 +17,32 @@ int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); int vsprintf(char *buf, const char *fmt, va_list args); +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); + +#if IN_PROPER || defined(CONFIG_PBL_CONSOLE) char *basprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); int asprintf(char **strp, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); char *bvasprintf(const char *fmt, va_list ap); int vasprintf(char **strp, const char *fmt, va_list ap); -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); -int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); +#else +static inline char *basprintf(const char *fmt, ...) +{ + return NULL; +} +static inline int asprintf(char **strp, const char *fmt, ...) +{ + return -ENOMEM; +} +static inline char *bvasprintf(const char *fmt, va_list ap) +{ + return NULL; +} +static inline int vasprintf(char **strp, const char *fmt, va_list ap) +{ + return -ENOMEM; +} +#endif #ifdef CONFIG_ARCH_HAS_CTRLC int arch_ctrlc(void); -- 2.39.5