我有一个功能:
void testfunction() {
static char_t theChar1 = 1;
static unsigned char smallArray[1];
static unsigned char largeArray[135];
...
}
和一个链接器文件:
. = ALIGN(4);
_edata = . ;
PROVIDE (edata = .);
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
} > ramEXT
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
我需要静态数组(.bss 数据)在 4 字节边界上对齐,但似乎数组拒绝这样做。结构和原始类型可以很好地对齐(参见填充线),但是数组已经全部结束了。这是我的地图文件:
.data.firstTimeFlag.7295
0xa000098c 0x4 output/file1.o
.data.theChar1.5869
0xa0000990 0x1 output/file2.o
*fill* 0xa0000991 0x3 00
.data.debounce
0xa0000994 0x270 output/file3.o
...
.bss.initialized.5826
0xa000812c 0x1 output/file2.o
*fill* 0xa000812d 0x3 00
.bss.allocator.5825
0xa0008130 0x34 output/file2.o
.bss.largeArray.5869
0xa0008164 0x87 output/file2.o
.bss.smallArray.5868
0xa00081eb 0x1 output/file2.o
.bss.initialized.5897
0xa00081ec 0x1 output/file2.o
*fill* 0xa00081ed 0x3 00
.bss.allocator.5896
有人知道如何对齐数组吗?