@@ -2381,21 +2381,24 @@ static int read_annotate(struct objtool_file *file,
2381
2381
return 0 ;
2382
2382
}
2383
2383
2384
- static int __annotate_ignore_alts (struct objtool_file * file , int type , struct instruction * insn )
2384
+ static int __annotate_early (struct objtool_file * file , int type , struct instruction * insn )
2385
2385
{
2386
- if (type != ANNOTYPE_IGNORE_ALTS )
2387
- return 0 ;
2386
+ switch (type ) {
2387
+ case ANNOTYPE_IGNORE_ALTS :
2388
+ insn -> ignore_alts = true;
2389
+ break ;
2388
2390
2389
- insn -> ignore_alts = true;
2390
- return 0 ;
2391
- }
2391
+ /*
2392
+ * Must be before read_unwind_hints() since that needs insn->noendbr.
2393
+ */
2394
+ case ANNOTYPE_NOENDBR :
2395
+ insn -> noendbr = 1 ;
2396
+ break ;
2392
2397
2393
- static int __annotate_noendbr (struct objtool_file * file , int type , struct instruction * insn )
2394
- {
2395
- if (type != ANNOTYPE_NOENDBR )
2396
- return 0 ;
2398
+ default :
2399
+ break ;
2400
+ }
2397
2401
2398
- insn -> noendbr = 1 ;
2399
2402
return 0 ;
2400
2403
}
2401
2404
@@ -2429,26 +2432,21 @@ static int __annotate_ifc(struct objtool_file *file, int type, struct instructio
2429
2432
return 0 ;
2430
2433
}
2431
2434
2432
- static int __annotate_retpoline_safe (struct objtool_file * file , int type , struct instruction * insn )
2435
+ static int __annotate_late (struct objtool_file * file , int type , struct instruction * insn )
2433
2436
{
2434
- if (type != ANNOTYPE_RETPOLINE_SAFE )
2435
- return 0 ;
2436
-
2437
- if (insn -> type != INSN_JUMP_DYNAMIC &&
2438
- insn -> type != INSN_CALL_DYNAMIC &&
2439
- insn -> type != INSN_RETURN &&
2440
- insn -> type != INSN_NOP ) {
2441
- WARN_INSN (insn , "retpoline_safe hint not an indirect jump/call/ret/nop" );
2442
- return -1 ;
2443
- }
2437
+ switch (type ) {
2438
+ case ANNOTYPE_RETPOLINE_SAFE :
2439
+ if (insn -> type != INSN_JUMP_DYNAMIC &&
2440
+ insn -> type != INSN_CALL_DYNAMIC &&
2441
+ insn -> type != INSN_RETURN &&
2442
+ insn -> type != INSN_NOP ) {
2443
+ WARN_INSN (insn , "retpoline_safe hint not an indirect jump/call/ret/nop" );
2444
+ return -1 ;
2445
+ }
2444
2446
2445
- insn -> retpoline_safe = true;
2446
- return 0 ;
2447
- }
2447
+ insn -> retpoline_safe = true;
2448
+ break ;
2448
2449
2449
- static int __annotate_instr (struct objtool_file * file , int type , struct instruction * insn )
2450
- {
2451
- switch (type ) {
2452
2450
case ANNOTYPE_INSTR_BEGIN :
2453
2451
insn -> instr ++ ;
2454
2452
break ;
@@ -2457,23 +2455,17 @@ static int __annotate_instr(struct objtool_file *file, int type, struct instruct
2457
2455
insn -> instr -- ;
2458
2456
break ;
2459
2457
2458
+ case ANNOTYPE_UNRET_BEGIN :
2459
+ insn -> unret = 1 ;
2460
+ break ;
2461
+
2460
2462
default :
2461
2463
break ;
2462
2464
}
2463
2465
2464
2466
return 0 ;
2465
2467
}
2466
2468
2467
- static int __annotate_unret (struct objtool_file * file , int type , struct instruction * insn )
2468
- {
2469
- if (type != ANNOTYPE_UNRET_BEGIN )
2470
- return 0 ;
2471
-
2472
- insn -> unret = 1 ;
2473
- return 0 ;
2474
-
2475
- }
2476
-
2477
2469
/*
2478
2470
* Return true if name matches an instrumentation function, where calls to that
2479
2471
* function from noinstr code can safely be removed, but compilers won't do so.
@@ -2583,14 +2575,7 @@ static int decode_sections(struct objtool_file *file)
2583
2575
add_ignores (file );
2584
2576
add_uaccess_safe (file );
2585
2577
2586
- ret = read_annotate (file , __annotate_ignore_alts );
2587
- if (ret )
2588
- return ret ;
2589
-
2590
- /*
2591
- * Must be before read_unwind_hints() since that needs insn->noendbr.
2592
- */
2593
- ret = read_annotate (file , __annotate_noendbr );
2578
+ ret = read_annotate (file , __annotate_early );
2594
2579
if (ret )
2595
2580
return ret ;
2596
2581
@@ -2636,15 +2621,7 @@ static int decode_sections(struct objtool_file *file)
2636
2621
if (ret )
2637
2622
return ret ;
2638
2623
2639
- ret = read_annotate (file , __annotate_retpoline_safe );
2640
- if (ret )
2641
- return ret ;
2642
-
2643
- ret = read_annotate (file , __annotate_instr );
2644
- if (ret )
2645
- return ret ;
2646
-
2647
- ret = read_annotate (file , __annotate_unret );
2624
+ ret = read_annotate (file , __annotate_late );
2648
2625
if (ret )
2649
2626
return ret ;
2650
2627
0 commit comments