Trying to build newlib with -DMALLOC_PROVIDED
Stephan Mühlstrasser
stephan.muehlstrasser@web.de
Wed Apr 19 18:15:00 GMT 2017
Hi,
I'm making my first attempt to build newlib for an ARM bare-metal
environment from the current master branch. malloc(), free() etc. come
from the bare-metal library, therefore I'm trying to build newlib with
-DMALLOC_PROVIDED, using other configurations in newlib/configure.host
as a blueprint.
I made this modification in newlib/configure.host for my target:
arm*-*-circleraspi0)
syscall_dir=syscalls
newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
;;
I can successfully build newlib, and when I try to link a test
application that just calls printf() I get the following unresolved symbols:
E:/Users/stm/Documents/GIT/newlib-raspi0/arm-none-circleraspi0/lib/libc.a(lib_a-vfprintf.o):
In function `_vfprintf_r':
vfprintf.c:(.text+0x1fcc): undefined reference to `_free_r'
vfprintf.c:(.text+0x215c): undefined reference to `_free_r'
E:/Users/stm/Documents/GIT/newlib-raspi0/arm-none-circleraspi0/lib/libc.a(lib_a-wsetup.o):
In function `__swsetup_r':
wsetup.c:(.text+0xcc): undefined reference to `_free_r'
E:/Users/stm/Documents/GIT/newlib-raspi0/arm-none-circleraspi0/lib/libc.a(lib_a-fflush.o):
In function `__sflush_r':
fflush.c:(.text+0x24c): undefined reference to `_free_r'
E:/Users/stm/Documents/GIT/newlib-raspi0/arm-none-circleraspi0/lib/libc.a(lib_a-findfp.o):
In function `__sfmoreglue':
findfp.c:(.text+0x130): undefined reference to `_malloc_r'
and also
E:/Users/stm/Documents/GIT/newlib-raspi0/arm-none-circleraspi0/lib/libc.a(lib_a-syscalls.o):
In function `_sbrk':
syscalls.c:(.text+0x984): undefined reference to `end'
I read various tutorials about porting newlib, and they suggest that it
should be possible to build without the reentrant versions of the memory
management functions. But I don't understand how that is supposed to
work in the source. For example in malloc.h:
extern _PTR malloc _PARAMS ((size_t));
#ifdef __CYGWIN__
#undef _malloc_r
#define _malloc_r(r, s) malloc (s)
#else
extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t));
#endif
This looks like that only for __CYGWIN__ the reentrant variants are
defined away.
How can I build newlib for an environment that provides the memory
management functions that are already thread-safe?
Thanks in advance for any suggestions!
Best regards
Stephan
More information about the Newlib
mailing list