EmbDev.net

Forum: ARM programming with GCC/GNU tools Keil -> GNU porting linker errors


Author: Randall Aiken (Guest)
Posted on:

Rate this post
0 useful
not useful
I'm porting some existing functional Keil code over to the GNU compiler,
and I'm running into some odd linker errors.  The code compiles fine,
but I get the linker errors listed below.  They look like they refer to
library functions, so I suspect I may not have all the "#include" files
I need.  Any ideas?

Thanks,

Randall Aiken


Linker error output:

Linking: moat.elf
arm-elf-gcc  -mcpu=arm7tdmi  -I. -gdwarf-2 -DROM_RUN  -Os -Wall
-Wcast-align -Wcast-qual -Wimplicit  -Wpointer-arith -Wswitch
-Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=crt0.lst
-MD -MP -MF .dep/moat.elf.d crt0.o    main.o CLI.o I2C.o ISR.o Serial.o
SPI.o     --output moat.elf -nostartfiles -Wl,-Map=moat.map,--cref -lc
-lm -lc -lgcc -TLPC2124-ROM.ld
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(fr 
eer.o):
In function `_malloc_trim_r':mallocr.c:(.text+0x48): undefined reference
to `_sbrk_r'
:mallocr.c:(.text+0x64): undefined reference to `_sbrk_r'
:mallocr.c:(.text+0x84): undefined reference to `_sbrk_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(ma 
kebuf.o):
In function `__smakebuf':makebuf.c:(.text+0x3c): undefined reference to
`_fstat_r'
:makebuf.c:(.text+0x110): undefined reference to `isatty'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(ma 
llocr.o):
In function `_malloc_r':mallocr.c:(.text+0x424): undefined reference to
`_sbrk_r'
:mallocr.c:(.text+0x4cc): undefined reference to `_sbrk_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__sclose':stdio.c:(.text+0xc): undefined reference to
`_close_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__sseek':stdio.c:(.text+0x30): undefined reference to
`_lseek_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__swrite':stdio.c:(.text+0x84): undefined reference to
`_lseek_r'
:stdio.c:(.text+0xac): undefined reference to `_write_r'
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(st 
dio.o):
In function `__sread':stdio.c:(.text+0xd0): undefined reference to
`_read_r'
collect2: ld returned 1 exit status
Make: *** [moat.elf] Error 1

Author: Andreas Schwarz (andreas) (Admin) Flattr this
Posted on:

Rate this post
0 useful
not useful
Randall Aiken wrote:
> c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib\libc.a(fr eer.o):
> In function `_malloc_trim_r':mallocr.c:(.text+0x48): undefined reference
> to `_sbrk_r'

You need to provide your own implementation of the Newlib stubs (_*_r).
See syscalls.c in the example projects.

Author: Randall Aiken (Guest)
Posted on:

Rate this post
0 useful
not useful
Andreas S. wrote:

> You need to provide your own implementation of the Newlib stubs (_*_r).
> See syscalls.c in the example projects.

Thanks!  I've got it all working now.  I had to modify the syscalls
examples to work with my UART character read/writes, but that wasn't too
difficult.

Randall Aiken

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.