How to use Linker-generated symbols

From SEGGER Wiki
Revision as of 10:02, 23 September 2022 by Lucas (talk | contribs) (Created page with "This article will explain how to use linker generated symbol in the right way. Linker-generated symbols are actually pointers / arrays at the address instead of integers with...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article will explain how to use linker generated symbol in the right way.

Linker-generated symbols are actually pointers / arrays at the address instead of integers with the address as value.

As such its use might be a bit different and unusual.


The following code snippet shows a example of using Linker-generated symbols:

extern unsigned char __FLASH_segment_start__[];
extern unsigned char __FLASH_segment_end__[];
extern unsigned char __FLASH_segment_size__[];

extern unsigned char __FLASH_segment_used_start__[];
extern unsigned char __FLASH_segment_used_end__[];
extern unsigned char __FLASH_segment_used_size__[];

static void _Print(unsigned int Start, unsigned int End, unsigned int Size) {
 printf("  0x%.8X - 0x%.8X, size: %u\n", Start, End, Size);
}

int main(void) {
 printf("Flash:\n");
 _Print((unsigned int)__FLASH_segment_start__, (unsigned int)__FLASH_segment_end__, (unsigned int)__FLASH_segment_size__);
 printf("Used:\n");
 _Print((unsigned int)__FLASH_segment_used_start__, (unsigned int)__FLASH_segment_used_end__, (unsigned int)__FLASH_segment_used_size__);
}