[cfe-dev] Recent changes regarding section type conflicts and #pragma clang section
Bruno De Fraine via cfe-dev
cfe-dev at lists.llvm.org
Tue Jun 9 05:05:49 PDT 2020
We observe two issues regarding your commits "[Clang][Sema] Capturing section type conflicts between #pragma clang section":
A first observation is that once a section has been used as bss argument in a #pragma clang section, it is no longer possible to use this section in an explicit section annotation on a variable, even if this variable is zero-initialized:
[ In contrast, for a section used as the rodata argument, you *can* still do this, provided that the variable is "const":
The problem for bss sections seems to be related to the newly introduced "PSF_ZeroInit" flag?
A second issue is that #pragma clang section provided a way to assign multiple variables to the same data section, mixing const, non-const and zero-initialized variables. When using an explicit section attribute, clang and gcc disallow to use the same section for const and non-const variables: https://godbolt.org/z/S76vKm (but you can mix zero-initialized and non-zero-initialized variables)
An implicit section annotation using #pragma clang section allowed to work around this, by specifying the same data section in the pragma:
#pragma clang section data="mydata" bss="mydata" rodata="mydata"
This is an example using clang-10: https://godbolt.org/z/vxty7T
This is now rejected, and granted, it was an abuse of the #pragma clang section. But is it not valid to assign both const and non-const variables to the same data section? Either with an explicit annotation or implicit?
Bruno De Fraine
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev