EmbDev.net

Forum: ARM programming with GCC/GNU tools newli link problem


von Fan Z. (zf1998)


Rate this post
useful
not useful
Hi,

I am new to both gnuarm and newlib. I download the toolchain provided by
Darrik Spaude from gnuarm.org, and I am trying to build my
hello_world.c, but I got the following error:

/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-freer.o):
In function `_malloc_trim_r':
../../../.././newlib/libc/stdlib/mallocr.c:3326: undefined reference to
`_sbrk_r'
../../../.././newlib/libc/stdlib/mallocr.c:3335: undefined reference to
`_sbrk_r'
../../../.././newlib/libc/stdlib/mallocr.c:3340: undefined reference to
`_sbrk_r'
/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-makebuf.o):
In function `__smakebuf':
../../../.././newlib/libc/stdio/makebuf.c:54: undefined reference to
`_fstat_r'
/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-mallocr.o):
In function `malloc_extend_top':
../../../.././newlib/libc/stdlib/mallocr.c:2160: undefined reference to
`_sbrk_r'
../../../.././newlib/libc/stdlib/mallocr.c:2197: undefined reference to
`_sbrk_r'
/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-stdio.o):
In function `__sclose':
../../../.././newlib/libc/stdio/stdio.c:120: undefined reference to
`_close_r'
/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-stdio.o):
In function `__sseek':
../../../.././newlib/libc/stdio/stdio.c:103: undefined reference to
`_lseek_r'
/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-stdio.o):
In function `__swrite':
../../../.././newlib/libc/stdio/stdio.c:76: undefined reference to
`_lseek_r'
../../../.././newlib/libc/stdio/stdio.c:84: undefined reference to
`_write_r'
/usr/local/arm/bin/../lib/gcc/arm-elf/4.2.0/../../../../arm-elf/lib/libc 
.a(lib_a-stdio.o):
In function `__sread':
../../../.././newlib/libc/stdio/stdio.c:47: undefined reference to
`_read_r'

I searched the web, and I think this is caused by missing stub
implementations. My host machine is Intel MAC and the target is
At91sam9260 based board running linux 2.6.22.1. I found that in the
toolchain it already contians a libgloss-linux.a, then I tried to
compile with -lgloss-linux,but I got the same error.

Is there an available newlib stub implementation for arm-linux? Or maybe
I misused the libgloss-linux.a?

I checked with: arm-elf-nm libgloss-linux.a|grep sbrk
000000ac T _sbrk
000000ac T sbrk
it seems the _sbrk_r is missing.

von Darrik S. (dspaude)


Rate this post
useful
not useful
Thanks for posting here, Fan. I was going to do the same.

Any suggestions are greatly appreciated. I have a request to GNUARM
about the same issue and will post back here if I find any solution. If
I find a solution, then I will also generate a new toolchain.

Darrik

von Fan Z. (zf1998)


Rate this post
useful
not useful
Darrik Spaude wrote:
> Thanks for posting here, Fan. I was going to do the same.
>
> Any suggestions are greatly appreciated. I have a request to GNUARM
> about the same issue and will post back here if I find any solution. If
> I find a solution, then I will also generate a new toolchain.
>
> Darrik

Thanks for the quick reply. I really appreciate for your contribution
about GNUARM. :)

von Darrik S. (dspaude)


Rate this post
useful
not useful
Just to follow up, the Mac versions of the toolchain I built include
reentrancy, so the undefined references in question need to be defined
by the source being compiled and linked. For example, in an embedded
system a printf() could mean output is sent to a UART or USB or some
other device, so the implementation needs to define which device is the
default target for a write.

Thanks goes to Pablo at GNU ARM for his input.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.