@@ -2339,7 +2339,8 @@ static int read_unwind_hints(struct objtool_file *file)
2339
2339
return 0 ;
2340
2340
}
2341
2341
2342
- static int read_annotate (struct objtool_file * file , int (* func )(int type , struct instruction * insn ))
2342
+ static int read_annotate (struct objtool_file * file ,
2343
+ int (* func )(struct objtool_file * file , int type , struct instruction * insn ))
2343
2344
{
2344
2345
struct section * sec ;
2345
2346
struct instruction * insn ;
@@ -2372,15 +2373,15 @@ static int read_annotate(struct objtool_file *file, int (*func)(int type, struct
2372
2373
return -1 ;
2373
2374
}
2374
2375
2375
- ret = func (type , insn );
2376
+ ret = func (file , type , insn );
2376
2377
if (ret < 0 )
2377
2378
return ret ;
2378
2379
}
2379
2380
2380
2381
return 0 ;
2381
2382
}
2382
2383
2383
- static int __annotate_ignore_alts (int type , struct instruction * insn )
2384
+ static int __annotate_ignore_alts (struct objtool_file * file , int type , struct instruction * insn )
2384
2385
{
2385
2386
if (type != ANNOTYPE_IGNORE_ALTS )
2386
2387
return 0 ;
@@ -2389,7 +2390,7 @@ static int __annotate_ignore_alts(int type, struct instruction *insn)
2389
2390
return 0 ;
2390
2391
}
2391
2392
2392
- static int __annotate_noendbr (int type , struct instruction * insn )
2393
+ static int __annotate_noendbr (struct objtool_file * file , int type , struct instruction * insn )
2393
2394
{
2394
2395
if (type != ANNOTYPE_NOENDBR )
2395
2396
return 0 ;
@@ -2398,7 +2399,37 @@ static int __annotate_noendbr(int type, struct instruction *insn)
2398
2399
return 0 ;
2399
2400
}
2400
2401
2401
- static int __annotate_retpoline_safe (int type , struct instruction * insn )
2402
+ static int __annotate_ifc (struct objtool_file * file , int type , struct instruction * insn )
2403
+ {
2404
+ unsigned long dest_off ;
2405
+
2406
+ if (type != ANNOTYPE_INTRA_FUNCTION_CALL )
2407
+ return 0 ;
2408
+
2409
+ if (insn -> type != INSN_CALL ) {
2410
+ WARN_INSN (insn , "intra_function_call not a direct call" );
2411
+ return -1 ;
2412
+ }
2413
+
2414
+ /*
2415
+ * Treat intra-function CALLs as JMPs, but with a stack_op.
2416
+ * See add_call_destinations(), which strips stack_ops from
2417
+ * normal CALLs.
2418
+ */
2419
+ insn -> type = INSN_JUMP_UNCONDITIONAL ;
2420
+
2421
+ dest_off = arch_jump_destination (insn );
2422
+ insn -> jump_dest = find_insn (file , insn -> sec , dest_off );
2423
+ if (!insn -> jump_dest ) {
2424
+ WARN_INSN (insn , "can't find call dest at %s+0x%lx" ,
2425
+ insn -> sec -> name , dest_off );
2426
+ return -1 ;
2427
+ }
2428
+
2429
+ return 0 ;
2430
+ }
2431
+
2432
+ static int __annotate_retpoline_safe (struct objtool_file * file , int type , struct instruction * insn )
2402
2433
{
2403
2434
if (type != ANNOTYPE_RETPOLINE_SAFE )
2404
2435
return 0 ;
@@ -2415,7 +2446,7 @@ static int __annotate_retpoline_safe(int type, struct instruction *insn)
2415
2446
return 0 ;
2416
2447
}
2417
2448
2418
- static int __annotate_instr (int type , struct instruction * insn )
2449
+ static int __annotate_instr (struct objtool_file * file , int type , struct instruction * insn )
2419
2450
{
2420
2451
switch (type ) {
2421
2452
case ANNOTYPE_INSTR_BEGIN :
@@ -2433,7 +2464,7 @@ static int __annotate_instr(int type, struct instruction *insn)
2433
2464
return 0 ;
2434
2465
}
2435
2466
2436
- static int __annotate_unret (int type , struct instruction * insn )
2467
+ static int __annotate_unret (struct objtool_file * file , int type , struct instruction * insn )
2437
2468
{
2438
2469
if (type != ANNOTYPE_UNRET_BEGIN )
2439
2470
return 0 ;
@@ -2443,55 +2474,6 @@ static int __annotate_unret(int type, struct instruction *insn)
2443
2474
2444
2475
}
2445
2476
2446
- static int read_intra_function_calls (struct objtool_file * file )
2447
- {
2448
- struct instruction * insn ;
2449
- struct section * rsec ;
2450
- struct reloc * reloc ;
2451
-
2452
- rsec = find_section_by_name (file -> elf , ".rela.discard.intra_function_calls" );
2453
- if (!rsec )
2454
- return 0 ;
2455
-
2456
- for_each_reloc (rsec , reloc ) {
2457
- unsigned long dest_off ;
2458
-
2459
- if (reloc -> sym -> type != STT_SECTION ) {
2460
- WARN ("unexpected relocation symbol type in %s" ,
2461
- rsec -> name );
2462
- return -1 ;
2463
- }
2464
-
2465
- insn = find_insn (file , reloc -> sym -> sec , reloc_addend (reloc ));
2466
- if (!insn ) {
2467
- WARN ("bad .discard.intra_function_call entry" );
2468
- return -1 ;
2469
- }
2470
-
2471
- if (insn -> type != INSN_CALL ) {
2472
- WARN_INSN (insn , "intra_function_call not a direct call" );
2473
- return -1 ;
2474
- }
2475
-
2476
- /*
2477
- * Treat intra-function CALLs as JMPs, but with a stack_op.
2478
- * See add_call_destinations(), which strips stack_ops from
2479
- * normal CALLs.
2480
- */
2481
- insn -> type = INSN_JUMP_UNCONDITIONAL ;
2482
-
2483
- dest_off = arch_jump_destination (insn );
2484
- insn -> jump_dest = find_insn (file , insn -> sec , dest_off );
2485
- if (!insn -> jump_dest ) {
2486
- WARN_INSN (insn , "can't find call dest at %s+0x%lx" ,
2487
- insn -> sec -> name , dest_off );
2488
- return -1 ;
2489
- }
2490
- }
2491
-
2492
- return 0 ;
2493
- }
2494
-
2495
2477
/*
2496
2478
* Return true if name matches an instrumentation function, where calls to that
2497
2479
* function from noinstr code can safely be removed, but compilers won't do so.
@@ -2630,7 +2612,7 @@ static int decode_sections(struct objtool_file *file)
2630
2612
* Must be before add_call_destination(); it changes INSN_CALL to
2631
2613
* INSN_JUMP.
2632
2614
*/
2633
- ret = read_intra_function_calls (file );
2615
+ ret = read_annotate (file , __annotate_ifc );
2634
2616
if (ret )
2635
2617
return ret ;
2636
2618
0 commit comments