0

While developing code for STM32 MCU, I'm placing some structures into custom memory section:

struct MyStruct structName;

__attribute__((__section__("my_section"))) __attribute__((__used__)) const struct MyStruct *const mystruct1 = &x

Linker generated additional symbols, __start_my_section_ and __stop_my_section_. After compilation while debugging MCU, I see that __start_my_section_ contains a valid value, e.g. 0x20000468 but __stop_my_section_ is incorrect, equal to 0.

In the .map file, the __stop_my_section_ also contains a valid value:

                0x20000470                __stop_my_section_ = .

What's wrong? I haven't added anything to linker script, linker automatically created that section and placed in bss.

VIPPER
  • 326
  • 4
  • 24
  • `mystruct1 = &x` you need to show that the load address is in the flash and run address in ram. Then you need to write some startup code to initialize this variable. – 0___________ Jan 09 '22 at 13:37
  • `contains a valid value` How do you check it? `__stop_my_section_` It's not `__stop_my_section_` it's `__stop_my_section`. – KamilCuk Jan 14 '22 at 23:27

1 Answers1

0

You need to use Address Operator (&) to get the start and stop address of "my_section": &__start_my_section and &__stop_my_section respectively

kover
  • 155
  • 1
  • 6