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/linux/string.h | 7 +++++++ include/malloc.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index 3b8775c9a57d..38077da95d13 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -161,7 +161,14 @@ static inline const char *kbasename(const char *path) } #endif +#ifndef __PBL__ void *memdup(const void *, size_t); +#else +static inline void *memdup(const void *buf, size_t size) +{ + return NULL; +} +#endif #define memdup_array(arr, count) memdup(arr, array_size(count, sizeof(*arr))); diff --git a/include/malloc.h b/include/malloc.h index fc0c94855e05..682f724fb4fa 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -5,6 +5,7 @@ #include <linux/compiler.h> #include <types.h> +#ifndef __PBL__ void *malloc(size_t) __alloc_size(1); size_t malloc_usable_size(void *); void free(void *); @@ -16,5 +17,41 @@ void malloc_stats(void); void *sbrk(ptrdiff_t increment); int mem_malloc_is_initialized(void); +#else +static inline void *malloc(size_t nbytes) +{ + return NULL; +} +static inline void free(void *buf) +{ +} +static inline void free_sensitive(void *buf) +{ +} +static inline void *realloc(void *orig, size_t nbytes) +{ + return NULL; +} +static inline void *memalign(size_t align, size_t size) +{ + return NULL; +} +static inline void *calloc(size_t num, size_t size) +{ + return NULL; +} +static inline void malloc_stats(void) +{ +} +static inline void *sbrk(ptrdiff_t increment) +{ + return NULL; +} + +static inline int mem_malloc_is_initialized(void) +{ + return 0; +} +#endif #endif /* __MALLOC_H */ -- 2.39.5