summaryrefslogtreecommitdiff
path: root/gcc/asan.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-07 17:46:30 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-07 17:46:30 +0000
commit046a838d4bd78003015b5b7d359503a6793b7262 (patch)
treec16c78fba132676d9465ffce223c5996274fa41b /gcc/asan.c
parent99d5fe2dc7fe91aa2471ae80315c9a9a60e43dc4 (diff)
downloadgcc-046a838d4bd78003015b5b7d359503a6793b7262.tar.gz
* varasm.c (output_constant_def_contents): For asan_protect_global
protected strings, adjust DECL_ALIGN if needed, before testing for anchored symbols. (place_block_symbol): Adjust size for asan protected STRING_CSTs if TREE_CONSTANT_POOL_ADDRESS_P. Increase alignment for asan protected normal decls. (output_object_block): For asan protected decls, emit asan padding after their contents. * asan.c (asan_protect_global): Don't check TREE_ASM_WRITTEN here. (asan_finish_file): Test it here instead. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194984 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/asan.c')
-rw-r--r--gcc/asan.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index 40af45dd0bb..9d3387616de 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1,5 +1,5 @@
/* AddressSanitizer, a fast memory error detector.
- Copyright (C) 2012 Free Software Foundation, Inc.
+ Copyright (C) 2012, 2013 Free Software Foundation, Inc.
Contributed by Kostya Serebryany <kcc@google.com>
This file is part of GCC.
@@ -463,7 +463,6 @@ asan_protect_global (tree decl)
|| DECL_THREAD_LOCAL_P (decl)
/* Externs will be protected elsewhere. */
|| DECL_EXTERNAL (decl)
- || !TREE_ASM_WRITTEN (decl)
|| !DECL_RTL_SET_P (decl)
/* Comdat vars pose an ABI problem, we can't know if
the var that is selected by the linker will have
@@ -1699,7 +1698,8 @@ asan_finish_file (void)
tree fn = builtin_decl_implicit (BUILT_IN_ASAN_INIT);
append_to_statement_list (build_call_expr (fn, 0), &asan_ctor_statements);
FOR_EACH_DEFINED_VARIABLE (vnode)
- if (asan_protect_global (vnode->symbol.decl))
+ if (TREE_ASM_WRITTEN (vnode->symbol.decl)
+ && asan_protect_global (vnode->symbol.decl))
++gcount;
htab_t const_desc_htab = constant_pool_htab ();
htab_traverse (const_desc_htab, count_string_csts, &gcount);
@@ -1721,7 +1721,8 @@ asan_finish_file (void)
DECL_IGNORED_P (var) = 1;
vec_alloc (v, gcount);
FOR_EACH_DEFINED_VARIABLE (vnode)
- if (asan_protect_global (vnode->symbol.decl))
+ if (TREE_ASM_WRITTEN (vnode->symbol.decl)
+ && asan_protect_global (vnode->symbol.decl))
asan_add_global (vnode->symbol.decl, TREE_TYPE (type), v);
struct asan_add_string_csts_data aascd;
aascd.type = TREE_TYPE (type);