KDS 3.0 linkage problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KDS 3.0 linkage problem

947件の閲覧回数
davidsherman
Senior Contributor I

I am seeing a strange behavior.  I was using stdlib.h, and tried to use srand and rand functions.  At the end of the link, I got an error about an undefined reference to _sbrk.  After some searching, I found if I added:

 

GROUP (

libnosys.a

)

to the bottom of ProcessorExpert.ld, it works.  Now the strange thing is that my colleague is able to build the same project without having to do that, and we both have KDS 3.0.0.  Is there a setting somewhere that adds libnosys without having to modify the linker file, and perhaps the setting has changed?  We have been using stdlib.h for other functions with no trouble, it was just when we tried to use the random functions this showed up.

ラベル(1)
0 件の賞賛
返信
1 返信

747件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi David,

Check out Erich Styger's blog:

https://mcuoneclipse.com/2015/12/13/linting-with-eclipse-and-the-gnu-arm-embedded-launchpad-compiler...

Look for:

c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/fpu\libg_s.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
makefile:72: recipe for target 'EDWB.elf' failed
make: *** [EDWB.elf] Error 1

Erich Stygeron May 25, 2016 at 16:30 said:

Add
-specs=nosys.specs
to the linker options. This will disable semihosting which I think is causing your problem.

Hi Dale,
_sbrk() is a low level memory allocation routine, and this is needed depending on what kind of library you are using. I have seen this in other places too. You might use my implementation I have used in this article:
https://mcuoneclipse.com/2015/10/28/tutorial-lwip-with-the-freertos-and-the-freescale-frdm-k64f-boar...

I hope this helps,
Erich

Regards,

David

0 件の賞賛
返信