EmbDev.net

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


Author: Fan Zhang (zf1998)
Posted on:

Rate this post
0 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.

Author: Darrik Spaude (dspaude)
Posted on:

Rate this post
0 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

Author: Fan Zhang (zf1998)
Posted on:

Rate this post
0 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. :)

Author: Darrik Spaude (dspaude)
Posted on:

Rate this post
0 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.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.