From 3dbaad0a1f27b96462541e1189efe37ffa913e9a Mon Sep 17 00:00:00 2001 From: Albert Ou Date: Tue, 13 Dec 2016 15:05:19 -0800 Subject: Refactor libc stubs into libwrap The --wrap feature of GNU ld supports a cleaner framework for linking in alternative implementations of libc functions without cpp hacks. Place wrappers in separate object files to reduce static code size. --- bsp/libwrap/stdlib/malloc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bsp/libwrap/stdlib/malloc.c (limited to 'bsp/libwrap/stdlib') diff --git a/bsp/libwrap/stdlib/malloc.c b/bsp/libwrap/stdlib/malloc.c new file mode 100644 index 0000000..8f4f432 --- /dev/null +++ b/bsp/libwrap/stdlib/malloc.c @@ -0,0 +1,17 @@ +/* See LICENSE for license details. */ + +/* These functions are intended for embedded RV32 systems and are + obviously incorrect in general. */ + +void* __wrap_malloc(unsigned long sz) +{ + extern void* sbrk(long); + void* res = sbrk(sz); + if ((long)res == -1) + return 0; + return res; +} + +void __wrap_free(void* ptr) +{ +} -- cgit v1.2.3