cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE Linker Error on changing from GCC 9 to GCC 10

Leopold N.
Associate II

Hello,

when i select the newer Toolchain "GNU Tools for STM32 (10.3-2021.10)" instead of the one that worked until now "GNU Tools for STM32 (9-2020-q2-update) i get some Linker Errors. The exact same Code builds fine on the older Toolchain but throws those Errors on the newer one.

Console Output:

23:30:06 **** Incremental Build of configuration Debug for project STM32F030F4P6 ****

make -j24 all

arm-none-eabi-g++ -o "STM32F030F4P6.elf" @"objects.list" -lstm32f030f4p6 -lcmos0 -mcpu=cortex-m0 -T"C:\Users\Admin\Desktop\Projekte\Embedded\Dev Board STM32F030F4P6\Software\STM32F030F4P6\STM32F030F4P6 Dev Board Linker Script.ld" --specs=nosys.specs -Wl,-Map="STM32F030F4P6.map" -Wl,--gc-sections -nostartfiles -nodefaultlibs -nostdlib -static -L"C:\Users\Admin\Desktop\Projekte\Embedded\DeviceDriver\STM32F030F4P6\API\Lib" -L"C:\Users\Admin\Desktop\Projekte\Embedded\CMOS\API\Lib" --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group

c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.9.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libc_nano.a(lib_a-abort.o): in function `abort':

abort.c:(.text.abort+0xa): undefined reference to `_exit'

c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.9.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libc_nano.a(lib_a-signalr.o): in function `_kill_r':

signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'

c:\st\stm32cubeide_1.9.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: c:/st/stm32cubeide_1.9.0/stm32cubeide/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp\libc_nano.a(lib_a-signalr.o): in function `_getpid_r':

signalr.c:(.text._getpid_r+0x2): undefined reference to `_getpid'

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:77: STM32F030F4P6.elf] Error 1

"make -j24 all" terminated with exit code 2. Build might be incomplete.

23:30:06 Build Failed. 7 errors, 0 warnings. (took 213ms)

I dont want to use Standard Libraries for linking or Startup Code because the Code is baremetal. How can i fix this?

1 ACCEPTED SOLUTION

Accepted Solutions
Leopold N.
Associate II

Solution: Just overwrite those Functions with own Implementations:

int _kill(int, int)
	{
		return(-1);
	}
 
int _getpid()
	{
		return(1);
	}
 
void _exit(int)
	{
		while(1)
		{
			
		}
	}

View solution in original post

4 REPLIES 4
alister
Lead

>but throws those Errors on the newer one.

Either code you've written or code you're linking is calling abort, _kill_r and _getpid_r, and the linker is unable to resolve functions they're calling.

You've changed the toolchain, its libraries are different

>I dont want to use Standard Libraries for linking or Startup Code because the Code is baremetal. How can i fix this?

This preconceived idea is incorrect. Baremetal has nothing to do with it.

Do you want fastest code, smallest code or something else? You've got to decide how much time you have and what you want.

You could remove the missing functions by either not calling them or the functions that call them.

You could code the missing functions or replace the functions that call them.

You could change the libraries. Generally it's least effort to use the libraries that come with the toolchain.

Leopold N.
Associate II

The Problem is, that i dont even know which function calls them. The whole Code including the manual linked Libraries -lcmos0 and -lstm32f030f4p6 are written by myself and i never called explicitly a Function that i havent written on my own. The missing functions are located in a standard library from the toolchain i guess but i dont know why they are needed (who is calling them where?).

I just wonder why it worked in GCC 9 and now it doesnt anymore.

Changing the toolchain requires experience. If you've solved no problem, what's the experience?

Enable generating map and list files and study those.

Find the standard library's source code and study that.

Search engines are your friend.

Leopold N.
Associate II

Solution: Just overwrite those Functions with own Implementations:

int _kill(int, int)
	{
		return(-1);
	}
 
int _getpid()
	{
		return(1);
	}
 
void _exit(int)
	{
		while(1)
		{
			
		}
	}