2025-09-09 1:56 AM - last edited on 2025-09-09 2:19 AM by mƎALLEm
MCU: STM32G474xx
IDE: VSCode
Toolchain: ARM Compiler 6 (armclang, armlink)
Question:
I'm a newcomer to using armclang and armlink for compiling and linking a project for an STM32G4 MCU. I've successfully compiled a minimal project and am trying to link it using armlink.
My scatter file is:
LR_IROM1 0x08000000 0x00080000 { ; load region size_region ER_IROM1 0x08000000 0x00080000 { ; load address = execution address *.o (.isr_vector, +First) *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) } RW_IRAM1 0x20000000 0x00020000 { ; RW data .ANY (+RW +ZI) } }
I use a startup script in GNU syntax generated from CubeMX.
The linker command I am using is: armlink --cpu=Cortex-M4.fp.sp *.o --scatter=STM32G474XX_FLASH.sct --map --info=summarysizes --load_addr_map_info --xref --callgraph --symbols --info=sizes --info=totals --info=unused --info=veneers
This setup results in the following linking errors:
Error: L6218E: Undefined symbol _sidata (referred from startup_stm32g474xx.o). Error: L6218E: Undefined symbol _sdata (referred from startup_stm32g474xx.o). Error: L6218E: Undefined symbol _edata (referred from startup_stm32g474xx.o). Error: L6218E: Undefined symbol _sbss (referred from startup_stm32g474xx.o). Error: L6218E: Undefined symbol _ebss (referred from startup_stm32g474xx.o). Error: L6218E: Undefined symbol __libc_init_array (referred from startup_stm32g474xx.o). Error: L6218E: Undefined symbol _estack (referred from startup_stm32g474xx.o).
I understand that the scatter file defines memory regions, but it seems I also need to define these specific symbols (_sidata, _sdata, _estack, etc.) for the linker. How do I properly define these symbols within the .sct file, and what is the correct way to resolve the missing __libc_init_array function?