Lines Matching refs:file

37 struct instruction *find_insn(struct objtool_file *file,  in find_insn()  argument
42 hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) { in find_insn()
50 struct instruction *next_insn_same_sec(struct objtool_file *file, in next_insn_same_sec() argument
54 return find_insn(file, insn->sec, insn->offset + insn->len); in next_insn_same_sec()
63 static struct instruction *next_insn_same_func(struct objtool_file *file, in next_insn_same_func() argument
66 struct instruction *next = next_insn_same_sec(file, insn); in next_insn_same_func()
80 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
83 static struct instruction *prev_insn_same_sec(struct objtool_file *file, in prev_insn_same_sec() argument
88 return find_insn(file, insn->sec, insn->offset - insn->prev_len); in prev_insn_same_sec()
95 static struct instruction *prev_insn_same_sym(struct objtool_file *file, in prev_insn_same_sym() argument
98 struct instruction *prev = prev_insn_same_sec(file, insn); in prev_insn_same_sym()
106 #define for_each_insn(file, insn) \ argument
109 for_each_sec(file, __sec) \
110 sec_for_each_insn(file, __sec, insn)
112 #define func_for_each_insn(file, func, insn) \ argument
113 for (insn = find_insn(file, func->sec, func->offset); \
115 insn = next_insn_same_func(file, insn))
117 #define sym_for_each_insn(file, sym, insn) \ argument
118 for (insn = find_insn(file, sym->sec, sym->offset); \
120 insn = next_insn_same_sec(file, insn))
122 #define sym_for_each_insn_continue_reverse(file, sym, insn) \ argument
123 for (insn = prev_insn_same_sec(file, insn); \
125 insn = prev_insn_same_sec(file, insn))
127 #define sec_for_each_insn_from(file, insn) \ argument
128 for (; insn; insn = next_insn_same_sec(file, insn))
130 #define sec_for_each_insn_continue(file, insn) \ argument
131 for (insn = next_insn_same_sec(file, insn); insn; \
132 insn = next_insn_same_sec(file, insn))
248 static bool __dead_end_function(struct objtool_file *file, struct symbol *func, in __dead_end_function() argument
279 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
283 func_for_each_insn(file, func, insn) { in __dead_end_function()
298 func_for_each_insn(file, func, insn) { in __dead_end_function()
316 return __dead_end_function(file, insn_func(dest), recursion+1); in __dead_end_function()
323 static bool dead_end_function(struct objtool_file *file, struct symbol *func) in dead_end_function() argument
325 return __dead_end_function(file, func, 0); in dead_end_function()
341 static void init_insn_state(struct objtool_file *file, struct insn_state *state, in init_insn_state() argument
427 static int decode_instructions(struct objtool_file *file) in decode_instructions() argument
435 for_each_sec(file, sec) { in decode_instructions()
482 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
498 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
517 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
522 sym_for_each_insn(file, func, insn) { in decode_instructions()
528 list_add_tail(&insn->call_node, &file->endbr_list); in decode_instructions()
529 file->nr_endbr++; in decode_instructions()
531 file->nr_endbr_int++; in decode_instructions()
547 static int add_pv_ops(struct objtool_file *file, const char *symname) in add_pv_ops() argument
554 sym = find_symbol_by_name(file->elf, symname); in add_pv_ops()
561 reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
577 if (objtool_pv_add(file, idx, func)) in add_pv_ops()
591 static int init_pv_ops(struct objtool_file *file) in init_pv_ops() argument
607 file->pv_ops = NULL; in init_pv_ops()
609 sym = find_symbol_by_name(file->elf, "pv_ops"); in init_pv_ops()
614 file->pv_ops = calloc(sizeof(struct pv_state), nr); in init_pv_ops()
615 if (!file->pv_ops) { in init_pv_ops()
621 INIT_LIST_HEAD(&file->pv_ops[idx].targets); in init_pv_ops()
624 ret = add_pv_ops(file, pv_ops); in init_pv_ops()
632 static int create_static_call_sections(struct objtool_file *file) in create_static_call_sections() argument
641 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
643 INIT_LIST_HEAD(&file->static_call_list); in create_static_call_sections()
648 if (list_empty(&file->static_call_list)) in create_static_call_sections()
652 list_for_each_entry(insn, &file->static_call_list, call_node) in create_static_call_sections()
655 sec = elf_create_section_pair(file->elf, ".static_call_sites", in create_static_call_sections()
664 list_for_each_entry(insn, &file->static_call_list, call_node) { in create_static_call_sections()
667 if (!elf_init_reloc_text_sym(file->elf, sec, in create_static_call_sections()
686 key_sym = find_symbol_by_name(file->elf, tmp); in create_static_call_sections()
706 if (!elf_init_reloc_data_sym(file->elf, sec, in create_static_call_sections()
718 static int create_retpoline_sites_sections(struct objtool_file *file) in create_retpoline_sites_sections() argument
724 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
731 list_for_each_entry(insn, &file->retpoline_call_list, call_node) in create_retpoline_sites_sections()
737 sec = elf_create_section_pair(file->elf, ".retpoline_sites", in create_retpoline_sites_sections()
743 list_for_each_entry(insn, &file->retpoline_call_list, call_node) { in create_retpoline_sites_sections()
745 if (!elf_init_reloc_text_sym(file->elf, sec, in create_retpoline_sites_sections()
756 static int create_return_sites_sections(struct objtool_file *file) in create_return_sites_sections() argument
762 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
769 list_for_each_entry(insn, &file->return_thunk_list, call_node) in create_return_sites_sections()
775 sec = elf_create_section_pair(file->elf, ".return_sites", in create_return_sites_sections()
781 list_for_each_entry(insn, &file->return_thunk_list, call_node) { in create_return_sites_sections()
783 if (!elf_init_reloc_text_sym(file->elf, sec, in create_return_sites_sections()
794 static int create_ibt_endbr_seal_sections(struct objtool_file *file) in create_ibt_endbr_seal_sections() argument
800 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
807 list_for_each_entry(insn, &file->endbr_list, call_node) in create_ibt_endbr_seal_sections()
811 printf("ibt: ENDBR at function start: %d\n", file->nr_endbr); in create_ibt_endbr_seal_sections()
812 printf("ibt: ENDBR inside functions: %d\n", file->nr_endbr_int); in create_ibt_endbr_seal_sections()
819 sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal", in create_ibt_endbr_seal_sections()
825 list_for_each_entry(insn, &file->endbr_list, call_node) { in create_ibt_endbr_seal_sections()
840 if (!elf_init_reloc_text_sym(file->elf, sec, in create_ibt_endbr_seal_sections()
851 static int create_cfi_sections(struct objtool_file *file) in create_cfi_sections() argument
857 sec = find_section_by_name(file->elf, ".cfi_sites"); in create_cfi_sections()
859 INIT_LIST_HEAD(&file->call_list); in create_cfi_sections()
865 for_each_sym(file, sym) { in create_cfi_sections()
875 sec = elf_create_section_pair(file->elf, ".cfi_sites", in create_cfi_sections()
881 for_each_sym(file, sym) { in create_cfi_sections()
888 if (!elf_init_reloc_text_sym(file->elf, sec, in create_cfi_sections()
899 static int create_mcount_loc_sections(struct objtool_file *file) in create_mcount_loc_sections() argument
901 size_t addr_size = elf_addr_size(file->elf); in create_mcount_loc_sections()
906 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
908 INIT_LIST_HEAD(&file->mcount_loc_list); in create_mcount_loc_sections()
913 if (list_empty(&file->mcount_loc_list)) in create_mcount_loc_sections()
917 list_for_each_entry(insn, &file->mcount_loc_list, call_node) in create_mcount_loc_sections()
920 sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size, in create_mcount_loc_sections()
928 list_for_each_entry(insn, &file->mcount_loc_list, call_node) { in create_mcount_loc_sections()
932 reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx, in create_mcount_loc_sections()
937 set_reloc_type(file->elf, reloc, addr_size == 8 ? R_ABS64 : R_ABS32); in create_mcount_loc_sections()
945 static int create_direct_call_sections(struct objtool_file *file) in create_direct_call_sections() argument
951 sec = find_section_by_name(file->elf, ".call_sites"); in create_direct_call_sections()
953 INIT_LIST_HEAD(&file->call_list); in create_direct_call_sections()
958 if (list_empty(&file->call_list)) in create_direct_call_sections()
962 list_for_each_entry(insn, &file->call_list, call_node) in create_direct_call_sections()
965 sec = elf_create_section_pair(file->elf, ".call_sites", in create_direct_call_sections()
971 list_for_each_entry(insn, &file->call_list, call_node) { in create_direct_call_sections()
973 if (!elf_init_reloc_text_sym(file->elf, sec, in create_direct_call_sections()
987 static int add_ignores(struct objtool_file *file) in add_ignores() argument
993 rsec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
1213 static void add_uaccess_safe(struct objtool_file *file) in add_uaccess_safe() argument
1222 func = find_symbol_by_name(file->elf, *name); in add_uaccess_safe()
1257 static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn) in insn_reloc() argument
1264 if (!file) in insn_reloc()
1267 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1288 static int annotate_call_site(struct objtool_file *file, in annotate_call_site() argument
1291 struct reloc *reloc = insn_reloc(file, insn); in annotate_call_site()
1298 list_add_tail(&insn->call_node, &file->static_call_list); in annotate_call_site()
1303 list_add_tail(&insn->call_node, &file->retpoline_call_list); in annotate_call_site()
1314 set_reloc_type(file->elf, reloc, R_NONE); in annotate_call_site()
1316 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1343 set_reloc_type(file->elf, reloc, R_NONE); in annotate_call_site()
1345 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1354 list_add_tail(&insn->call_node, &file->mcount_loc_list); in annotate_call_site()
1360 list_add_tail(&insn->call_node, &file->call_list); in annotate_call_site()
1362 if (!sibling && dead_end_function(file, sym)) in annotate_call_site()
1368 static int add_call_dest(struct objtool_file *file, struct instruction *insn, in add_call_dest() argument
1384 return annotate_call_site(file, insn, sibling); in add_call_dest()
1387 static int add_retpoline_call(struct objtool_file *file, struct instruction *insn) in add_retpoline_call() argument
1418 return annotate_call_site(file, insn, false); in add_retpoline_call()
1421 static void add_return_call(struct objtool_file *file, struct instruction *insn, bool add) in add_return_call() argument
1431 list_add_tail(&insn->call_node, &file->return_thunk_list); in add_return_call()
1434 static bool is_first_func_insn(struct objtool_file *file, in is_first_func_insn() argument
1442 struct instruction *prev = prev_insn_same_sym(file, insn); in is_first_func_insn()
1456 static bool jump_is_sibling_call(struct objtool_file *file, in jump_is_sibling_call() argument
1467 if (!is_first_func_insn(file, to, ts)) in jump_is_sibling_call()
1481 static int add_jump_destinations(struct objtool_file *file) in add_jump_destinations() argument
1489 for_each_insn(file, insn) { in add_jump_destinations()
1502 reloc = insn_reloc(file, insn); in add_jump_destinations()
1510 ret = add_retpoline_call(file, insn); in add_jump_destinations()
1515 add_return_call(file, insn, true); in add_jump_destinations()
1522 ret = add_call_dest(file, insn, reloc->sym, true); in add_jump_destinations()
1535 jump_dest = find_insn(file, dest_sec, dest_off); in add_jump_destinations()
1548 add_return_call(file, insn, false); in add_jump_destinations()
1556 if (file->ignore_unreachables && func && in add_jump_destinations()
1573 ret = add_retpoline_call(file, insn); in add_jump_destinations()
1579 add_return_call(file, insn, true); in add_jump_destinations()
1611 if (jump_is_sibling_call(file, insn, jump_dest)) { in add_jump_destinations()
1616 ret = add_call_dest(file, insn, insn_func(jump_dest), true); in add_jump_destinations()
1642 static int add_call_destinations(struct objtool_file *file) in add_call_destinations() argument
1650 for_each_insn(file, insn) { in add_call_destinations()
1655 reloc = insn_reloc(file, insn); in add_call_destinations()
1660 ret = add_call_dest(file, insn, dest, false); in add_call_destinations()
1686 ret = add_call_dest(file, insn, dest, false); in add_call_destinations()
1691 ret = add_retpoline_call(file, insn); in add_call_destinations()
1696 ret = add_call_dest(file, insn, reloc->sym, false); in add_call_destinations()
1709 static int handle_group_alt(struct objtool_file *file, in handle_group_alt() argument
1735 sec_for_each_insn_from(file, insn) { in handle_group_alt()
1794 sec_for_each_insn_from(file, insn) { in handle_group_alt()
1813 alt_reloc = insn_reloc(file, insn); in handle_group_alt()
1829 insn->jump_dest = next_insn_same_sec(file, orig_alt_group->last_insn); in handle_group_alt()
1858 static int handle_jump_alt(struct objtool_file *file, in handle_jump_alt() argument
1871 struct reloc *reloc = insn_reloc(file, orig_insn); in handle_jump_alt()
1874 set_reloc_type(file->elf, reloc, R_NONE); in handle_jump_alt()
1876 if (elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
1887 file->jl_nop_short++; in handle_jump_alt()
1889 file->jl_nop_long++; in handle_jump_alt()
1895 file->jl_short++; in handle_jump_alt()
1897 file->jl_long++; in handle_jump_alt()
1899 *new_insn = next_insn_same_sec(file, orig_insn); in handle_jump_alt()
1909 static int add_special_section_alts(struct objtool_file *file) in add_special_section_alts() argument
1917 if (special_get_alts(file->elf, &special_alts)) in add_special_section_alts()
1922 orig_insn = find_insn(file, special_alt->orig_sec, in add_special_section_alts()
1932 new_insn = find_insn(file, special_alt->new_sec, in add_special_section_alts()
1947 ret = handle_group_alt(file, special_alt, orig_insn, in add_special_section_alts()
1953 ret = handle_jump_alt(file, special_alt, orig_insn, in add_special_section_alts()
1975 printf("short:\t%ld\t%ld\n", file->jl_nop_short, file->jl_short); in add_special_section_alts()
1976 printf("long:\t%ld\t%ld\n", file->jl_nop_long, file->jl_long); in add_special_section_alts()
1987 static int add_jump_table(struct objtool_file *file, struct instruction *insn) in add_jump_table() argument
2028 dest_insn = find_insn(file, reloc->sym->sec, sym_offset); in add_jump_table()
2061 static void find_jump_table(struct objtool_file *file, struct symbol *func, in find_jump_table() argument
2076 insn = insn->first_jump_src ?: prev_insn_same_sym(file, insn)) { in find_jump_table()
2088 table_reloc = arch_find_switch_table(file, insn, &table_size); in find_jump_table()
2094 dest_insn = find_insn(file, table_reloc->sym->sec, sym_offset); in find_jump_table()
2110 static void mark_func_jump_tables(struct objtool_file *file, in mark_func_jump_tables() argument
2115 func_for_each_insn(file, func, insn) { in mark_func_jump_tables()
2136 find_jump_table(file, func, insn); in mark_func_jump_tables()
2140 static int add_func_jump_tables(struct objtool_file *file, in add_func_jump_tables() argument
2146 func_for_each_insn(file, func, insn) { in add_func_jump_tables()
2150 ret = add_jump_table(file, insn); in add_func_jump_tables()
2163 static int add_jump_table_alts(struct objtool_file *file) in add_jump_table_alts() argument
2168 if (!file->rodata) in add_jump_table_alts()
2171 for_each_sym(file, func) { in add_jump_table_alts()
2175 mark_func_jump_tables(file, func); in add_jump_table_alts()
2176 ret = add_func_jump_tables(file, func); in add_jump_table_alts()
2193 static int read_unwind_hints(struct objtool_file *file) in read_unwind_hints() argument
2203 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2217 file->hints = true; in read_unwind_hints()
2222 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2237 insn = find_insn(file, reloc->sym->sec, offset); in read_unwind_hints()
2285 cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset); in read_unwind_hints()
2295 static int read_annotate(struct objtool_file *file, in read_annotate() argument
2296 int (*func)(struct objtool_file *file, int type, struct instruction *insn)) in read_annotate() argument
2304 sec = find_section_by_name(file->elf, ".discard.annotate_insn"); in read_annotate()
2322 type = bswap_if_needed(file->elf, type); in read_annotate()
2325 insn = find_insn(file, reloc->sym->sec, offset); in read_annotate()
2332 ret = func(file, type, insn); in read_annotate()
2340 static int __annotate_early(struct objtool_file *file, int type, struct instruction *insn) in __annotate_early() argument
2363 static int __annotate_ifc(struct objtool_file *file, int type, struct instruction *insn) in __annotate_ifc() argument
2383 insn->jump_dest = find_insn(file, insn->sec, dest_off); in __annotate_ifc()
2393 static int __annotate_late(struct objtool_file *file, int type, struct instruction *insn) in __annotate_late() argument
2469 static int classify_symbols(struct objtool_file *file) in classify_symbols() argument
2473 for_each_sym(file, func) { in classify_symbols()
2503 static void mark_rodata(struct objtool_file *file) in mark_rodata() argument
2518 for_each_sec(file, sec) { in mark_rodata()
2527 file->rodata = found; in mark_rodata()
2530 static int decode_sections(struct objtool_file *file) in decode_sections() argument
2534 mark_rodata(file); in decode_sections()
2536 ret = init_pv_ops(file); in decode_sections()
2543 ret = classify_symbols(file); in decode_sections()
2547 ret = decode_instructions(file); in decode_sections()
2551 ret = add_ignores(file); in decode_sections()
2555 add_uaccess_safe(file); in decode_sections()
2557 ret = read_annotate(file, __annotate_early); in decode_sections()
2566 ret = add_special_section_alts(file); in decode_sections()
2571 ret = add_jump_destinations(file); in decode_sections()
2579 ret = read_annotate(file, __annotate_ifc); in decode_sections()
2583 ret = add_call_destinations(file); in decode_sections()
2587 ret = add_jump_table_alts(file); in decode_sections()
2591 ret = read_unwind_hints(file); in decode_sections()
2599 ret = read_annotate(file, __annotate_late); in decode_sections()
3195 static int propagate_alt_cfi(struct objtool_file *file, struct instruction *insn) in propagate_alt_cfi() argument
3345 static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) in pv_call_dest() argument
3351 reloc = insn_reloc(file, insn); in pv_call_dest()
3357 if (file->pv_ops[idx].clean) in pv_call_dest()
3360 file->pv_ops[idx].clean = true; in pv_call_dest()
3362 list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { in pv_call_dest()
3365 file->pv_ops[idx].clean = false; in pv_call_dest()
3369 return file->pv_ops[idx].clean; in pv_call_dest()
3372 static inline bool noinstr_call_dest(struct objtool_file *file, in noinstr_call_dest() argument
3381 if (file->pv_ops) in noinstr_call_dest()
3382 return pv_call_dest(file, insn); in noinstr_call_dest()
3410 static int validate_call(struct objtool_file *file, in validate_call() argument
3415 !noinstr_call_dest(file, insn, insn_call_dest(insn))) { in validate_call()
3433 static int validate_sibling_call(struct objtool_file *file, in validate_sibling_call() argument
3442 return validate_call(file, insn, state); in validate_sibling_call()
3480 static struct instruction *next_insn_to_validate(struct objtool_file *file, in next_insn_to_validate() argument
3507 return next_insn_same_sec(file, insn); in next_insn_to_validate()
3510 return next_insn_same_sec(file, alt_group->orig_group->last_insn); in next_insn_to_validate()
3547 static int validate_branch(struct objtool_file *file, struct symbol *func, in validate_branch() argument
3562 next_insn = next_insn_to_validate(file, insn); in validate_branch()
3570 if (file->ignore_unreachables) in validate_branch()
3601 sym_for_each_insn_continue_reverse(file, func, i) { in validate_branch()
3648 if (propagate_alt_cfi(file, insn)) in validate_branch()
3653 ret = validate_branch(file, func, alt->insn, state); in validate_branch()
3674 ret = validate_call(file, insn, &state); in validate_branch()
3689 ret = validate_sibling_call(file, insn, &state); in validate_branch()
3694 ret = validate_branch(file, func, in validate_branch()
3710 ret = validate_sibling_call(file, insn, &state); in validate_branch()
3793 if (file->ignore_unreachables) in validate_branch()
3809 static int validate_unwind_hint(struct objtool_file *file, in validate_unwind_hint() argument
3814 int ret = validate_branch(file, insn_func(insn), insn, *state); in validate_unwind_hint()
3823 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3829 if (!file->hints) in validate_unwind_hints()
3832 init_insn_state(file, &state, sec); in validate_unwind_hints()
3835 sec_for_each_insn(file, sec, insn) in validate_unwind_hints()
3836 warnings += validate_unwind_hint(file, insn, &state); in validate_unwind_hints()
3838 for_each_insn(file, insn) in validate_unwind_hints()
3839 warnings += validate_unwind_hint(file, insn, &state); in validate_unwind_hints()
3851 static int validate_unret(struct objtool_file *file, struct instruction *insn) in validate_unret() argument
3857 next = next_insn_to_validate(file, insn); in validate_unret()
3867 ret = validate_unret(file, alt->insn); in validate_unret()
3890 ret = validate_unret(file, insn->jump_dest); in validate_unret()
3905 dest = find_insn(file, insn_call_dest(insn)->sec, in validate_unret()
3913 ret = validate_unret(file, dest); in validate_unret()
3960 static int validate_unrets(struct objtool_file *file) in validate_unrets() argument
3965 for_each_insn(file, insn) { in validate_unrets()
3969 warnings += validate_unret(file, insn); in validate_unrets()
3975 static int validate_retpoline(struct objtool_file *file) in validate_retpoline() argument
3980 for_each_insn(file, insn) { in validate_retpoline()
4021 static bool ignore_unreachable_insn(struct objtool_file *file, struct instruction *insn) in ignore_unreachable_insn() argument
4056 sec_for_each_insn_continue(file, insn) { in ignore_unreachable_insn()
4093 prev_insn = prev_insn_same_sec(file, insn); in ignore_unreachable_insn()
4124 insn = next_insn_same_sec(file, insn); in ignore_unreachable_insn()
4130 static int add_prefix_symbol(struct objtool_file *file, struct symbol *func) in add_prefix_symbol() argument
4135 insn = find_insn(file, func->sec, func->offset); in add_prefix_symbol()
4139 for (prev = prev_insn_same_sec(file, insn); in add_prefix_symbol()
4141 prev = prev_insn_same_sec(file, prev)) { in add_prefix_symbol()
4155 elf_create_prefix_symbol(file->elf, func, opts.prefix); in add_prefix_symbol()
4172 for (; prev != insn; prev = next_insn_same_sec(file, prev)) in add_prefix_symbol()
4178 static int add_prefix_symbols(struct objtool_file *file) in add_prefix_symbols() argument
4183 for_each_sec(file, sec) { in add_prefix_symbols()
4191 add_prefix_symbol(file, func); in add_prefix_symbols()
4198 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
4212 insn = find_insn(file, sec, sym->offset); in validate_symbol()
4219 ret = validate_branch(file, insn_func(insn), insn, *state); in validate_symbol()
4225 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
4235 init_insn_state(file, &state, sec); in validate_section()
4238 warnings += validate_symbol(file, sec, func, &state); in validate_section()
4244 static int validate_noinstr_sections(struct objtool_file *file) in validate_noinstr_sections() argument
4249 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
4251 warnings += validate_section(file, sec); in validate_noinstr_sections()
4252 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4255 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
4257 warnings += validate_section(file, sec); in validate_noinstr_sections()
4258 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4261 sec = find_section_by_name(file->elf, ".cpuidle.text"); in validate_noinstr_sections()
4263 warnings += validate_section(file, sec); in validate_noinstr_sections()
4264 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4270 static int validate_functions(struct objtool_file *file) in validate_functions() argument
4275 for_each_sec(file, sec) { in validate_functions()
4279 warnings += validate_section(file, sec); in validate_functions()
4291 static bool noendbr_range(struct objtool_file *file, struct instruction *insn) in noendbr_range() argument
4299 first = find_insn(file, sym->sec, sym->offset); in noendbr_range()
4309 static int __validate_ibt_insn(struct objtool_file *file, struct instruction *insn, in __validate_ibt_insn() argument
4347 if (noendbr_range(file, dest)) in __validate_ibt_insn()
4354 static int validate_ibt_insn(struct objtool_file *file, struct instruction *insn) in validate_ibt_insn() argument
4378 if (!insn_reloc(file, insn)) { in validate_ibt_insn()
4383 dest = find_insn(file, insn->sec, off); in validate_ibt_insn()
4389 return __validate_ibt_insn(file, insn, dest); in validate_ibt_insn()
4397 for (reloc = insn_reloc(file, insn); in validate_ibt_insn()
4399 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4410 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4414 warnings += __validate_ibt_insn(file, insn, dest); in validate_ibt_insn()
4420 static int validate_ibt_data_reloc(struct objtool_file *file, in validate_ibt_data_reloc() argument
4425 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4449 static int validate_ibt(struct objtool_file *file) in validate_ibt() argument
4456 for_each_insn(file, insn) in validate_ibt()
4457 warnings += validate_ibt_insn(file, insn); in validate_ibt()
4459 for_each_sec(file, sec) { in validate_ibt()
4496 warnings += validate_ibt_data_reloc(file, reloc); in validate_ibt()
4502 static int validate_sls(struct objtool_file *file) in validate_sls() argument
4507 for_each_insn(file, insn) { in validate_sls()
4508 next_insn = next_insn_same_sec(file, insn); in validate_sls()
4535 static int validate_reachable_instructions(struct objtool_file *file) in validate_reachable_instructions() argument
4541 if (file->ignore_unreachables) in validate_reachable_instructions()
4544 for_each_insn(file, insn) { in validate_reachable_instructions()
4545 if (insn->visited || ignore_unreachable_insn(file, insn)) in validate_reachable_instructions()
4548 prev_insn = prev_insn_same_sec(file, insn); in validate_reachable_instructions()
4616 static void disas_warned_funcs(struct objtool_file *file) in disas_warned_funcs() argument
4621 for_each_sym(file, sym) { in disas_warned_funcs()
4657 static void free_insns(struct objtool_file *file) in free_insns() argument
4662 for_each_insn(file, insn) { in free_insns()
4675 int check(struct objtool_file *file) in check() argument
4686 if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) { in check()
4694 ret = decode_sections(file); in check()
4702 warnings += validate_retpoline(file); in check()
4707 w += validate_functions(file); in check()
4708 w += validate_unwind_hints(file, NULL); in check()
4710 w += validate_reachable_instructions(file); in check()
4715 warnings += validate_noinstr_sections(file); in check()
4723 warnings += validate_unrets(file); in check()
4727 warnings += validate_ibt(file); in check()
4730 warnings += validate_sls(file); in check()
4733 ret = create_static_call_sections(file); in check()
4739 ret = create_retpoline_sites_sections(file); in check()
4745 ret = create_cfi_sections(file); in check()
4751 ret = create_return_sites_sections(file); in check()
4756 ret = create_direct_call_sections(file); in check()
4763 ret = create_mcount_loc_sections(file); in check()
4769 ret = add_prefix_symbols(file); in check()
4775 ret = create_ibt_endbr_seal_sections(file); in check()
4781 ret = orc_create(file); in check()
4786 free_insns(file); in check()
4806 disas_warned_funcs(file); in check()