9
9
* any of the gcc libraries
10
10
*
11
11
* This gcc plugin is needed for tracking the lowest border of the kernel stack.
12
- * It instruments the kernel code inserting stackleak_track_stack () calls:
12
+ * It instruments the kernel code inserting __sanitizer_cov_stack_depth () calls:
13
13
* - after alloca();
14
14
* - for the functions with a stack frame size greater than or equal
15
15
* to the "track-min-size" plugin parameter.
@@ -33,7 +33,7 @@ __visible int plugin_is_GPL_compatible;
33
33
34
34
static int track_frame_size = -1 ;
35
35
static bool build_for_x86 = false;
36
- static const char track_function [] = "stackleak_track_stack " ;
36
+ static const char track_function [] = "__sanitizer_cov_stack_depth " ;
37
37
static bool disable = false;
38
38
static bool verbose = false;
39
39
@@ -58,7 +58,7 @@ static void add_stack_tracking_gcall(gimple_stmt_iterator *gsi, bool after)
58
58
cgraph_node_ptr node ;
59
59
basic_block bb ;
60
60
61
- /* Insert calling stackleak_track_stack () */
61
+ /* Insert calling __sanitizer_cov_stack_depth () */
62
62
stmt = gimple_build_call (track_function_decl , 0 );
63
63
gimple_call = as_a_gcall (stmt );
64
64
if (after )
@@ -120,12 +120,12 @@ static void add_stack_tracking_gasm(gimple_stmt_iterator *gsi, bool after)
120
120
gcc_assert (build_for_x86 );
121
121
122
122
/*
123
- * Insert calling stackleak_track_stack () in asm:
124
- * asm volatile("call stackleak_track_stack "
123
+ * Insert calling __sanitizer_cov_stack_depth () in asm:
124
+ * asm volatile("call __sanitizer_cov_stack_depth "
125
125
* :: "r" (current_stack_pointer))
126
126
* Use ASM_CALL_CONSTRAINT trick from arch/x86/include/asm/asm.h.
127
127
* This constraint is taken into account during gcc shrink-wrapping
128
- * optimization. It is needed to be sure that stackleak_track_stack ()
128
+ * optimization. It is needed to be sure that __sanitizer_cov_stack_depth ()
129
129
* call is inserted after the prologue of the containing function,
130
130
* when the stack frame is prepared.
131
131
*/
@@ -137,7 +137,7 @@ static void add_stack_tracking_gasm(gimple_stmt_iterator *gsi, bool after)
137
137
input = build_tree_list (NULL_TREE , build_const_char_string (2 , "r" ));
138
138
input = chainon (NULL_TREE , build_tree_list (input , sp_decl ));
139
139
vec_safe_push (inputs , input );
140
- asm_call = gimple_build_asm_vec ("call stackleak_track_stack " ,
140
+ asm_call = gimple_build_asm_vec ("call __sanitizer_cov_stack_depth " ,
141
141
inputs , NULL , NULL , NULL );
142
142
gimple_asm_set_volatile (asm_call , true);
143
143
if (after )
@@ -151,11 +151,11 @@ static void add_stack_tracking(gimple_stmt_iterator *gsi, bool after)
151
151
{
152
152
/*
153
153
* The 'no_caller_saved_registers' attribute is used for
154
- * stackleak_track_stack (). If the compiler supports this attribute for
155
- * the target arch, we can add calling stackleak_track_stack () in asm.
154
+ * __sanitizer_cov_stack_depth (). If the compiler supports this attribute for
155
+ * the target arch, we can add calling __sanitizer_cov_stack_depth () in asm.
156
156
* That improves performance: we avoid useless operations with the
157
157
* caller-saved registers in the functions from which we will remove
158
- * stackleak_track_stack () call during the stackleak_cleanup pass.
158
+ * __sanitizer_cov_stack_depth () call during the stackleak_cleanup pass.
159
159
*/
160
160
if (lookup_attribute_spec (get_identifier ("no_caller_saved_registers" )))
161
161
add_stack_tracking_gasm (gsi , after );
@@ -165,7 +165,7 @@ static void add_stack_tracking(gimple_stmt_iterator *gsi, bool after)
165
165
166
166
/*
167
167
* Work with the GIMPLE representation of the code. Insert the
168
- * stackleak_track_stack () call after alloca() and into the beginning
168
+ * __sanitizer_cov_stack_depth () call after alloca() and into the beginning
169
169
* of the function if it is not instrumented.
170
170
*/
171
171
static unsigned int stackleak_instrument_execute (void )
@@ -205,7 +205,7 @@ static unsigned int stackleak_instrument_execute(void)
205
205
DECL_NAME_POINTER (current_function_decl ));
206
206
}
207
207
208
- /* Insert stackleak_track_stack () call after alloca() */
208
+ /* Insert __sanitizer_cov_stack_depth () call after alloca() */
209
209
add_stack_tracking (& gsi , true);
210
210
if (bb == entry_bb )
211
211
prologue_instrumented = true;
@@ -241,7 +241,7 @@ static unsigned int stackleak_instrument_execute(void)
241
241
return 0 ;
242
242
}
243
243
244
- /* Insert stackleak_track_stack () call at the function beginning */
244
+ /* Insert __sanitizer_cov_stack_depth () call at the function beginning */
245
245
bb = entry_bb ;
246
246
if (!single_pred_p (bb )) {
247
247
/* gcc_assert(bb_loop_depth(bb) ||
@@ -270,15 +270,15 @@ static void remove_stack_tracking_gcall(void)
270
270
rtx_insn * insn , * next ;
271
271
272
272
/*
273
- * Find stackleak_track_stack () calls. Loop through the chain of insns,
273
+ * Find __sanitizer_cov_stack_depth () calls. Loop through the chain of insns,
274
274
* which is an RTL representation of the code for a function.
275
275
*
276
276
* The example of a matching insn:
277
- * (call_insn 8 4 10 2 (call (mem (symbol_ref ("stackleak_track_stack ")
278
- * [flags 0x41] <function_decl 0x7f7cd3302a80 stackleak_track_stack >)
279
- * [0 stackleak_track_stack S1 A8]) (0)) 675 {*call} (expr_list
280
- * (symbol_ref ("stackleak_track_stack ") [flags 0x41] <function_decl
281
- * 0x7f7cd3302a80 stackleak_track_stack >) (expr_list (0) (nil))) (nil))
277
+ * (call_insn 8 4 10 2 (call (mem (symbol_ref ("__sanitizer_cov_stack_depth ")
278
+ * [flags 0x41] <function_decl 0x7f7cd3302a80 __sanitizer_cov_stack_depth >)
279
+ * [0 __sanitizer_cov_stack_depth S1 A8]) (0)) 675 {*call} (expr_list
280
+ * (symbol_ref ("__sanitizer_cov_stack_depth ") [flags 0x41] <function_decl
281
+ * 0x7f7cd3302a80 __sanitizer_cov_stack_depth >) (expr_list (0) (nil))) (nil))
282
282
*/
283
283
for (insn = get_insns (); insn ; insn = next ) {
284
284
rtx body ;
@@ -318,7 +318,7 @@ static void remove_stack_tracking_gcall(void)
318
318
if (SYMBOL_REF_DECL (body ) != track_function_decl )
319
319
continue ;
320
320
321
- /* Delete the stackleak_track_stack () call */
321
+ /* Delete the __sanitizer_cov_stack_depth () call */
322
322
delete_insn_and_edges (insn );
323
323
#if BUILDING_GCC_VERSION < 8000
324
324
if (GET_CODE (next ) == NOTE &&
@@ -340,12 +340,12 @@ static bool remove_stack_tracking_gasm(void)
340
340
gcc_assert (build_for_x86 );
341
341
342
342
/*
343
- * Find stackleak_track_stack () asm calls. Loop through the chain of
343
+ * Find __sanitizer_cov_stack_depth () asm calls. Loop through the chain of
344
344
* insns, which is an RTL representation of the code for a function.
345
345
*
346
346
* The example of a matching insn:
347
347
* (insn 11 5 12 2 (parallel [ (asm_operands/v
348
- * ("call stackleak_track_stack ") ("") 0
348
+ * ("call __sanitizer_cov_stack_depth ") ("") 0
349
349
* [ (reg/v:DI 7 sp [ current_stack_pointer ]) ]
350
350
* [ (asm_input:DI ("r")) ] [])
351
351
* (clobber (reg:CC 17 flags)) ]) -1 (nil))
@@ -375,7 +375,7 @@ static bool remove_stack_tracking_gasm(void)
375
375
continue ;
376
376
377
377
if (strcmp (ASM_OPERANDS_TEMPLATE (body ),
378
- "call stackleak_track_stack " )) {
378
+ "call __sanitizer_cov_stack_depth " )) {
379
379
continue ;
380
380
}
381
381
@@ -389,7 +389,7 @@ static bool remove_stack_tracking_gasm(void)
389
389
390
390
/*
391
391
* Work with the RTL representation of the code.
392
- * Remove the unneeded stackleak_track_stack () calls from the functions
392
+ * Remove the unneeded __sanitizer_cov_stack_depth () calls from the functions
393
393
* which don't call alloca() and don't have a large enough stack frame size.
394
394
*/
395
395
static unsigned int stackleak_cleanup_execute (void )
@@ -474,13 +474,13 @@ static bool stackleak_gate(void)
474
474
return track_frame_size >= 0 ;
475
475
}
476
476
477
- /* Build the function declaration for stackleak_track_stack () */
477
+ /* Build the function declaration for __sanitizer_cov_stack_depth () */
478
478
static void stackleak_start_unit (void * gcc_data __unused ,
479
479
void * user_data __unused )
480
480
{
481
481
tree fntype ;
482
482
483
- /* void stackleak_track_stack (void) */
483
+ /* void __sanitizer_cov_stack_depth (void) */
484
484
fntype = build_function_type_list (void_type_node , NULL_TREE );
485
485
track_function_decl = build_fn_decl (track_function , fntype );
486
486
DECL_ASSEMBLER_NAME (track_function_decl ); /* for LTO */
0 commit comments