diff mbox

[PR,lto/79042] Propagate node->dynamically_initialized bit for varpool node to LTRANS stage.

Message ID 5875F43C.6080901@samsung.com
State New
Headers show

Commit Message

Maxim Ostapenko Jan. 11, 2017, 9 a.m. UTC
Hi,

as mentioned in PR, LTO doesn't propagate node->dynamically_initialized 
bit for varpool nodes that leads to ASan fails to detect initialization 
order fiasco even for trivial example (e.g. from here: 
https://github.com/google/sanitizers/wiki/AddressSanitizerExampleInitOrderFiasco).
This trivial patch fixes the issue. Regtested on 
x86_64-unknown-linux-gnu, OK for mainline?

-Maxim

Comments

Richard Biener Jan. 11, 2017, 11:17 a.m. UTC | #1
On Wed, Jan 11, 2017 at 10:00 AM, Maxim Ostapenko
<m.ostapenko@samsung.com> wrote:
> Hi,
>
> as mentioned in PR, LTO doesn't propagate node->dynamically_initialized bit
> for varpool nodes that leads to ASan fails to detect initialization order
> fiasco even for trivial example (e.g. from here:
> https://github.com/google/sanitizers/wiki/AddressSanitizerExampleInitOrderFiasco).
> This trivial patch fixes the issue. Regtested on x86_64-unknown-linux-gnu,
> OK for mainline?

Ok.  This is also needed on branches, correct?

Richard.

> -Maxim
Maxim Ostapenko Jan. 11, 2017, 11:21 a.m. UTC | #2
On 11/01/17 14:17, Richard Biener wrote:
> On Wed, Jan 11, 2017 at 10:00 AM, Maxim Ostapenko
> <m.ostapenko@samsung.com> wrote:
>> Hi,
>>
>> as mentioned in PR, LTO doesn't propagate node->dynamically_initialized bit
>> for varpool nodes that leads to ASan fails to detect initialization order
>> fiasco even for trivial example (e.g. from here:
>> https://github.com/google/sanitizers/wiki/AddressSanitizerExampleInitOrderFiasco).
>> This trivial patch fixes the issue. Regtested on x86_64-unknown-linux-gnu,
>> OK for mainline?
> Ok.  This is also needed on branches, correct?

Yes, branches also need this. gcc-5-branch and gcc-6-branch, right?

Thanks,
-Maxim

>
> Richard.
>
>> -Maxim
>
Richard Biener Jan. 11, 2017, 11:34 a.m. UTC | #3
On Wed, Jan 11, 2017 at 12:21 PM, Maxim Ostapenko
<m.ostapenko@samsung.com> wrote:
> On 11/01/17 14:17, Richard Biener wrote:
>>
>> On Wed, Jan 11, 2017 at 10:00 AM, Maxim Ostapenko
>> <m.ostapenko@samsung.com> wrote:
>>>
>>> Hi,
>>>
>>> as mentioned in PR, LTO doesn't propagate node->dynamically_initialized
>>> bit
>>> for varpool nodes that leads to ASan fails to detect initialization order
>>> fiasco even for trivial example (e.g. from here:
>>>
>>> https://github.com/google/sanitizers/wiki/AddressSanitizerExampleInitOrderFiasco).
>>> This trivial patch fixes the issue. Regtested on
>>> x86_64-unknown-linux-gnu,
>>> OK for mainline?
>>
>> Ok.  This is also needed on branches, correct?
>
>
> Yes, branches also need this. gcc-5-branch and gcc-6-branch, right?

Yes.  Please bump lto-streamer.h:LTO_minor_version on the branches
with such change
as the LTO binary format will be incompatible.  (not that we always
remember to do that...)

Thanks,
Richard.

> Thanks,
> -Maxim
>
>>
>> Richard.
>>
>>> -Maxim
>>
>>
>
diff mbox

Patch

gcc/ChangeLog:

2017-01-11  Maxim Ostapenko  <m.ostapenko@samsung.com>

	PR lto/79042
	* lto-cgraph.c (lto_output_varpool_node): Pack dynamically_initialized
	bit.
	(input_varpool_node): Unpack dynamically_initialized bit.

diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index c0321f7..77605f7 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -626,6 +626,7 @@  lto_output_varpool_node (struct lto_simple_output_block *ob, varpool_node *node,
     }
   bp_pack_value (&bp, node->tls_model, 3);
   bp_pack_value (&bp, node->used_by_single_function, 1);
+  bp_pack_value (&bp, node->dynamically_initialized, 1);
   bp_pack_value (&bp, node->need_bounds_init, 1);
   streamer_write_bitpack (&bp);
 
@@ -1400,6 +1401,7 @@  input_varpool_node (struct lto_file_decl_data *file_data,
     node->alias_target = get_alias_symbol (node->decl);
   node->tls_model = (enum tls_model)bp_unpack_value (&bp, 3);
   node->used_by_single_function = (enum tls_model)bp_unpack_value (&bp, 1);
+  node->dynamically_initialized = bp_unpack_value (&bp, 1);
   node->need_bounds_init = bp_unpack_value (&bp, 1);
   group = read_identifier (ib);
   if (group)