How do you ensure a linker section does not get flash memory allocated

Viewed 246

I'm presently working on adding a ".ccmbss" section into my linker script, where I'm trying to place some uninitialized variables/structs. This is separate from the normal ".bss" section, with the key differentiator being that .ccmbss is located in the core-coupled memory RAM and .bss is located in normal RAM.

When I try placing a large uninitialized struct (~32kB) within the .ccmbss section using the C __attribute__((section(.ccmbss))) designator, I notice that it gets an allocated section of flash of the same size. However, when I don't explicitly set it to move into the .ccmbss section, it gets allocated to the .bss section (as expected) and doesn't take up any flash space.

Any ideas as to how to guarantee that the ccmbss section does not get an associated flash region of memory?

Here is the key part of the linker file that I am working on:

 .ccm : {
  . = ALIGN(4);
  _siccmram = .;
  *(.ccm)
  _eiccmram = .;
  . = ALIGN(4);
 } >ccm AT >app
 _ccm_loadaddr = LOADADDR(.ccm);
 
 .ccmbss : {
  . = ALIGN(4);
  *(.ccmbss)
  *(.ccmbss*)
  . = ALIGN(4);
  _eccmbss = .;
  _eccmram = .;
 } >ccm
 
 .data : {
  _data = .;
  *(.data*)
  . = ALIGN(4);
  _edata = .;
 } >ram AT >app
 _data_loadaddr = LOADADDR(.data);
 
 .bss : {
  *(.bss*)
  *(COMMON)
  . = ALIGN(4);
  _ebss = .;
 } >ram
1 Answers

So it looks like Eugene and Ian were on the right track, but unfortunately it didn't work for me as I'm using the ARM-specific compiler (arm-none-eabi-gcc), which threw errors when coming across the first comma in __attribute__((section(".ccmbss,/"aw/",@nobits#))): Error: junk at end of line, first unrecognized character is `,'

After spending way too long trying different things to fix this (pragmas, the zero_init specifier for __attribute__((section()))), I did find a solution here. The resolution was to rename .ccmbss to .bss.ccm so that the section was defaulting to a %nobits section type, which prevents the section from taking up ROM space.

Thank you for your help!!

Related