1 2012-10-29 Wei Mi <wmi@google.com>
3 * gcc.c (LINK_COMMAND_SPEC): Add -lasan to link command if
4 -faddress-sanitizer is on.
6 2012-10-26 Dodji Seketeli <dodji@redhat.com>
8 * gimple.h (is_gimple_builtin_call): Declare ...
9 * gimple.c (is_gimple_builtin_call): ... new public function.
10 * asan.c (insert_if_then_before_iter, instrument_mem_region_access,
11 instrument_strlen_call, maybe_instrument_builtin_call,
12 instrument_call): New static functions.
13 (create_cond_insert_point): Renamed
14 create_cond_insert_point_before_iter into this. Add a new
15 parameter to decide whether to insert the condition before or
16 after the statement iterator.
17 (build_check_stmt): Adjust for the new create_cond_insert_point.
18 Add a new parameter to decide whether to add the instrumentation
19 code before or after the statement iterator.
20 (instrument_assignment): Factorize from ...
21 (transform_statements): ... here. Use maybe_instrument_call to
22 instrument builtin function calls as well.
23 (instrument_derefs): Adjust for the new parameter of
24 build_check_stmt. Fix detection of bit-field access.
26 2012-10-26 Dodji Seketeli <dodji@redhat.com>
28 * asan.c (create_cond_insert_point_before_iter): Factorize out of ...
29 (build_check_stmt): ... here.
31 2012-10-26 Dodji Seketeli <dodji@redhat.com>
33 * asan.c (build_check_stmt): Accept the memory access to be
34 represented by an SSA_NAME.
36 2012-10-17 Jakub Jelinek <jakub@redhat.com>
37 Wei Mi <wmi@google.com>
39 * varasm.c: Include asan.h.
40 (assemble_noswitch_variable): Grow size by asan_red_zone_size
41 if decl is asan protected.
42 (place_block_symbol): Likewise.
43 (assemble_variable): If decl is asan protected, increase
44 DECL_ALIGN if needed, and for decls emitted using
45 assemble_variable_contents append padding zeros after it.
46 * Makefile.in (varasm.o): Depend on asan.h.
47 * asan.c: Include output.h.
48 (asan_pp, asan_pp_initialized, asan_ctor_statements): New variables.
49 (asan_pp_initialize, asan_pp_string): New functions.
50 (asan_emit_stack_protection): Use asan_pp{,_initialized}
51 instead of local pp{,_initialized} vars, use asan_pp_initialize
52 and asan_pp_string helpers.
53 (asan_needs_local_alias, asan_protect_global,
54 asan_global_struct, asan_add_global): New functions.
55 (asan_finish_file): Protect global vars that can be protected. Use
56 asan_ctor_statements instead of ctor_statements
57 * asan.h (asan_protect_global): New prototype.
58 (asan_red_zone_size): New inline function.
60 2012-10-17 Jakub Jelinek <jakub@redhat.com>
62 * Makefile.in (asan.o): Depend on $(EXPR_H) $(OPTABS_H).
63 (cfgexpand.o): Depend on asan.h.
64 * asan.c: Include expr.h and optabs.h.
65 (asan_shadow_set): New variable.
66 (asan_shadow_cst, asan_emit_stack_protection): New functions.
67 (asan_init_shadow_ptr_types): Initialize also asan_shadow_set.
68 * cfgexpand.c: Include asan.h. Define HOST_WIDE_INT heap vector.
69 (partition_stack_vars): If i is large alignment and j small
70 alignment or vice versa, break out of the loop instead of continue,
71 and put the test earlier. If flag_asan, break out of the loop
72 if for small alignment size is different.
73 (struct stack_vars_data): New type.
74 (expand_stack_vars): Add DATA argument. Change PRED type to
75 function taking size_t argument instead of tree. Adjust pred
76 calls. Fill DATA in and add needed padding in between variables
77 if -faddress-sanitizer.
78 (defer_stack_allocation): Defer everything for flag_asan.
79 (stack_protect_decl_phase_1, stack_protect_decl_phase_2): Take
80 size_t index into stack_vars array instead of the decl directly.
81 (asan_decl_phase_3): New function.
82 (expand_used_vars): Return var destruction sequence. Adjust
83 expand_stack_vars calls, add another one for flag_asan. Call
84 asan_emit_stack_protection if expand_stack_vars added anything
86 (expand_gimple_basic_block): Add disable_tail_calls argument.
87 (gimple_expand_cfg): Pass true to it if expand_used_vars returned
88 non-NULL. Emit the sequence returned by expand_used_vars after
90 * asan.h (asan_emit_stack_protection): New prototype.
91 (asan_shadow_set): New decl.
92 (ASAN_RED_ZONE_SIZE, ASAN_STACK_MAGIC_LEFT, ASAN_STACK_MAGIC_MIDDLE,
93 ASAN_STACK_MAGIC_RIGHT, ASAN_STACK_FRAME_MAGIC): Define.
94 (asan_protect_stack_decl): New inline.
95 * toplev.c (process_options): Also disable -faddress-sanitizer on
96 !FRAME_GROWS_DOWNWARDS targets.
98 2012-10-17 Jakub Jelinek <jakub@redhat.com>
100 * Makefile.in (asan.o): Depend on $(EXPR_H) $(OPTABS_H).
101 (cfgexpand.o): Depend on asan.h.
102 * asan.c: Include expr.h and optabs.h.
103 (asan_shadow_set): New variable.
104 (asan_shadow_cst, asan_emit_stack_protection): New functions.
105 (asan_init_shadow_ptr_types): Initialize also asan_shadow_set.
106 * cfgexpand.c: Include asan.h. Define HOST_WIDE_INT heap vector.
107 (partition_stack_vars): If i is large alignment and j small
108 alignment or vice versa, break out of the loop instead of continue,
109 and put the test earlier. If flag_asan, break out of the loop
110 if for small alignment size is different.
111 (struct stack_vars_data): New type.
112 (expand_stack_vars): Add DATA argument. Change PRED type to
113 function taking size_t argument instead of tree. Adjust pred calls.
114 Fill DATA in and add needed padding in between variables if -fasan.
115 (defer_stack_allocation): Defer everything for flag_asan.
116 (stack_protect_decl_phase_1, stack_protect_decl_phase_2): Take
117 size_t index into stack_vars array instead of the decl directly.
118 (asan_decl_phase_3): New function.
119 (expand_used_vars): Return var destruction sequence. Adjust
120 expand_stack_vars calls, add another one for flag_asan. Call
121 asan_emit_stack_protection if expand_stack_vars added anything
123 (expand_gimple_basic_block): Add disable_tail_calls argument.
124 (gimple_expand_cfg): Pass true to it if expand_used_vars returned
125 non-NULL. Emit the sequence returned by expand_used_vars after
127 * asan.h (asan_emit_stack_protection): New prototype.
128 (asan_shadow_set): New decl.
129 (ASAN_RED_ZONE_SIZE, ASAN_STACK_MAGIC_LEFT, ASAN_STACK_MAGIC_MIDDLE,
130 ASAN_STACK_MAGIC_RIGHT, ASAN_STACK_FRAME_MAGIC): Define.
131 (asan_protect_stack_decl): New inline.
132 * toplev.c (process_options): Also disable -fasan on
133 !FRAME_GROWS_DOWNWARDS targets.
135 2012-10-12 Jakub Jelinek <jakub@redhat.com>
137 * asan.c (build_check_stmt): Rename join_bb variable to else_bb.
138 (gate_asan_O0): New function.
139 (pass_asan_O0): New variable.
140 * passes.c (init_optimization_passes): Add pass_asan_O0.
141 * tree-pass.h (pass_asan_O0): New declaration.
143 2012-10-11 Jakub Jelinek <jakub@redhat.com>
144 Xinliang David Li <davidxl@google.com>
145 Dodji Seketeli <dodji@redhat.com>
147 * Makefile.in (GTFILES): Add $(srcdir)/asan.c.
148 (asan.o): Update the dependencies of asan.o.
149 * asan.c (tm.h, tree.h, tm_p.h, basic-block.h, flags.h
150 function.h, tree-inline.h, tree-dump.h, diagnostic.h, demangle.h,
151 langhooks.h, ggc.h, cgraph.h, gimple.h): Remove these unused but
153 (shadow_ptr_types): New variable.
154 (report_error_func): Change is_store argument to bool, don't append
155 newline to function name.
156 (PROB_VERY_UNLIKELY, PROB_ALWAYS): Define.
157 (build_check_stmt): Change is_store argument to bool. Emit GIMPLE
158 directly instead of creating trees and gimplifying them. Mark
159 the error reporting function as very unlikely.
160 (instrument_derefs): Change is_store argument to bool. Use
161 int_size_in_bytes to compute size_in_bytes, simplify size check.
162 Use build_fold_addr_expr instead of build_addr.
163 (transform_statements): Adjust instrument_derefs caller.
164 Use gimple_assign_single_p as stmt test. Don't look at MEM refs
166 (asan_init_shadow_ptr_types): New function.
167 (asan_instrument): Don't push/pop gimplify context.
168 Call asan_init_shadow_ptr_types if not yet initialized.
169 * asan.h (ASAN_SHADOW_SHIFT): Adjust comment.
171 2012-10-11 Jakub Jelinek <jakub@redhat.com>
172 Dodji Seketeli <dodji@redhat.com>
174 * Makefile.in (GTFILES): Add $(srcdir)/asan.c.
175 (asan.o): Update the dependencies of asan.o.
176 * asan.c (tm.h, tree.h, tm_p.h, basic-block.h, flags.h
177 function.h, tree-inline.h, tree-dump.h, diagnostic.h, demangle.h,
178 langhooks.h, ggc.h, cgraph.h, gimple.h): Remove these unused but
180 (shadow_ptr_types): New variable.
181 (report_error_func): Change is_store argument to bool, don't append
182 newline to function name.
183 (PROB_VERY_UNLIKELY, PROB_ALWAYS): Define.
184 (build_check_stmt): Change is_store argument to bool. Emit GIMPLE
185 directly instead of creating trees and gimplifying them. Mark
186 the error reporting function as very unlikely.
187 (instrument_derefs): Change is_store argument to bool. Use
188 int_size_in_bytes to compute size_in_bytes, simplify size check.
189 Use build_fold_addr_expr instead of build_addr.
190 (transform_statements): Adjust instrument_derefs caller.
191 Use gimple_assign_single_p as stmt test. Don't look at MEM refs
193 (asan_init_shadow_ptr_types): New function.
194 (asan_instrument): Don't push/pop gimplify context.
195 Call asan_init_shadow_ptr_types if not yet initialized.
196 * asan.h (ASAN_SHADOW_SHIFT): Adjust comment.
198 2012-10-11 Jakub Jelinek <jakub@redhat.com>
200 * toplev.c (process_options): Warn and turn off
201 -faddress-sanitizer if not supported by target.
202 * asan.c: Include target.h.
203 (asan_scale, asan_offset_log_32, asan_offset_log_64,
204 asan_offset_log): Removed.
205 (build_check_stmt): Use ASAN_SHADOW_SHIFT and
206 targetm.asan_shadow_offset ().
207 (asan_instrument): Don't initialize asan_offset_log.
208 * asan.h (ASAN_SHADOW_SHIFT): Define.
209 * target.def (TARGET_ASAN_SHADOW_OFFSET): New hook.
210 * doc/tm.texi.in (TARGET_ASAN_SHADOW_OFFSET): Add it.
211 * doc/tm.texi: Regenerated.
212 * Makefile.in (asan.o): Depend on $(TARGET_H).
213 * config/i386/i386.c (ix86_asan_shadow_offset): New function.
214 (TARGET_ASAN_SHADOW_OFFSET): Define.
216 2012-10-10 Wei Mi <wmi@google.com>
217 Diego Novillo <dnovillo@google.com>
218 Dodji Seketeli <dodji@redhat.com>
220 * Makefile.in: Add asan.c and its dependencies.
221 * common.opt: Add -faddress-sanitizer option.
222 * invoke.texi: Document the new flag.
223 * passes.c: Add the asan pass.
224 * toplev.c (compile_file): Call asan_finish_file.
227 * tree-pass.h: Declare pass_asan.