@@ -2381,21 +2381,24 @@ static int read_annotate(struct objtool_file *file,
23812381 return 0 ;
23822382}
23832383
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 )
23852385{
2386- if (type != ANNOTYPE_IGNORE_ALTS )
2387- return 0 ;
2386+ switch (type ) {
2387+ case ANNOTYPE_IGNORE_ALTS :
2388+ insn -> ignore_alts = true;
2389+ break ;
23882390
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 ;
23922397
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+ }
23972401
2398- insn -> noendbr = 1 ;
23992402 return 0 ;
24002403}
24012404
@@ -2429,26 +2432,21 @@ static int __annotate_ifc(struct objtool_file *file, int type, struct instructio
24292432 return 0 ;
24302433}
24312434
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 )
24332436{
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+ }
24442446
2445- insn -> retpoline_safe = true;
2446- return 0 ;
2447- }
2447+ insn -> retpoline_safe = true;
2448+ break ;
24482449
2449- static int __annotate_instr (struct objtool_file * file , int type , struct instruction * insn )
2450- {
2451- switch (type ) {
24522450 case ANNOTYPE_INSTR_BEGIN :
24532451 insn -> instr ++ ;
24542452 break ;
@@ -2457,23 +2455,17 @@ static int __annotate_instr(struct objtool_file *file, int type, struct instruct
24572455 insn -> instr -- ;
24582456 break ;
24592457
2458+ case ANNOTYPE_UNRET_BEGIN :
2459+ insn -> unret = 1 ;
2460+ break ;
2461+
24602462 default :
24612463 break ;
24622464 }
24632465
24642466 return 0 ;
24652467}
24662468
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-
24772469/*
24782470 * Return true if name matches an instrumentation function, where calls to that
24792471 * 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)
25832575 add_ignores (file );
25842576 add_uaccess_safe (file );
25852577
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 );
25942579 if (ret )
25952580 return ret ;
25962581
@@ -2636,15 +2621,7 @@ static int decode_sections(struct objtool_file *file)
26362621 if (ret )
26372622 return ret ;
26382623
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 );
26482625 if (ret )
26492626 return ret ;
26502627
0 commit comments