"Bingfeng Mei" <b...@broadcom.com> writes: > I came across an issue regarding named section and nobits. In > the following example, I expected the c is placed is placed > in a section named .smemdata and nobits is set for the section > since "c" is initialized to zeros. > > int a = 0; > > int b = 2000 * 512; > static int c[(200 * 512)] __attribute__((section(".smemdata"))); > > void foo() > { > c[0] = 0; > } > > Using both trunk x86_64 and arm-elf compilers, I found .smemdata > has progbits flag instead of nobits. Is this a bug?
I don't think I would call it a bug; it's more like a feature which has not been implemented. gcc would have to record for each user defined section whether there are any variables initialized to non-zero values. It currently does not do that. Using SHT_PROGBITS always works, though I understand it is not ideal for your scenario. Ian