Keil -> GNU porting linker errors

Guest #1171163
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
Admin #1171164
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.
Guest #1171165
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

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.