@@ -2440,48 +2440,19 @@ static int __annotate_retpoline_safe(int type, struct instruction *insn)
24402440 return 0 ;
24412441}
24422442
2443- static int read_instr_hints ( struct objtool_file * file )
2443+ static int __annotate_instr ( int type , struct instruction * insn )
24442444{
2445- struct section * rsec ;
2446- struct instruction * insn ;
2447- struct reloc * reloc ;
2448-
2449- rsec = find_section_by_name (file -> elf , ".rela.discard.instr_end" );
2450- if (!rsec )
2451- return 0 ;
2452-
2453- for_each_reloc (rsec , reloc ) {
2454- if (reloc -> sym -> type != STT_SECTION ) {
2455- WARN ("unexpected relocation symbol type in %s" , rsec -> name );
2456- return -1 ;
2457- }
2458-
2459- insn = find_insn (file , reloc -> sym -> sec , reloc_addend (reloc ));
2460- if (!insn ) {
2461- WARN ("bad .discard.instr_end entry" );
2462- return -1 ;
2463- }
2445+ switch (type ) {
2446+ case ANNOTYPE_INSTR_BEGIN :
2447+ insn -> instr ++ ;
2448+ break ;
24642449
2450+ case ANNOTYPE_INSTR_END :
24652451 insn -> instr -- ;
2466- }
2467-
2468- rsec = find_section_by_name (file -> elf , ".rela.discard.instr_begin" );
2469- if (!rsec )
2470- return 0 ;
2471-
2472- for_each_reloc (rsec , reloc ) {
2473- if (reloc -> sym -> type != STT_SECTION ) {
2474- WARN ("unexpected relocation symbol type in %s" , rsec -> name );
2475- return -1 ;
2476- }
2477-
2478- insn = find_insn (file , reloc -> sym -> sec , reloc_addend (reloc ));
2479- if (!insn ) {
2480- WARN ("bad .discard.instr_begin entry" );
2481- return -1 ;
2482- }
2452+ break ;
24832453
2484- insn -> instr ++ ;
2454+ default :
2455+ break ;
24852456 }
24862457
24872458 return 0 ;
@@ -2730,7 +2701,7 @@ static int decode_sections(struct objtool_file *file)
27302701 if (ret )
27312702 return ret ;
27322703
2733- ret = read_instr_hints (file );
2704+ ret = read_annotate (file , __annotate_instr );
27342705 if (ret )
27352706 return ret ;
27362707
0 commit comments