On Mon, 8 Apr 2019, Richard Biener wrote:
> That is, the C testcase
>
> const char x[1024*1024] = {};
>
> reproduces the "issue". The comment in bss_initializer_p though
> explicitely says
>
> /* Do not put non-common constants into the .bss section, they belong in
> a readonly section, except when NAMED is true. */
> return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named)
>
> (where named refers to explicit .bss section marked decls). Note
> the docs for -fzero-initialized-in-bss doesn't mention that this doesn't
> apply for readonly variables.
I'd say it's a security risk (breaks expected hardening properties) for a
const variable with static storage duration not to end up in read-only
memory, regardless of its size or contents, so such variables should not
be put in BSS by default.
--
Joseph S. Myers
[email protected]