cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Linker exported symbol in an application?

Priyadarshini Solanki
Associate II

I am using #[STM32 MCUs]​ #Cortex-m0​ . In linker file we have symbol: __ICFEDIT_region_ROM_start__ 

How we can use this symbol in application ?

I have assigned &__ICFEDIT_region_ROM_start__ to Pointer.

i.e int *p = &__ICFEDIT_region_ROM_start__

now using p we can fetch the data define by symbol __ICFEDIT_region_ROM_start__.

I want that data to be in macro definition. How i can use?

#define ROM_address   __ICFEDIT_region_ROM_start__ ( ROM_address holds wrong data )

1 ACCEPTED SOLUTION

Accepted Solutions

Try this way:

extern uint32_t __ICFEDIT_region_ROM_start__;
 
#define ROM_address ((void *)(&__ICFEDIT_region_ROM_start__))

Or change (void *) to whatever pointer type you require. And turn off compiler's strict aliasing rules to be safe (-fno-strict-aliasing option in GCC)

View solution in original post

2 REPLIES 2

Try this way:

extern uint32_t __ICFEDIT_region_ROM_start__;
 
#define ROM_address ((void *)(&__ICFEDIT_region_ROM_start__))

Or change (void *) to whatever pointer type you require. And turn off compiler's strict aliasing rules to be safe (-fno-strict-aliasing option in GCC)

Thanks for the response.

It's perfectly working as expected.