Link error about sbrk
loody
miloody@gmail.com
Mon Nov 16 22:12:00 GMT 2009
Dear all:
I cross-compile newlib as mips target, but when I link the libraries I
build in libgloss, I get the error as below:
# make TOOLCHAIN=mipsel-unknown-elf-
mipsel-unknown-elf-ld -T ./link.xn -o TestCode.elf -Map TestCode.map
--oformat elf32-littlemips init.o reset.o atexit.o -static -nostdlib
-L/media/sdb1/newlib-1.17.0/mipsel/libgloss/libnosys
-L/media/sdb1/newlib-1.17.0/mipsel/libgloss/mips/libidt.a
-L/media/sdb1/newlib-1.17.0/mipsel/newlib -lnosys -lc
/media/sdb1/newlib-1.17.0/mipsel/newlib/libc.a(lib_a-sbrkr.o): In
function `_sbrk_r':
(.text+0x14): undefined reference to `sbrk'
/media/sdb1/newlib-1.17.0/mipsel/newlib/libc.a(lib_a-sbrkr.o): In
function `_sbrk_r':
(.text+0x14): relocation truncated to fit: R_MIPS_26 against `sbrk'
make: *** [TestCode.elf] Error 1
#
My questions are:
1. take mips for example, why we have to build some many different libraries as
libcfe.a
libidt.a
liblsi.a
libnullmon.a
libpmon.a
instead of build a bare one?
( all of them are just different combinations of the .o files)
if we ar all .o files as one library, linker will link what we need
automatically, right?
2. the files I need to modify, system calls that act as 'glue' between
newlib and my OS, are all located at libgloss/mips, right? If so, I
have checked that sbrk is located at syscalls.c and it is ared at
libidt.a, but why linker still complain he cannot find the sbrk? did I
miss something?
appreciate your help,
miloody
More information about the Newlib
mailing list