This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Trying to build newlib with -DMALLOC_PROVIDED


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]