[llvm-dev] User defined sections as SHT_NOBITS

Cody Addison via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 24 14:48:05 PST 2019


I've noticed that variables in user defined sections are always type SHT_PROGBITS instead of SHT_NOBITS in the ELF file, even if the variable is uninitialized.

__attribute__((section("mybss")))
int array[100];

In isSuitableForBSS(), there is an explicit check that the global variable does not have a section. If I remove this code, I get the expected result. I tracked the change down to a commit 10 years ago which fixed PR4619. I'm not entirely sure why this was an issue, but I get the impression that at the time having a section kind of bss meant the section is actually .bss, whereas today the section kind is really describing the attributes of a section which could have any name.

Does anyone have any additional information on this restriction, or issues with this change?

For background, this is causing a problem in an embedded application where all sections allocated to RAM are expected to be uninitialized and sections allocated to Flash are initialized.


More information about the llvm-dev mailing list