3
votes

The embedded device has two SRAM regions. First at 0x20000000 and length 16k. Then at 0x20040000 length 96k. In the application, the resulting .bss section size is 102k so it doesn't fit to either RAM region fully. It needs to be split between the two regions. How to do this is in .ld linker script?

I know two options which are kludgy.

Option A: hand pick the objects by name in the script and split those to two sections. With this option I feel like I am doing manually what the linker is supposed to do.

Option B: place attributes to source code to make some objects to special .bss2 section. This one's even worse than option A.

I want that the linker automatically optimally does split objects across the two memory regions. I know at least IAR linker does it optimally without any manual work.

1
What did your research in the linker's documentation and/or the internet reveal?the busybee
There is duplicate question here with no answer: stackoverflow.com/questions/15156201/…Tagli

1 Answers

0
votes

I red that from a NXP employee :
"The GNU linker is going through the linker script file in a linear way, and does not try to fill up things or distribute variables into different memory areas."
You have to create a bss2 section and init it in startup file, then go either for option A or B. You can also use another toolchain, most of them are able to distribute variables into different memory sections

Linker script :

.bss2 :
  {
    . = ALIGN(4);
    __bss2_start__ = .;
    *(.bss2)
    *(.bss2.*)
    . = ALIGN(4);
    __bss2_end__ = .;
  } > RAM2 AT > RAM2