libnosys.a, the FPU, and missing _exit/_kill etc

Asked by Kenny Koller on 2014-04-26

Hi,

I'm curious why there are fpu and non-fpu versions of libnosys.a. If I am using a Cortex-M4F (STM32F407) what is the proper way to build using the FPU? Related to this I am trying to solve the dreaded link errors related to the missing system calls (_exit, _kill etc). I'm using C++ and the linker does not seem to resolve these symbols with libnosys.a.

Ultimately I may wish to use printf() but if I do I will use semihosting to do so.

I'm porting a fairly involved project from IAR on Windows to GCC on OSX.

Thanks,

Kenny

$ find ~/Development -name libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv6-m/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7-ar/thumb/fpu/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7-ar/thumb/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7-ar/thumb/softfp/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7-m/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7e-m/fpu/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7e-m/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7e-m/softfp/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/fpu/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/libnosys.a
/Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/thumb/libnosys.a

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Joey Ye
Solved:
2014-05-04
Last query:
2014-05-04
Last reply:
2014-05-04
Joey Ye (jinyun-ye) said : #1

Kenny,

The way that GCC multilib works is that each architecture/ABI variants have their own copy of all libraries, regardless of the actual usage of floating point.

Although libnosys might not use floating point, it has to be built to different copies and put into corresponding directories.

Hope it answers your question.

Joey

Kenny Koller (kenny-koller) said : #2

Thanks Joey.

The second part of my question is related to linking in the stubbed syscalls that I assumed were in libnosys.a. I've seen a number of people ask about this with no resolution. I've only seen suggestions to stub the calls out.

I tried to link a simple empty main() and it cannot resolve _exit but objdump seems to suggest that it exists. Please see below.

Kenny

arm-none-eabi-g++ -o Faircharge-Flash.elf -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T GCC/Flash.ld Build/Application/Main.o -lnosys
/Volumes/Development/Resource/GCC.4.8.2013.Q4/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol Reset_Handler; defaulting to 0000000008000000
/Volumes/Development/Resource/GCC.4.8.2013.Q4/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/lib/armv7e-m/fpu/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x16): undefined reference to `_exit'

$ arm-none-eabi-objdump -t /Users/Kenny/Development/GCC.4.8.2013.Q4/arm-none-eabi/lib/armv7e-m/fpu/libnosys.a | grep _exit
_exit.o: file format elf32-littlearm
00000000 l df *ABS* 00000000 _exit.c
00000000 l d .text._exit 00000000 .text._exit
00000000 g F .text._exit 00000002 _exit

Best Joey Ye (jinyun-ye) said : #3

Kenny,

Missing _exit is kind of annoying issue when linker handles static library. It could be solved by adding a number of -lc before -lnosys, which is tedious.

Since 4.8, we recommend -specs=nosys.specs to solve this issue ultimately. Namely, you can remove -lnosys and add -spces=nosys.specs.

Please have a try.

Thanks,
Joey

Kenny Koller (kenny-koller) said : #4

Thanks Joey Ye, that solved my question.

Joey Ye (jinyun-ye) said : #5

Missing _exit is kind of annoying issue when linker handles static library. It could be solved by adding a number of -lc before -lnosys, which is tedious.

Since 4.8, we recommend -specs=nosys.specs to solve this issue ultimately. Namely, you can remove -lnosys and add -spces=nosys.specs.
FAQ #2519: “Missing _exit/_kill”.

This did not work for me, the problem persists. I had to add this to my linker script instead:
GROUP (libnosys.a)