How to place variables into a 2nd .bss / common section?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm working on an embedded system with a coldfire (m68k-elf) cpu.
The system has two different ram areas:
1. External DRAM (the main ram module)
2. Internal SRAM 

The first and normal ".bss" section works just fine (see below).

To put global variables into the second section called
".bss_sram" I use the following macro:

#define SECTION_BSS_SRAM __attribute__((section(".bss_sram")))

Unfortunately, GCC generates assembler-code with the "@progbits"
attribute:

.section	.bss_sram,"aw",@progbits

which makes the linker mark the section as loadable and reserve
space in the executable (not necessary & unwanted):

"m68k-elf-objdump -h $EXECUTABLE" shows the problem:
  5 .bss          01fac966  4000001c  00001700  0000401c  2**1
                  ALLOC
  6 .bss_sram     00001094  80000000  80000000  00010000  2**11
                  CONTENTS, ALLOC, LOAD, DATA

I didn't find any options to tell GCC that this is a section with
"common" data, but instead found a "dirty workaround" to inject
the "@nobits" attribute into the assembly code:

http://stackoverflow.com/questions/6252812/what-does-the-aw-flag-in-the-section-attribute-mean

Is this the only way to have a second common section or is there a
more beautiful way / option?

Thanks
Michael




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux