-lgcc seemingly ignored when linking with -nostdlib
I tried to link using a freestanding environment by passing -ffreestanding, -nostdlib and -lgcc, but the -lgcc option seems to be ignored by the linker because a symbol in libgcc.a is not linked in. The following error message is emitted.
./main.c.o: In function `main':
main.c:21: undefined reference to `__aeabi_fmul'
collect2: error: ld returned 1 exit status
The linker command line is shown below.
arm-none-eabi-gcc -mcpu=cortex-m0plus -mthumb -ffreestanding -nostdlib -lgcc -Tlinker/
The program being compiled is
int main( void )
{
volatile float a = 1.10, b=2.2;
a *= b;
return 0;
}
The __aeabi_fmul function is located in libgcc.a. When linking without the -nostdlib option the map file generated by the linker has the following lines indicating that __aeabi_fmul is indeed being linked from libgcc.
Archive member included to satisfy reference by file (symbol)
/usr/bin/
.text 0x0000000000000024 0x2f8 /usr/bin/
I suspect that the -lgcc option when passed along with -nostdlib is being ignored by the linker. The compiler version is
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q3-update) 7.3.1 20180622 (release) [ARM/embedded-
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Thomas Preud'homme
- Solved:
- Last query:
- Last reply: