2022-03-09 07:22 AM
I am using below codes. But this define not supportted
#define KeepInCompilation __root
#define KeepInCompilation __root
/* Private function prototypes -----------------------------------------------*/
int Init ();
KeepInCompilation int Write (uint32_t Address, uint32_t Size, uint8_t* buffer);
KeepInCompilation int SectorErase (uint32_t EraseStartAddress ,uint32_t EraseEndAddress);
KeepInCompilation uint64_t Verify (uint32_t MemoryAddr, uint32_t RAMBufferAddr, uint32_t Size, uint32_t missalignement);
KeepInCompilation HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
KeepInCompilation int MassErase (uint32_t Parallelism );
Solved! Go to Solution.
2023-09-21 01:17 PM - edited 2023-09-21 01:20 PM
As I said, I address this in the Linker Script, by establishing the symbols I want to retain and export.
https://github.com/cturvey/stm32extldr/blob/main/ExternalLoader.ld#L43
Whereas KeepInCompilation is a tool chain specific macro to flag to the linker, by way of the compiler, that a function is used somewhere, and thus not subject to dead-code-removal. You can check the exports/symbols with tools like objcopy or fromelf
#ifdef __ICCARM__ // IAR
#define KeepInCompilation __root
#elif __CC_ARM // MDK-ARM V5.xx
#define KeepInCompilation __attribute__((used))
#elif __clang__ // MDK-ARM V6.xx
#define KeepInCompilation __attribute__((used))
#elif TASKING // TrueStudio
#define KeepInCompilation __attribute__((used))
#elif defined(__GNUC__)
#define KeepInCompilation __attribute__((used))
#endif
ST has some specific expectations with .ELF / .STLDR object files. Typically they are not going to use main() and an entry point, there's not startup.s code to clear or move static initializations, and there's no expectation of an interrupt vector table. The StorageInfo struct has specific size, content and placement expectations too.
2023-09-22 01:57 AM
Thanks a lot.