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))
246 static bool __dead_end_function(struct objtool_file *file, struct symbol *func, in __dead_end_function() argument
277 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
281 func_for_each_insn(file, func, insn) { in __dead_end_function()
296 func_for_each_insn(file, func, insn) { in __dead_end_function()
314 return __dead_end_function(file, insn_func(dest), recursion+1); in __dead_end_function()
321 static bool dead_end_function(struct objtool_file *file, struct symbol *func) in dead_end_function() argument
323 return __dead_end_function(file, func, 0); in dead_end_function()
339 static void init_insn_state(struct objtool_file *file, struct insn_state *state, in init_insn_state() argument
425 static int decode_instructions(struct objtool_file *file) in decode_instructions() argument
433 for_each_sec(file, sec) { in decode_instructions()
480 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
496 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
515 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
520 sym_for_each_insn(file, func, insn) { in decode_instructions()
526 list_add_tail(&insn->call_node, &file->endbr_list); in decode_instructions()
527 file->nr_endbr++; in decode_instructions()
529 file->nr_endbr_int++; in decode_instructions()
545 static int add_pv_ops(struct objtool_file *file, const char *symname) in add_pv_ops() argument
552 sym = find_symbol_by_name(file->elf, symname); in add_pv_ops()
559 reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
575 if (objtool_pv_add(file, idx, func)) in add_pv_ops()
589 static int init_pv_ops(struct objtool_file *file) in init_pv_ops() argument
605 file->pv_ops = NULL; in init_pv_ops()
607 sym = find_symbol_by_name(file->elf, "pv_ops"); in init_pv_ops()
612 file->pv_ops = calloc(sizeof(struct pv_state), nr); in init_pv_ops()
613 if (!file->pv_ops) { in init_pv_ops()
619 INIT_LIST_HEAD(&file->pv_ops[idx].targets); in init_pv_ops()
622 ret = add_pv_ops(file, pv_ops); in init_pv_ops()
630 static int create_static_call_sections(struct objtool_file *file) in create_static_call_sections() argument
639 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
641 INIT_LIST_HEAD(&file->static_call_list); in create_static_call_sections()
646 if (list_empty(&file->static_call_list)) in create_static_call_sections()
650 list_for_each_entry(insn, &file->static_call_list, call_node) in create_static_call_sections()
653 sec = elf_create_section_pair(file->elf, ".static_call_sites", in create_static_call_sections()
662 list_for_each_entry(insn, &file->static_call_list, call_node) { in create_static_call_sections()
665 if (!elf_init_reloc_text_sym(file->elf, sec, in create_static_call_sections()
684 key_sym = find_symbol_by_name(file->elf, tmp); in create_static_call_sections()
704 if (!elf_init_reloc_data_sym(file->elf, sec, in create_static_call_sections()
716 static int create_retpoline_sites_sections(struct objtool_file *file) in create_retpoline_sites_sections() argument
722 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
729 list_for_each_entry(insn, &file->retpoline_call_list, call_node) in create_retpoline_sites_sections()
735 sec = elf_create_section_pair(file->elf, ".retpoline_sites", in create_retpoline_sites_sections()
741 list_for_each_entry(insn, &file->retpoline_call_list, call_node) { in create_retpoline_sites_sections()
743 if (!elf_init_reloc_text_sym(file->elf, sec, in create_retpoline_sites_sections()
754 static int create_return_sites_sections(struct objtool_file *file) in create_return_sites_sections() argument
760 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
767 list_for_each_entry(insn, &file->return_thunk_list, call_node) in create_return_sites_sections()
773 sec = elf_create_section_pair(file->elf, ".return_sites", in create_return_sites_sections()
779 list_for_each_entry(insn, &file->return_thunk_list, call_node) { in create_return_sites_sections()
781 if (!elf_init_reloc_text_sym(file->elf, sec, in create_return_sites_sections()
792 static int create_ibt_endbr_seal_sections(struct objtool_file *file) in create_ibt_endbr_seal_sections() argument
798 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
805 list_for_each_entry(insn, &file->endbr_list, call_node) in create_ibt_endbr_seal_sections()
809 printf("ibt: ENDBR at function start: %d\n", file->nr_endbr); in create_ibt_endbr_seal_sections()
810 printf("ibt: ENDBR inside functions: %d\n", file->nr_endbr_int); in create_ibt_endbr_seal_sections()
817 sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal", in create_ibt_endbr_seal_sections()
823 list_for_each_entry(insn, &file->endbr_list, call_node) { in create_ibt_endbr_seal_sections()
838 if (!elf_init_reloc_text_sym(file->elf, sec, in create_ibt_endbr_seal_sections()
849 static int create_cfi_sections(struct objtool_file *file) in create_cfi_sections() argument
855 sec = find_section_by_name(file->elf, ".cfi_sites"); in create_cfi_sections()
857 INIT_LIST_HEAD(&file->call_list); in create_cfi_sections()
863 for_each_sym(file, sym) { in create_cfi_sections()
873 sec = elf_create_section_pair(file->elf, ".cfi_sites", in create_cfi_sections()
879 for_each_sym(file, sym) { in create_cfi_sections()
886 if (!elf_init_reloc_text_sym(file->elf, sec, in create_cfi_sections()
897 static int create_mcount_loc_sections(struct objtool_file *file) in create_mcount_loc_sections() argument
899 size_t addr_size = elf_addr_size(file->elf); in create_mcount_loc_sections()
904 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
906 INIT_LIST_HEAD(&file->mcount_loc_list); in create_mcount_loc_sections()
911 if (list_empty(&file->mcount_loc_list)) in create_mcount_loc_sections()
915 list_for_each_entry(insn, &file->mcount_loc_list, call_node) in create_mcount_loc_sections()
918 sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size, in create_mcount_loc_sections()
926 list_for_each_entry(insn, &file->mcount_loc_list, call_node) { in create_mcount_loc_sections()
930 reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx, in create_mcount_loc_sections()
935 set_reloc_type(file->elf, reloc, addr_size == 8 ? R_ABS64 : R_ABS32); in create_mcount_loc_sections()
943 static int create_direct_call_sections(struct objtool_file *file) in create_direct_call_sections() argument
949 sec = find_section_by_name(file->elf, ".call_sites"); in create_direct_call_sections()
951 INIT_LIST_HEAD(&file->call_list); in create_direct_call_sections()
956 if (list_empty(&file->call_list)) in create_direct_call_sections()
960 list_for_each_entry(insn, &file->call_list, call_node) in create_direct_call_sections()
963 sec = elf_create_section_pair(file->elf, ".call_sites", in create_direct_call_sections()
969 list_for_each_entry(insn, &file->call_list, call_node) { in create_direct_call_sections()
971 if (!elf_init_reloc_text_sym(file->elf, sec, in create_direct_call_sections()
985 static int add_ignores(struct objtool_file *file) in add_ignores() argument
991 rsec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
1211 static void add_uaccess_safe(struct objtool_file *file) in add_uaccess_safe() argument
1220 func = find_symbol_by_name(file->elf, *name); in add_uaccess_safe()
1255 static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn) in insn_reloc() argument
1262 if (!file) in insn_reloc()
1265 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1286 static int annotate_call_site(struct objtool_file *file, in annotate_call_site() argument
1289 struct reloc *reloc = insn_reloc(file, insn); in annotate_call_site()
1296 list_add_tail(&insn->call_node, &file->static_call_list); in annotate_call_site()
1301 list_add_tail(&insn->call_node, &file->retpoline_call_list); in annotate_call_site()
1312 set_reloc_type(file->elf, reloc, R_NONE); in annotate_call_site()
1314 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1341 set_reloc_type(file->elf, reloc, R_NONE); in annotate_call_site()
1343 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1352 list_add_tail(&insn->call_node, &file->mcount_loc_list); in annotate_call_site()
1358 list_add_tail(&insn->call_node, &file->call_list); in annotate_call_site()
1360 if (!sibling && dead_end_function(file, sym)) in annotate_call_site()
1366 static int add_call_dest(struct objtool_file *file, struct instruction *insn, in add_call_dest() argument
1382 return annotate_call_site(file, insn, sibling); in add_call_dest()
1385 static int add_retpoline_call(struct objtool_file *file, struct instruction *insn) in add_retpoline_call() argument
1416 return annotate_call_site(file, insn, false); in add_retpoline_call()
1419 static void add_return_call(struct objtool_file *file, struct instruction *insn, bool add) in add_return_call() argument
1429 list_add_tail(&insn->call_node, &file->return_thunk_list); in add_return_call()
1432 static bool is_first_func_insn(struct objtool_file *file, in is_first_func_insn() argument
1440 struct instruction *prev = prev_insn_same_sym(file, insn); in is_first_func_insn()
1454 static bool jump_is_sibling_call(struct objtool_file *file, in jump_is_sibling_call() argument
1465 if (!is_first_func_insn(file, to, ts)) in jump_is_sibling_call()
1479 static int add_jump_destinations(struct objtool_file *file) in add_jump_destinations() argument
1487 for_each_insn(file, insn) { in add_jump_destinations()
1500 reloc = insn_reloc(file, insn); in add_jump_destinations()
1508 ret = add_retpoline_call(file, insn); in add_jump_destinations()
1513 add_return_call(file, insn, true); in add_jump_destinations()
1520 ret = add_call_dest(file, insn, reloc->sym, true); in add_jump_destinations()
1533 jump_dest = find_insn(file, dest_sec, dest_off); in add_jump_destinations()
1546 add_return_call(file, insn, false); in add_jump_destinations()
1554 if (file->ignore_unreachables && func && in add_jump_destinations()
1571 ret = add_retpoline_call(file, insn); in add_jump_destinations()
1577 add_return_call(file, insn, true); in add_jump_destinations()
1609 if (jump_is_sibling_call(file, insn, jump_dest)) { in add_jump_destinations()
1614 ret = add_call_dest(file, insn, insn_func(jump_dest), true); in add_jump_destinations()
1640 static int add_call_destinations(struct objtool_file *file) in add_call_destinations() argument
1648 for_each_insn(file, insn) { in add_call_destinations()
1653 reloc = insn_reloc(file, insn); in add_call_destinations()
1658 ret = add_call_dest(file, insn, dest, false); in add_call_destinations()
1684 ret = add_call_dest(file, insn, dest, false); in add_call_destinations()
1689 ret = add_retpoline_call(file, insn); in add_call_destinations()
1694 ret = add_call_dest(file, insn, reloc->sym, false); in add_call_destinations()
1707 static int handle_group_alt(struct objtool_file *file, in handle_group_alt() argument
1733 sec_for_each_insn_from(file, insn) { in handle_group_alt()
1792 sec_for_each_insn_from(file, insn) { in handle_group_alt()
1811 alt_reloc = insn_reloc(file, insn); in handle_group_alt()
1827 insn->jump_dest = next_insn_same_sec(file, orig_alt_group->last_insn); in handle_group_alt()
1856 static int handle_jump_alt(struct objtool_file *file, in handle_jump_alt() argument
1869 struct reloc *reloc = insn_reloc(file, orig_insn); in handle_jump_alt()
1872 set_reloc_type(file->elf, reloc, R_NONE); in handle_jump_alt()
1874 if (elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
1885 file->jl_nop_short++; in handle_jump_alt()
1887 file->jl_nop_long++; in handle_jump_alt()
1893 file->jl_short++; in handle_jump_alt()
1895 file->jl_long++; in handle_jump_alt()
1897 *new_insn = next_insn_same_sec(file, orig_insn); in handle_jump_alt()
1907 static int add_special_section_alts(struct objtool_file *file) in add_special_section_alts() argument
1915 if (special_get_alts(file->elf, &special_alts)) in add_special_section_alts()
1920 orig_insn = find_insn(file, special_alt->orig_sec, in add_special_section_alts()
1930 new_insn = find_insn(file, special_alt->new_sec, in add_special_section_alts()
1945 ret = handle_group_alt(file, special_alt, orig_insn, in add_special_section_alts()
1951 ret = handle_jump_alt(file, special_alt, orig_insn, in add_special_section_alts()
1973 printf("short:\t%ld\t%ld\n", file->jl_nop_short, file->jl_short); in add_special_section_alts()
1974 printf("long:\t%ld\t%ld\n", file->jl_nop_long, file->jl_long); in add_special_section_alts()
1985 static int add_jump_table(struct objtool_file *file, struct instruction *insn) in add_jump_table() argument
2026 dest_insn = find_insn(file, reloc->sym->sec, sym_offset); in add_jump_table()
2059 static void find_jump_table(struct objtool_file *file, struct symbol *func, in find_jump_table() argument
2074 insn = insn->first_jump_src ?: prev_insn_same_sym(file, insn)) { in find_jump_table()
2086 table_reloc = arch_find_switch_table(file, insn, &table_size); in find_jump_table()
2092 dest_insn = find_insn(file, table_reloc->sym->sec, sym_offset); in find_jump_table()
2108 static void mark_func_jump_tables(struct objtool_file *file, in mark_func_jump_tables() argument
2113 func_for_each_insn(file, func, insn) { in mark_func_jump_tables()
2134 find_jump_table(file, func, insn); in mark_func_jump_tables()
2138 static int add_func_jump_tables(struct objtool_file *file, in add_func_jump_tables() argument
2144 func_for_each_insn(file, func, insn) { in add_func_jump_tables()
2148 ret = add_jump_table(file, insn); in add_func_jump_tables()
2161 static int add_jump_table_alts(struct objtool_file *file) in add_jump_table_alts() argument
2166 if (!file->rodata) in add_jump_table_alts()
2169 for_each_sym(file, func) { in add_jump_table_alts()
2173 mark_func_jump_tables(file, func); in add_jump_table_alts()
2174 ret = add_func_jump_tables(file, func); in add_jump_table_alts()
2191 static int read_unwind_hints(struct objtool_file *file) in read_unwind_hints() argument
2201 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2215 file->hints = true; in read_unwind_hints()
2220 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2235 insn = find_insn(file, reloc->sym->sec, offset); in read_unwind_hints()
2283 cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset); in read_unwind_hints()
2293 static int read_annotate(struct objtool_file *file, in read_annotate() argument
2294 int (*func)(struct objtool_file *file, int type, struct instruction *insn)) in read_annotate() argument
2302 sec = find_section_by_name(file->elf, ".discard.annotate_insn"); in read_annotate()
2322 insn = find_insn(file, reloc->sym->sec, offset); in read_annotate()
2329 ret = func(file, type, insn); in read_annotate()
2337 static int __annotate_early(struct objtool_file *file, int type, struct instruction *insn) in __annotate_early() argument
2360 static int __annotate_ifc(struct objtool_file *file, int type, struct instruction *insn) in __annotate_ifc() argument
2380 insn->jump_dest = find_insn(file, insn->sec, dest_off); in __annotate_ifc()
2390 static int __annotate_late(struct objtool_file *file, int type, struct instruction *insn) in __annotate_late() argument
2466 static int classify_symbols(struct objtool_file *file) in classify_symbols() argument
2470 for_each_sym(file, func) { in classify_symbols()
2500 static void mark_rodata(struct objtool_file *file) in mark_rodata() argument
2515 for_each_sec(file, sec) { in mark_rodata()
2524 file->rodata = found; in mark_rodata()
2527 static int decode_sections(struct objtool_file *file) in decode_sections() argument
2531 mark_rodata(file); in decode_sections()
2533 ret = init_pv_ops(file); in decode_sections()
2540 ret = classify_symbols(file); in decode_sections()
2544 ret = decode_instructions(file); in decode_sections()
2548 ret = add_ignores(file); in decode_sections()
2552 add_uaccess_safe(file); in decode_sections()
2554 ret = read_annotate(file, __annotate_early); in decode_sections()
2563 ret = add_special_section_alts(file); in decode_sections()
2568 ret = add_jump_destinations(file); in decode_sections()
2576 ret = read_annotate(file, __annotate_ifc); in decode_sections()
2580 ret = add_call_destinations(file); in decode_sections()
2584 ret = add_jump_table_alts(file); in decode_sections()
2588 ret = read_unwind_hints(file); in decode_sections()
2596 ret = read_annotate(file, __annotate_late); in decode_sections()
3192 static int propagate_alt_cfi(struct objtool_file *file, struct instruction *insn) in propagate_alt_cfi() argument
3342 static bool pv_call_dest(struct objtool_file *file, struct instruction *insn) in pv_call_dest() argument
3348 reloc = insn_reloc(file, insn); in pv_call_dest()
3354 if (file->pv_ops[idx].clean) in pv_call_dest()
3357 file->pv_ops[idx].clean = true; in pv_call_dest()
3359 list_for_each_entry(target, &file->pv_ops[idx].targets, pv_target) { in pv_call_dest()
3362 file->pv_ops[idx].clean = false; in pv_call_dest()
3366 return file->pv_ops[idx].clean; in pv_call_dest()
3369 static inline bool noinstr_call_dest(struct objtool_file *file, in noinstr_call_dest() argument
3378 if (file->pv_ops) in noinstr_call_dest()
3379 return pv_call_dest(file, insn); in noinstr_call_dest()
3407 static int validate_call(struct objtool_file *file, in validate_call() argument
3412 !noinstr_call_dest(file, insn, insn_call_dest(insn))) { in validate_call()
3430 static int validate_sibling_call(struct objtool_file *file, in validate_sibling_call() argument
3439 return validate_call(file, insn, state); in validate_sibling_call()
3477 static struct instruction *next_insn_to_validate(struct objtool_file *file, in next_insn_to_validate() argument
3504 return next_insn_same_sec(file, insn); in next_insn_to_validate()
3507 return next_insn_same_sec(file, alt_group->orig_group->last_insn); in next_insn_to_validate()
3544 static int validate_branch(struct objtool_file *file, struct symbol *func, in validate_branch() argument
3559 next_insn = next_insn_to_validate(file, insn); in validate_branch()
3567 if (file->ignore_unreachables) in validate_branch()
3598 sym_for_each_insn_continue_reverse(file, func, i) { in validate_branch()
3645 if (propagate_alt_cfi(file, insn)) in validate_branch()
3650 ret = validate_branch(file, func, alt->insn, state); in validate_branch()
3671 ret = validate_call(file, insn, &state); in validate_branch()
3686 ret = validate_sibling_call(file, insn, &state); in validate_branch()
3691 ret = validate_branch(file, func, in validate_branch()
3707 ret = validate_sibling_call(file, insn, &state); in validate_branch()
3790 if (file->ignore_unreachables) in validate_branch()
3806 static int validate_unwind_hint(struct objtool_file *file, in validate_unwind_hint() argument
3811 int ret = validate_branch(file, insn_func(insn), insn, *state); in validate_unwind_hint()
3820 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3826 if (!file->hints) in validate_unwind_hints()
3829 init_insn_state(file, &state, sec); in validate_unwind_hints()
3832 sec_for_each_insn(file, sec, insn) in validate_unwind_hints()
3833 warnings += validate_unwind_hint(file, insn, &state); in validate_unwind_hints()
3835 for_each_insn(file, insn) in validate_unwind_hints()
3836 warnings += validate_unwind_hint(file, insn, &state); in validate_unwind_hints()
3848 static int validate_unret(struct objtool_file *file, struct instruction *insn) in validate_unret() argument
3854 next = next_insn_to_validate(file, insn); in validate_unret()
3864 ret = validate_unret(file, alt->insn); in validate_unret()
3887 ret = validate_unret(file, insn->jump_dest); in validate_unret()
3902 dest = find_insn(file, insn_call_dest(insn)->sec, in validate_unret()
3910 ret = validate_unret(file, dest); in validate_unret()
3957 static int validate_unrets(struct objtool_file *file) in validate_unrets() argument
3962 for_each_insn(file, insn) { in validate_unrets()
3966 warnings += validate_unret(file, insn); in validate_unrets()
3972 static int validate_retpoline(struct objtool_file *file) in validate_retpoline() argument
3977 for_each_insn(file, insn) { in validate_retpoline()
4018 static bool ignore_unreachable_insn(struct objtool_file *file, struct instruction *insn) in ignore_unreachable_insn() argument
4053 sec_for_each_insn_continue(file, insn) { in ignore_unreachable_insn()
4090 prev_insn = prev_insn_same_sec(file, insn); in ignore_unreachable_insn()
4121 insn = next_insn_same_sec(file, insn); in ignore_unreachable_insn()
4127 static int add_prefix_symbol(struct objtool_file *file, struct symbol *func) in add_prefix_symbol() argument
4132 insn = find_insn(file, func->sec, func->offset); in add_prefix_symbol()
4136 for (prev = prev_insn_same_sec(file, insn); in add_prefix_symbol()
4138 prev = prev_insn_same_sec(file, prev)) { in add_prefix_symbol()
4152 elf_create_prefix_symbol(file->elf, func, opts.prefix); in add_prefix_symbol()
4169 for (; prev != insn; prev = next_insn_same_sec(file, prev)) in add_prefix_symbol()
4175 static int add_prefix_symbols(struct objtool_file *file) in add_prefix_symbols() argument
4180 for_each_sec(file, sec) { in add_prefix_symbols()
4188 add_prefix_symbol(file, func); in add_prefix_symbols()
4195 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
4209 insn = find_insn(file, sec, sym->offset); in validate_symbol()
4216 ret = validate_branch(file, insn_func(insn), insn, *state); in validate_symbol()
4222 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
4232 init_insn_state(file, &state, sec); in validate_section()
4235 warnings += validate_symbol(file, sec, func, &state); in validate_section()
4241 static int validate_noinstr_sections(struct objtool_file *file) in validate_noinstr_sections() argument
4246 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
4248 warnings += validate_section(file, sec); in validate_noinstr_sections()
4249 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4252 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
4254 warnings += validate_section(file, sec); in validate_noinstr_sections()
4255 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4258 sec = find_section_by_name(file->elf, ".cpuidle.text"); in validate_noinstr_sections()
4260 warnings += validate_section(file, sec); in validate_noinstr_sections()
4261 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4267 static int validate_functions(struct objtool_file *file) in validate_functions() argument
4272 for_each_sec(file, sec) { in validate_functions()
4276 warnings += validate_section(file, sec); in validate_functions()
4288 static bool noendbr_range(struct objtool_file *file, struct instruction *insn) in noendbr_range() argument
4296 first = find_insn(file, sym->sec, sym->offset); in noendbr_range()
4306 static int __validate_ibt_insn(struct objtool_file *file, struct instruction *insn, in __validate_ibt_insn() argument
4344 if (noendbr_range(file, dest)) in __validate_ibt_insn()
4351 static int validate_ibt_insn(struct objtool_file *file, struct instruction *insn) in validate_ibt_insn() argument
4375 if (!insn_reloc(file, insn)) { in validate_ibt_insn()
4380 dest = find_insn(file, insn->sec, off); in validate_ibt_insn()
4386 return __validate_ibt_insn(file, insn, dest); in validate_ibt_insn()
4394 for (reloc = insn_reloc(file, insn); in validate_ibt_insn()
4396 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4407 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4411 warnings += __validate_ibt_insn(file, insn, dest); in validate_ibt_insn()
4417 static int validate_ibt_data_reloc(struct objtool_file *file, in validate_ibt_data_reloc() argument
4422 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4446 static int validate_ibt(struct objtool_file *file) in validate_ibt() argument
4453 for_each_insn(file, insn) in validate_ibt()
4454 warnings += validate_ibt_insn(file, insn); in validate_ibt()
4456 for_each_sec(file, sec) { in validate_ibt()
4493 warnings += validate_ibt_data_reloc(file, reloc); in validate_ibt()
4499 static int validate_sls(struct objtool_file *file) in validate_sls() argument
4504 for_each_insn(file, insn) { in validate_sls()
4505 next_insn = next_insn_same_sec(file, insn); in validate_sls()
4532 static int validate_reachable_instructions(struct objtool_file *file) in validate_reachable_instructions() argument
4538 if (file->ignore_unreachables) in validate_reachable_instructions()
4541 for_each_insn(file, insn) { in validate_reachable_instructions()
4542 if (insn->visited || ignore_unreachable_insn(file, insn)) in validate_reachable_instructions()
4545 prev_insn = prev_insn_same_sec(file, insn); in validate_reachable_instructions()
4613 static void disas_warned_funcs(struct objtool_file *file) in disas_warned_funcs() argument
4618 for_each_sym(file, sym) { in disas_warned_funcs()
4654 static void free_insns(struct objtool_file *file) in free_insns() argument
4659 for_each_insn(file, insn) { in free_insns()
4672 int check(struct objtool_file *file) in check() argument
4683 if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) { in check()
4691 ret = decode_sections(file); in check()
4699 warnings += validate_retpoline(file); in check()
4704 w += validate_functions(file); in check()
4705 w += validate_unwind_hints(file, NULL); in check()
4707 w += validate_reachable_instructions(file); in check()
4712 warnings += validate_noinstr_sections(file); in check()
4720 warnings += validate_unrets(file); in check()
4724 warnings += validate_ibt(file); in check()
4727 warnings += validate_sls(file); in check()
4730 ret = create_static_call_sections(file); in check()
4736 ret = create_retpoline_sites_sections(file); in check()
4742 ret = create_cfi_sections(file); in check()
4748 ret = create_return_sites_sections(file); in check()
4753 ret = create_direct_call_sections(file); in check()
4760 ret = create_mcount_loc_sections(file); in check()
4766 ret = add_prefix_symbols(file); in check()
4772 ret = create_ibt_endbr_seal_sections(file); in check()
4778 ret = orc_create(file); in check()
4783 free_insns(file); in check()
4803 disas_warned_funcs(file); in check()