Commit a8a6fd74 by Jakub Jelinek Committed by Jakub Jelinek

varasm.c (get_variable_section): Don't return lcomm_section for asan_protect_global decls.

	* varasm.c (get_variable_section): Don't return lcomm_section
	for asan_protect_global decls.
	* asan.c (asan_protect_global): Only avoid public common variables.
	Don't call get_variable_section here.

From-SVN: r194393
parent c699deeb
2012-12-11 Jakub Jelinek <jakub@redhat.com> 2012-12-11 Jakub Jelinek <jakub@redhat.com>
* varasm.c (get_variable_section): Don't return lcomm_section
for asan_protect_global decls.
* asan.c (asan_protect_global): Only avoid public common variables.
Don't call get_variable_section here.
PR middle-end/43631 PR middle-end/43631
PR bootstrap/55615 PR bootstrap/55615
* var-tracking.c (emit_note_insn_var_location): If insn is followed * var-tracking.c (emit_note_insn_var_location): If insn is followed
...@@ -447,7 +447,6 @@ bool ...@@ -447,7 +447,6 @@ bool
asan_protect_global (tree decl) asan_protect_global (tree decl)
{ {
rtx rtl, symbol; rtx rtl, symbol;
section *sect;
if (TREE_CODE (decl) == STRING_CST) if (TREE_CODE (decl) == STRING_CST)
{ {
...@@ -471,7 +470,7 @@ asan_protect_global (tree decl) ...@@ -471,7 +470,7 @@ asan_protect_global (tree decl)
padding or not. */ padding or not. */
|| DECL_ONE_ONLY (decl) || DECL_ONE_ONLY (decl)
/* Similarly for common vars. People can use -fno-common. */ /* Similarly for common vars. People can use -fno-common. */
|| DECL_COMMON (decl) || (DECL_COMMON (decl) && TREE_PUBLIC (decl))
/* Don't protect if using user section, often vars placed /* Don't protect if using user section, often vars placed
into user section from multiple TUs are then assumed into user section from multiple TUs are then assumed
to be an array of such vars, putting padding in there to be an array of such vars, putting padding in there
...@@ -493,10 +492,6 @@ asan_protect_global (tree decl) ...@@ -493,10 +492,6 @@ asan_protect_global (tree decl)
|| TREE_CONSTANT_POOL_ADDRESS_P (symbol)) || TREE_CONSTANT_POOL_ADDRESS_P (symbol))
return false; return false;
sect = get_variable_section (decl, false);
if (sect->common.flags & SECTION_COMMON)
return false;
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))) if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
return false; return false;
......
...@@ -1034,7 +1034,8 @@ get_variable_section (tree decl, bool prefer_noswitch_p) ...@@ -1034,7 +1034,8 @@ get_variable_section (tree decl, bool prefer_noswitch_p)
&& !(prefer_noswitch_p && targetm.have_switchable_bss_sections) && !(prefer_noswitch_p && targetm.have_switchable_bss_sections)
&& bss_initializer_p (decl)) && bss_initializer_p (decl))
{ {
if (!TREE_PUBLIC (decl)) if (!TREE_PUBLIC (decl)
&& !(flag_asan && asan_protect_global (decl)))
return lcomm_section; return lcomm_section;
if (bss_noswitch_section) if (bss_noswitch_section)
return bss_noswitch_section; return bss_noswitch_section;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment