How to place the custom linker section in the .data section?

Hi,

I am working with nrf5340 with the Zephyr OS. I created a custom data section in a custom linker file.

.my_data_section :
{
PROVIDE(__my_data_section_start = .);
KEEP(*(.my_data_section))
PROVIDE(__my_data_section_end = .);
} > RAM AT > FLASH

I want to place "my_data_section"  under ".data" section in the final linker file. How can I do that?

Parents Reply Children
  • Both questions have different context.

    In this question, I am able to create my own data section in RAM. However, the global variables I place in this section do not have the correct initial values that I expect. This is because they should be placed under ".data" section for the compiler to recognize about correct initialization.

    In the final linker.cmd, I am expecting it to appear like the following (I just manually added this line for explanation purpose).

    I do not know how to automatically do this since linker.cmd is automatically generated.

Related