Lines Matching refs:file
38 struct instruction *find_insn(struct objtool_file *file, in find_insn() argument
43 hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) { in find_insn()
51 struct instruction *next_insn_same_sec(struct objtool_file *file, in next_insn_same_sec() argument
55 return find_insn(file, insn->sec, insn->offset + insn->len); in next_insn_same_sec()
64 static struct instruction *next_insn_same_func(struct objtool_file *file, in next_insn_same_func() argument
67 struct instruction *next = next_insn_same_sec(file, insn); in next_insn_same_func()
81 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
84 static struct instruction *prev_insn_same_sec(struct objtool_file *file, in prev_insn_same_sec() argument
89 return find_insn(file, insn->sec, insn->offset - insn->prev_len); in prev_insn_same_sec()
96 static struct instruction *prev_insn_same_sym(struct objtool_file *file, in prev_insn_same_sym() argument
99 struct instruction *prev = prev_insn_same_sec(file, insn); in prev_insn_same_sym()
107 #define for_each_insn(file, insn) \ argument
110 for_each_sec(file, __sec) \
111 sec_for_each_insn(file, __sec, insn)
113 #define func_for_each_insn(file, func, insn) \ argument
114 for (insn = find_insn(file, func->sec, func->offset); \
116 insn = next_insn_same_func(file, insn))
118 #define sym_for_each_insn(file, sym, insn) \ argument
119 for (insn = find_insn(file, sym->sec, sym->offset); \
121 insn = next_insn_same_sec(file, insn))
123 #define sym_for_each_insn_continue_reverse(file, sym, insn) \ argument
124 for (insn = prev_insn_same_sec(file, insn); \
126 insn = prev_insn_same_sec(file, insn))
128 #define sec_for_each_insn_from(file, insn) \ argument
129 for (; insn; insn = next_insn_same_sec(file, insn))
131 #define sec_for_each_insn_continue(file, insn) \ argument
132 for (insn = next_insn_same_sec(file, insn); insn; \
133 insn = next_insn_same_sec(file, insn))
235 static bool __dead_end_function(struct objtool_file *file, struct symbol *func, in __dead_end_function() argument
266 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
270 func_for_each_insn(file, func, insn) { in __dead_end_function()
285 func_for_each_insn(file, func, insn) { in __dead_end_function()
303 return __dead_end_function(file, insn_func(dest), recursion+1); in __dead_end_function()
310 static bool dead_end_function(struct objtool_file *file, struct symbol *func) in dead_end_function() argument
312 return __dead_end_function(file, func, 0); in dead_end_function()
328 static void init_insn_state(struct objtool_file *file, struct insn_state *state, in init_insn_state() argument
419 static int decode_instructions(struct objtool_file *file) in decode_instructions() argument
427 for_each_sec(file, sec) { in decode_instructions()
474 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
490 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
512 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
518 sym_for_each_insn(file, func, insn) { in decode_instructions()
524 list_add_tail(&insn->call_node, &file->endbr_list); in decode_instructions()
525 file->nr_endbr++; in decode_instructions()
527 file->nr_endbr_int++; in decode_instructions()
543 static int add_pv_ops(struct objtool_file *file, const char *symname) in add_pv_ops() argument
550 sym = find_symbol_by_name(file->elf, symname); in add_pv_ops()
557 reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
568 objtool_pv_add(file, idx, func); in add_pv_ops()
581 static int init_pv_ops(struct objtool_file *file) in init_pv_ops() argument
597 file->pv_ops = NULL; in init_pv_ops()
599 sym = find_symbol_by_name(file->elf, "pv_ops"); in init_pv_ops()
604 file->pv_ops = calloc(sizeof(struct pv_state), nr); in init_pv_ops()
605 if (!file->pv_ops) in init_pv_ops()
609 INIT_LIST_HEAD(&file->pv_ops[idx].targets); in init_pv_ops()
612 add_pv_ops(file, pv_ops); in init_pv_ops()
617 static struct instruction *find_last_insn(struct objtool_file *file, in find_last_insn() argument
625 insn = find_insn(file, sec, offset); in find_last_insn()
633 static int add_dead_ends(struct objtool_file *file) in add_dead_ends() argument
643 rsec = find_section_by_name(file->elf, ".rela.discard.unreachable"); in add_dead_ends()
657 insn = find_insn(file, reloc->sym->sec, offset); in add_dead_ends()
659 insn = prev_insn_same_sec(file, insn); in add_dead_ends()
661 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
683 rsec = find_section_by_name(file->elf, ".rela.discard.reachable"); in add_dead_ends()
697 insn = find_insn(file, reloc->sym->sec, offset); in add_dead_ends()
699 insn = prev_insn_same_sec(file, insn); in add_dead_ends()
701 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
719 static int create_static_call_sections(struct objtool_file *file) in create_static_call_sections() argument
728 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
730 INIT_LIST_HEAD(&file->static_call_list); in create_static_call_sections()
735 if (list_empty(&file->static_call_list)) in create_static_call_sections()
739 list_for_each_entry(insn, &file->static_call_list, call_node) in create_static_call_sections()
742 sec = elf_create_section_pair(file->elf, ".static_call_sites", in create_static_call_sections()
751 list_for_each_entry(insn, &file->static_call_list, call_node) { in create_static_call_sections()
754 if (!elf_init_reloc_text_sym(file->elf, sec, in create_static_call_sections()
774 key_sym = find_symbol_by_name(file->elf, tmp); in create_static_call_sections()
796 if (!elf_init_reloc_data_sym(file->elf, sec, in create_static_call_sections()
808 static int create_retpoline_sites_sections(struct objtool_file *file) in create_retpoline_sites_sections() argument
814 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
821 list_for_each_entry(insn, &file->retpoline_call_list, call_node) in create_retpoline_sites_sections()
827 sec = elf_create_section_pair(file->elf, ".retpoline_sites", in create_retpoline_sites_sections()
833 list_for_each_entry(insn, &file->retpoline_call_list, call_node) { in create_retpoline_sites_sections()
835 if (!elf_init_reloc_text_sym(file->elf, sec, in create_retpoline_sites_sections()
846 static int create_return_sites_sections(struct objtool_file *file) in create_return_sites_sections() argument
852 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
859 list_for_each_entry(insn, &file->return_thunk_list, call_node) in create_return_sites_sections()
865 sec = elf_create_section_pair(file->elf, ".return_sites", in create_return_sites_sections()
871 list_for_each_entry(insn, &file->return_thunk_list, call_node) { in create_return_sites_sections()
873 if (!elf_init_reloc_text_sym(file->elf, sec, in create_return_sites_sections()
884 static int create_ibt_endbr_seal_sections(struct objtool_file *file) in create_ibt_endbr_seal_sections() argument
890 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
897 list_for_each_entry(insn, &file->endbr_list, call_node) in create_ibt_endbr_seal_sections()
901 printf("ibt: ENDBR at function start: %d\n", file->nr_endbr); in create_ibt_endbr_seal_sections()
902 printf("ibt: ENDBR inside functions: %d\n", file->nr_endbr_int); in create_ibt_endbr_seal_sections()
909 sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal", in create_ibt_endbr_seal_sections()
915 list_for_each_entry(insn, &file->endbr_list, call_node) { in create_ibt_endbr_seal_sections()
927 if (!elf_init_reloc_text_sym(file->elf, sec, in create_ibt_endbr_seal_sections()
938 static int create_cfi_sections(struct objtool_file *file) in create_cfi_sections() argument
944 sec = find_section_by_name(file->elf, ".cfi_sites"); in create_cfi_sections()
946 INIT_LIST_HEAD(&file->call_list); in create_cfi_sections()
952 for_each_sym(file, sym) { in create_cfi_sections()
962 sec = elf_create_section_pair(file->elf, ".cfi_sites", in create_cfi_sections()
968 for_each_sym(file, sym) { in create_cfi_sections()
975 if (!elf_init_reloc_text_sym(file->elf, sec, in create_cfi_sections()
986 static int create_mcount_loc_sections(struct objtool_file *file) in create_mcount_loc_sections() argument
988 size_t addr_size = elf_addr_size(file->elf); in create_mcount_loc_sections()
993 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
995 INIT_LIST_HEAD(&file->mcount_loc_list); in create_mcount_loc_sections()
1000 if (list_empty(&file->mcount_loc_list)) in create_mcount_loc_sections()
1004 list_for_each_entry(insn, &file->mcount_loc_list, call_node) in create_mcount_loc_sections()
1007 sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size, in create_mcount_loc_sections()
1015 list_for_each_entry(insn, &file->mcount_loc_list, call_node) { in create_mcount_loc_sections()
1019 reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx, in create_mcount_loc_sections()
1024 set_reloc_type(file->elf, reloc, addr_size == 8 ? R_ABS64 : R_ABS32); in create_mcount_loc_sections()
1032 static int create_direct_call_sections(struct objtool_file *file) in create_direct_call_sections() argument
1038 sec = find_section_by_name(file->elf, ".call_sites"); in create_direct_call_sections()
1040 INIT_LIST_HEAD(&file->call_list); in create_direct_call_sections()
1045 if (list_empty(&file->call_list)) in create_direct_call_sections()
1049 list_for_each_entry(insn, &file->call_list, call_node) in create_direct_call_sections()
1052 sec = elf_create_section_pair(file->elf, ".call_sites", in create_direct_call_sections()
1058 list_for_each_entry(insn, &file->call_list, call_node) { in create_direct_call_sections()
1060 if (!elf_init_reloc_text_sym(file->elf, sec, in create_direct_call_sections()
1074 static void add_ignores(struct objtool_file *file) in add_ignores() argument
1081 rsec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
1103 func_for_each_insn(file, func, insn) in add_ignores()
1295 static void add_uaccess_safe(struct objtool_file *file) in add_uaccess_safe() argument
1304 func = find_symbol_by_name(file->elf, *name); in add_uaccess_safe()
1318 static int add_ignore_alternatives(struct objtool_file *file) in add_ignore_alternatives() argument
1324 rsec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
1334 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in add_ignore_alternatives()
1373 static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn) in insn_reloc() argument
1380 if (!file) in insn_reloc()
1383 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1404 static void annotate_call_site(struct objtool_file *file, in annotate_call_site() argument
1407 struct reloc *reloc = insn_reloc(file, insn); in annotate_call_site()
1423 list_add_tail(&insn->call_node, &file->static_call_list); in annotate_call_site()
1428 list_add_tail(&insn->call_node, &file->retpoline_call_list); in annotate_call_site()
1439 set_reloc_type(file->elf, reloc, R_NONE); in annotate_call_site()
1441 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1466 set_reloc_type(file->elf, reloc, R_NONE); in annotate_call_site()
1468 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1475 list_add_tail(&insn->call_node, &file->mcount_loc_list); in annotate_call_site()
1480 list_add_tail(&insn->call_node, &file->call_list); in annotate_call_site()
1482 if (!sibling && dead_end_function(file, sym)) in annotate_call_site()
1486 static void add_call_dest(struct objtool_file *file, struct instruction *insn, in add_call_dest() argument
1502 annotate_call_site(file, insn, sibling); in add_call_dest()
1505 static void add_retpoline_call(struct objtool_file *file, struct instruction *insn) in add_retpoline_call() argument
1536 annotate_call_site(file, insn, false); in add_retpoline_call()
1539 static void add_return_call(struct objtool_file *file, struct instruction *insn, bool add) in add_return_call() argument
1549 list_add_tail(&insn->call_node, &file->return_thunk_list); in add_return_call()
1552 static bool is_first_func_insn(struct objtool_file *file, in is_first_func_insn() argument
1560 struct instruction *prev = prev_insn_same_sym(file, insn); in is_first_func_insn()
1574 static bool jump_is_sibling_call(struct objtool_file *file, in jump_is_sibling_call() argument
1585 if (!is_first_func_insn(file, to, ts)) in jump_is_sibling_call()
1599 static int add_jump_destinations(struct objtool_file *file) in add_jump_destinations() argument
1606 for_each_insn(file, insn) { in add_jump_destinations()
1617 reloc = insn_reloc(file, insn); in add_jump_destinations()
1625 add_retpoline_call(file, insn); in add_jump_destinations()
1628 add_return_call(file, insn, true); in add_jump_destinations()
1635 add_call_dest(file, insn, reloc->sym, true); in add_jump_destinations()
1646 jump_dest = find_insn(file, dest_sec, dest_off); in add_jump_destinations()
1659 add_return_call(file, insn, false); in add_jump_destinations()
1675 add_retpoline_call(file, insn); in add_jump_destinations()
1679 add_return_call(file, insn, true); in add_jump_destinations()
1712 if (jump_is_sibling_call(file, insn, jump_dest)) { in add_jump_destinations()
1717 add_call_dest(file, insn, insn_func(jump_dest), true); in add_jump_destinations()
1741 static int add_call_destinations(struct objtool_file *file) in add_call_destinations() argument
1748 for_each_insn(file, insn) { in add_call_destinations()
1752 reloc = insn_reloc(file, insn); in add_call_destinations()
1757 add_call_dest(file, insn, dest, false); in add_call_destinations()
1781 add_call_dest(file, insn, dest, false); in add_call_destinations()
1784 add_retpoline_call(file, insn); in add_call_destinations()
1787 add_call_dest(file, insn, reloc->sym, false); in add_call_destinations()
1797 static int handle_group_alt(struct objtool_file *file, in handle_group_alt() argument
1823 sec_for_each_insn_from(file, insn) { in handle_group_alt()
1882 sec_for_each_insn_from(file, insn) { in handle_group_alt()
1902 alt_reloc = insn_reloc(file, insn); in handle_group_alt()
1918 insn->jump_dest = next_insn_same_sec(file, orig_alt_group->last_insn); in handle_group_alt()
1946 static int handle_jump_alt(struct objtool_file *file, in handle_jump_alt() argument
1959 struct reloc *reloc = insn_reloc(file, orig_insn); in handle_jump_alt()
1962 set_reloc_type(file->elf, reloc, R_NONE); in handle_jump_alt()
1963 elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
1971 file->jl_nop_short++; in handle_jump_alt()
1973 file->jl_nop_long++; in handle_jump_alt()
1979 file->jl_short++; in handle_jump_alt()
1981 file->jl_long++; in handle_jump_alt()
1983 *new_insn = next_insn_same_sec(file, orig_insn); in handle_jump_alt()
1993 static int add_special_section_alts(struct objtool_file *file) in add_special_section_alts() argument
2001 ret = special_get_alts(file->elf, &special_alts); in add_special_section_alts()
2007 orig_insn = find_insn(file, special_alt->orig_sec, in add_special_section_alts()
2018 new_insn = find_insn(file, special_alt->new_sec, in add_special_section_alts()
2035 ret = handle_group_alt(file, special_alt, orig_insn, in add_special_section_alts()
2040 ret = handle_jump_alt(file, special_alt, orig_insn, in add_special_section_alts()
2065 printf("short:\t%ld\t%ld\n", file->jl_nop_short, file->jl_short); in add_special_section_alts()
2066 printf("long:\t%ld\t%ld\n", file->jl_nop_long, file->jl_long); in add_special_section_alts()
2073 static int add_jump_table(struct objtool_file *file, struct instruction *insn, in add_jump_table() argument
2102 dest_insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in add_jump_table()
2134 static struct reloc *find_jump_table(struct objtool_file *file, in find_jump_table() argument
2148 insn = insn->first_jump_src ?: prev_insn_same_sym(file, insn)) { in find_jump_table()
2160 table_reloc = arch_find_switch_table(file, insn); in find_jump_table()
2163 dest_insn = find_insn(file, table_reloc->sym->sec, reloc_addend(table_reloc)); in find_jump_table()
2177 static void mark_func_jump_tables(struct objtool_file *file, in mark_func_jump_tables() argument
2183 func_for_each_insn(file, func, insn) { in mark_func_jump_tables()
2204 reloc = find_jump_table(file, func, insn); in mark_func_jump_tables()
2210 static int add_func_jump_tables(struct objtool_file *file, in add_func_jump_tables() argument
2216 func_for_each_insn(file, func, insn) { in add_func_jump_tables()
2227 ret = add_jump_table(file, insn_t1, insn_jump_table(insn_t2)); in add_func_jump_tables()
2235 ret = add_jump_table(file, insn_t1, NULL); in add_func_jump_tables()
2245 static int add_jump_table_alts(struct objtool_file *file) in add_jump_table_alts() argument
2250 if (!file->rodata) in add_jump_table_alts()
2253 for_each_sym(file, func) { in add_jump_table_alts()
2257 mark_func_jump_tables(file, func); in add_jump_table_alts()
2258 ret = add_func_jump_tables(file, func); in add_jump_table_alts()
2275 static int read_unwind_hints(struct objtool_file *file) in read_unwind_hints() argument
2285 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2299 file->hints = true; in read_unwind_hints()
2304 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2319 insn = find_insn(file, reloc->sym->sec, offset); in read_unwind_hints()
2366 cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset); in read_unwind_hints()
2376 static int read_noendbr_hints(struct objtool_file *file) in read_noendbr_hints() argument
2382 rsec = find_section_by_name(file->elf, ".rela.discard.noendbr"); in read_noendbr_hints()
2387 insn = find_insn(file, reloc->sym->sec, in read_noendbr_hints()
2400 static int read_retpoline_hints(struct objtool_file *file) in read_retpoline_hints() argument
2406 rsec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
2416 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_retpoline_hints()
2436 static int read_instr_hints(struct objtool_file *file) in read_instr_hints() argument
2442 rsec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
2452 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_instr_hints()
2461 rsec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
2471 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_instr_hints()
2483 static int read_validate_unret_hints(struct objtool_file *file) in read_validate_unret_hints() argument
2489 rsec = find_section_by_name(file->elf, ".rela.discard.validate_unret"); in read_validate_unret_hints()
2499 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_validate_unret_hints()
2511 static int read_intra_function_calls(struct objtool_file *file) in read_intra_function_calls() argument
2517 rsec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
2530 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_intra_function_calls()
2549 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
2585 static int classify_symbols(struct objtool_file *file) in classify_symbols() argument
2589 for_each_sym(file, func) { in classify_symbols()
2619 static void mark_rodata(struct objtool_file *file) in mark_rodata() argument
2634 for_each_sec(file, sec) { in mark_rodata()
2642 file->rodata = found; in mark_rodata()
2645 static int decode_sections(struct objtool_file *file) in decode_sections() argument
2649 mark_rodata(file); in decode_sections()
2651 ret = init_pv_ops(file); in decode_sections()
2658 ret = classify_symbols(file); in decode_sections()
2662 ret = decode_instructions(file); in decode_sections()
2666 add_ignores(file); in decode_sections()
2667 add_uaccess_safe(file); in decode_sections()
2669 ret = add_ignore_alternatives(file); in decode_sections()
2676 ret = read_noendbr_hints(file); in decode_sections()
2685 ret = add_special_section_alts(file); in decode_sections()
2690 ret = add_jump_destinations(file); in decode_sections()
2698 ret = read_intra_function_calls(file); in decode_sections()
2702 ret = add_call_destinations(file); in decode_sections()
2710 ret = add_dead_ends(file); in decode_sections()
2714 ret = add_jump_table_alts(file); in decode_sections()
2718 ret = read_unwind_hints(file); in decode_sections()
2722 ret = read_retpoline_hints(file); in decode_sections()
2726 ret = read_instr_hints(file); in decode_sections()
2730 ret = read_validate_unret_hints(file); in decode_sections()
3326 static int propagate_alt_cfi(struct objtool_file *file, struct instruction *insn) in propagate_alt_cfi() argument
3470 static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) in pv_call_dest() argument
3476 reloc = insn_reloc(file, insn); in pv_call_dest()
3482 if (file->pv_ops[idx].clean) in pv_call_dest()
3485 file->pv_ops[idx].clean = true; in pv_call_dest()
3487 list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { in pv_call_dest()
3490 file->pv_ops[idx].clean = false; in pv_call_dest()
3494 return file->pv_ops[idx].clean; in pv_call_dest()
3497 static inline bool noinstr_call_dest(struct objtool_file *file, in noinstr_call_dest() argument
3506 if (file->pv_ops) in noinstr_call_dest()
3507 return pv_call_dest(file, insn); in noinstr_call_dest()
3535 static int validate_call(struct objtool_file *file, in validate_call() argument
3540 !noinstr_call_dest(file, insn, insn_call_dest(insn))) { in validate_call()
3558 static int validate_sibling_call(struct objtool_file *file, in validate_sibling_call() argument
3567 return validate_call(file, insn, state); in validate_sibling_call()
3605 static struct instruction *next_insn_to_validate(struct objtool_file *file, in next_insn_to_validate() argument
3632 return next_insn_same_sec(file, insn); in next_insn_to_validate()
3635 return next_insn_same_sec(file, alt_group->orig_group->last_insn); in next_insn_to_validate()
3644 static int validate_branch(struct objtool_file *file, struct symbol *func, in validate_branch() argument
3656 next_insn = next_insn_to_validate(file, insn); in validate_branch()
3695 sym_for_each_insn_continue_reverse(file, func, i) { in validate_branch()
3742 if (propagate_alt_cfi(file, insn)) in validate_branch()
3752 ret = validate_branch(file, func, alt->insn, state); in validate_branch()
3773 ret = validate_call(file, insn, &state); in validate_branch()
3791 ret = validate_sibling_call(file, insn, &state); in validate_branch()
3796 ret = validate_branch(file, func, in validate_branch()
3812 ret = validate_sibling_call(file, insn, &state); in validate_branch()
3891 static int validate_unwind_hint(struct objtool_file *file, in validate_unwind_hint() argument
3896 int ret = validate_branch(file, insn_func(insn), insn, *state); in validate_unwind_hint()
3905 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3911 if (!file->hints) in validate_unwind_hints()
3914 init_insn_state(file, &state, sec); in validate_unwind_hints()
3917 sec_for_each_insn(file, sec, insn) in validate_unwind_hints()
3918 warnings += validate_unwind_hint(file, insn, &state); in validate_unwind_hints()
3920 for_each_insn(file, insn) in validate_unwind_hints()
3921 warnings += validate_unwind_hint(file, insn, &state); in validate_unwind_hints()
3933 static int validate_unret(struct objtool_file *file, struct instruction *insn) in validate_unret() argument
3939 next = next_insn_to_validate(file, insn); in validate_unret()
3954 ret = validate_unret(file, alt->insn); in validate_unret()
3980 ret = validate_unret(file, insn->jump_dest); in validate_unret()
3995 dest = find_insn(file, insn_call_dest(insn)->sec, in validate_unret()
4003 ret = validate_unret(file, dest); in validate_unret()
4041 static int validate_unrets(struct objtool_file *file) in validate_unrets() argument
4046 for_each_insn(file, insn) { in validate_unrets()
4050 ret = validate_unret(file, insn); in validate_unrets()
4061 static int validate_retpoline(struct objtool_file *file) in validate_retpoline() argument
4066 for_each_insn(file, insn) { in validate_retpoline()
4107 static bool ignore_unreachable_insn(struct objtool_file *file, struct instruction *insn) in ignore_unreachable_insn() argument
4141 sec_for_each_insn_continue(file, insn) { in ignore_unreachable_insn()
4158 func_for_each_insn(file, insn_func(dest), dest) in ignore_unreachable_insn()
4180 prev_insn = prev_insn_same_sec(file, insn); in ignore_unreachable_insn()
4211 insn = next_insn_same_sec(file, insn); in ignore_unreachable_insn()
4217 static int add_prefix_symbol(struct objtool_file *file, struct symbol *func) in add_prefix_symbol() argument
4222 insn = find_insn(file, func->sec, func->offset); in add_prefix_symbol()
4226 for (prev = prev_insn_same_sec(file, insn); in add_prefix_symbol()
4228 prev = prev_insn_same_sec(file, prev)) { in add_prefix_symbol()
4242 elf_create_prefix_symbol(file->elf, func, opts.prefix); in add_prefix_symbol()
4259 for (; prev != insn; prev = next_insn_same_sec(file, prev)) in add_prefix_symbol()
4265 static int add_prefix_symbols(struct objtool_file *file) in add_prefix_symbols() argument
4270 for_each_sec(file, sec) { in add_prefix_symbols()
4278 add_prefix_symbol(file, func); in add_prefix_symbols()
4285 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
4299 insn = find_insn(file, sec, sym->offset); in validate_symbol()
4305 ret = validate_branch(file, insn_func(insn), insn, *state); in validate_symbol()
4311 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
4321 init_insn_state(file, &state, sec); in validate_section()
4324 warnings += validate_symbol(file, sec, func, &state); in validate_section()
4330 static int validate_noinstr_sections(struct objtool_file *file) in validate_noinstr_sections() argument
4335 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
4337 warnings += validate_section(file, sec); in validate_noinstr_sections()
4338 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4341 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
4343 warnings += validate_section(file, sec); in validate_noinstr_sections()
4344 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4347 sec = find_section_by_name(file->elf, ".cpuidle.text"); in validate_noinstr_sections()
4349 warnings += validate_section(file, sec); in validate_noinstr_sections()
4350 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4356 static int validate_functions(struct objtool_file *file) in validate_functions() argument
4361 for_each_sec(file, sec) { in validate_functions()
4365 warnings += validate_section(file, sec); in validate_functions()
4377 static bool noendbr_range(struct objtool_file *file, struct instruction *insn) in noendbr_range() argument
4385 first = find_insn(file, sym->sec, sym->offset); in noendbr_range()
4395 static int validate_ibt_insn(struct objtool_file *file, struct instruction *insn) in validate_ibt_insn() argument
4420 for (reloc = insn_reloc(file, insn); in validate_ibt_insn()
4422 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4440 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4479 if (noendbr_range(file, dest)) in validate_ibt_insn()
4490 static int validate_ibt_data_reloc(struct objtool_file *file, in validate_ibt_data_reloc() argument
4495 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4520 static int validate_ibt(struct objtool_file *file) in validate_ibt() argument
4527 for_each_insn(file, insn) in validate_ibt()
4528 warnings += validate_ibt_insn(file, insn); in validate_ibt()
4530 for_each_sec(file, sec) { in validate_ibt()
4564 warnings += validate_ibt_data_reloc(file, reloc); in validate_ibt()
4570 static int validate_sls(struct objtool_file *file) in validate_sls() argument
4575 for_each_insn(file, insn) { in validate_sls()
4576 next_insn = next_insn_same_sec(file, insn); in validate_sls()
4632 static int validate_reachable_instructions(struct objtool_file *file) in validate_reachable_instructions() argument
4638 if (file->ignore_unreachables) in validate_reachable_instructions()
4641 for_each_insn(file, insn) { in validate_reachable_instructions()
4642 if (insn->visited || ignore_unreachable_insn(file, insn)) in validate_reachable_instructions()
4645 prev_insn = prev_insn_same_sec(file, insn); in validate_reachable_instructions()
4713 static int disas_warned_funcs(struct objtool_file *file) in disas_warned_funcs() argument
4718 for_each_sym(file, sym) { in disas_warned_funcs()
4748 static void free_insns(struct objtool_file *file) in free_insns() argument
4753 for_each_insn(file, insn) { in free_insns()
4766 int check(struct objtool_file *file) in check() argument
4777 if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) in check()
4783 ret = decode_sections(file); in check()
4793 ret = validate_retpoline(file); in check()
4800 ret = validate_functions(file); in check()
4805 ret = validate_unwind_hints(file, NULL); in check()
4811 ret = validate_reachable_instructions(file); in check()
4818 ret = validate_noinstr_sections(file); in check()
4829 ret = validate_unrets(file); in check()
4836 ret = validate_ibt(file); in check()
4843 ret = validate_sls(file); in check()
4850 ret = create_static_call_sections(file); in check()
4857 ret = create_retpoline_sites_sections(file); in check()
4864 ret = create_cfi_sections(file); in check()
4871 ret = create_return_sites_sections(file); in check()
4877 ret = create_direct_call_sections(file); in check()
4885 ret = create_mcount_loc_sections(file); in check()
4892 ret = add_prefix_symbols(file); in check()
4899 ret = create_ibt_endbr_seal_sections(file); in check()
4906 ret = orc_create(file); in check()
4912 free_insns(file); in check()
4915 disas_warned_funcs(file); in check()