Our ARM toolchain was extracted at “/home/devlab/Desktop/helloworld/assembly/gcc-arm-none-eabi-10-2020-q4-major/” hence lets first try to add this toolchain to terminal path as,
export PATH=$PATH:/home/devlab/Desktop/helloworld/assembly/gcc-arm-none-eabi-10-2020-q4-major/bin
Now, we had written simple helloworld.c program, which we tried to compile as,
$ arm-none-eabi-gcc -o hello_world helloworld.c -g
But we got the compilation error as,
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-exit.o): in function `exit':
exit.c:(.text.exit+0x2c): undefined reference to `_exit'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-sbrkr.o): in function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-writer.o): in function `_write_r':
writer.c:(.text._write_r+0x24): undefined reference to `_write'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-closer.o): in function `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `_close'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-lseekr.o): in function `_lseek_r':
lseekr.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-readr.o): in function `_read_r':
readr.c:(.text._read_r+0x24): undefined reference to `_read'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-fstatr.o): in function `_fstat_r':
fstatr.c:(.text._fstat_r+0x1c): undefined reference to `_fstat'
TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: TOOLCHAIN/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/libg.a(lib_a-isattyr.o): in function `_isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
collect2: error: ld returned 1 exit status
Solution
This error can be solved by adding “–specs=nosys.specs” at the end of the command as,
$ arm-none-eabi-gcc -o hello_world helloworld.c -g --specs=nosys.specs
In above “nosys.specs” meaning these system calls would be ignored in normal functions but if we want to debug something in the code then we need to enable semihosting, where same above errors can be resolved by passing “–specs=rdimon.specs”