EmbDev.net

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


von Randall Aiken (Guest)


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

von Andreas S. (andreas) (Admin)


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

von Randall Aiken (Guest)


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

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.