* Ping: check initializer to be zero in .bss-like sections
@ 2016-01-12 10:01 Jan Beulich
2016-01-14 22:38 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-01-12 10:01 UTC (permalink / raw)
To: gcc-patches
>>> On 10.12.15 at 08:21, wrote:
> Just like gas, which has recently learned to reject such initializers,
> gcc shouldn't accept such either.
> ---
> The only question really is whether the new test case should be limited
> to certain targets - I haven't been able to figure out possible valid
> qualifiers to use here.
>
> gcc/
> 2015-12-10 Jan Beulich <jbeulich@suse.com>
>
> * varasm.c (get_variable_section): Validate initializer in
> named .bss-like sections.
>
> gcc/testsuite/
> 2015-12-10 Jan Beulich <jbeulich@suse.com>
>
> * gcc.dg/bss.c: New.
>
> --- 2015-12-09/gcc/testsuite/gcc.dg/bss.c
> +++ 2015-12-09/gcc/testsuite/gcc.dg/bss.c
> @@ -0,0 +1,8 @@
> +/* Test non-zero initializers in .bss-like sections get properly refused.
> */
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +
> +int __attribute__((section(".bss.local"))) x = 1; /* { dg-error "" "zero
> init" } */
> +int *__attribute__((section(".bss.local"))) px = &x; /* { dg-error "" "zero
> init" } */
> +int __attribute__((section(".bss.local"))) y = 0;
> +int *__attribute__((section(".bss.local"))) py = (void*)0;
> --- 2015-12-09/gcc/varasm.c
> +++ 2015-12-09/gcc/varasm.c
> @@ -1150,7 +1150,18 @@ get_variable_section (tree decl, bool pr
>
> resolve_unique_section (decl, reloc, flag_data_sections);
> if (IN_NAMED_SECTION (decl))
> - return get_named_section (decl, NULL, reloc);
> + {
> + section *sect = get_named_section (decl, NULL, reloc);
> +
> + if ((sect->common.flags & SECTION_BSS) && !bss_initializer_p (decl))
> + {
> + error_at (DECL_SOURCE_LOCATION (decl),
> + "only zero initializers are allowed in section %qs",
> + sect->named.name);
> + DECL_INITIAL (decl) = error_mark_node;
> + }
> + return sect;
> + }
>
> if (ADDR_SPACE_GENERIC_P (as)
> && !DECL_THREAD_LOCAL_P (decl)
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Ping: check initializer to be zero in .bss-like sections
2016-01-12 10:01 Ping: check initializer to be zero in .bss-like sections Jan Beulich
@ 2016-01-14 22:38 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2016-01-14 22:38 UTC (permalink / raw)
To: Jan Beulich, gcc-patches
On 01/12/2016 03:01 AM, Jan Beulich wrote:
>>>> On 10.12.15 at 08:21, wrote:
>> Just like gas, which has recently learned to reject such initializers,
>> gcc shouldn't accept such either.
>> ---
>> The only question really is whether the new test case should be limited
>> to certain targets - I haven't been able to figure out possible valid
>> qualifiers to use here.
>>
>> gcc/
>> 2015-12-10 Jan Beulich <jbeulich@suse.com>
>>
>> * varasm.c (get_variable_section): Validate initializer in
>> named .bss-like sections.
Please double-check indentation. It may be an artifact of my looking at
a inline quoted patch -- so just double-check.
>>
>> gcc/testsuite/
>> 2015-12-10 Jan Beulich <jbeulich@suse.com>
>>
>> * gcc.dg/bss.c: New.
I think you need to verify the target supported named sections, for
which we have some functions in target-supports/target-supports-dg.exp.
Given that this should be good-to-go.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-14 22:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-12 10:01 Ping: check initializer to be zero in .bss-like sections Jan Beulich
2016-01-14 22:38 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).