Lines Matching full:sec

37 			      struct section *sec, unsigned long offset)  in find_insn()  argument
41 hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) { in find_insn()
42 if (insn->sec == sec && insn->offset == offset) in find_insn()
54 if (!next || &next->list == &file->insn_list || next->sec != insn->sec) in next_insn_same_sec()
77 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
92 for (insn = find_insn(file, func->sec, func->offset); \
97 for (insn = find_insn(file, sym->sec, sym->offset); \
99 insn->sec == sym->sec && \
106 insn->sec == sym->sec && insn->offset >= sym->offset; \
198 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
260 static void init_insn_state(struct insn_state *state, struct section *sec) in init_insn_state() argument
267 * not correctly determine insn->call_dest->sec (external symbols do in init_insn_state()
270 if (vmlinux && noinstr && sec) in init_insn_state()
271 state->noinstr = sec->noinstr; in init_insn_state()
352 struct section *sec; in decode_instructions() local
358 for_each_sec(file, sec) { in decode_instructions()
360 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
363 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
364 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
365 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
366 sec->text = true; in decode_instructions()
368 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
369 !strcmp(sec->name, ".entry.text") || in decode_instructions()
370 !strncmp(sec->name, ".text.__x86.", 12)) in decode_instructions()
371 sec->noinstr = true; in decode_instructions()
373 for (offset = 0; offset < sec->len; offset += insn->len) { in decode_instructions()
383 insn->sec = sec; in decode_instructions()
386 ret = arch_decode_instruction(file->elf, sec, offset, in decode_instructions()
387 sec->len - offset, in decode_instructions()
394 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
399 list_for_each_entry(func, &sec->symbol_list, list) { in decode_instructions()
403 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
425 struct section *sec) in find_last_insn() argument
429 unsigned int end = (sec->len > 10) ? sec->len - 10 : 0; in find_last_insn()
431 for (offset = sec->len - 1; offset >= end && !insn; offset--) in find_last_insn()
432 insn = find_insn(file, sec, offset); in find_last_insn()
442 struct section *sec; in add_dead_ends() local
457 sec = find_section_by_name(file->elf, ".rela.discard.unreachable"); in add_dead_ends()
458 if (!sec) in add_dead_ends()
461 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
463 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
466 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
469 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
470 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
473 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
478 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
492 sec = find_section_by_name(file->elf, ".rela.discard.reachable"); in add_dead_ends()
493 if (!sec) in add_dead_ends()
496 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
498 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
501 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
504 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
505 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
508 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
513 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
525 struct section *sec; in create_static_call_sections() local
532 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
533 if (sec) { in create_static_call_sections()
546 sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, in create_static_call_sections()
548 if (!sec) in create_static_call_sections()
554 site = (struct static_call_site *)sec->data->d_buf + idx; in create_static_call_sections()
558 if (elf_add_reloc_to_insn(file->elf, sec, in create_static_call_sections()
561 insn->sec, insn->offset)) in create_static_call_sections()
599 if (elf_add_reloc(file->elf, sec, in create_static_call_sections()
614 struct section *sec; in create_retpoline_sites_sections() local
617 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
618 if (sec) { in create_retpoline_sites_sections()
630 sec = elf_create_section(file->elf, ".retpoline_sites", 0, in create_retpoline_sites_sections()
632 if (!sec) { in create_retpoline_sites_sections()
640 int *site = (int *)sec->data->d_buf + idx; in create_retpoline_sites_sections()
643 if (elf_add_reloc_to_insn(file->elf, sec, in create_retpoline_sites_sections()
646 insn->sec, insn->offset)) { in create_retpoline_sites_sections()
660 struct section *sec; in create_return_sites_sections() local
663 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
664 if (sec) { in create_return_sites_sections()
676 sec = elf_create_section(file->elf, ".return_sites", 0, in create_return_sites_sections()
678 if (!sec) { in create_return_sites_sections()
686 int *site = (int *)sec->data->d_buf + idx; in create_return_sites_sections()
689 if (elf_add_reloc_to_insn(file->elf, sec, in create_return_sites_sections()
692 insn->sec, insn->offset)) { in create_return_sites_sections()
705 struct section *sec; in create_mcount_loc_sections() local
710 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
711 if (sec) { in create_mcount_loc_sections()
724 sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned long), idx); in create_mcount_loc_sections()
725 if (!sec) in create_mcount_loc_sections()
731 loc = (unsigned long *)sec->data->d_buf + idx; in create_mcount_loc_sections()
734 if (elf_add_reloc_to_insn(file->elf, sec, in create_mcount_loc_sections()
737 insn->sec, insn->offset)) in create_mcount_loc_sections()
752 struct section *sec; in add_ignores() local
756 sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
757 if (!sec) in add_ignores()
760 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignores()
767 func = find_func_by_offset(reloc->sym->sec, reloc->addend); in add_ignores()
773 WARN("unexpected relocation symbol type in %s: %d", sec->name, reloc->sym->type); in add_ignores()
950 struct section *sec; in add_ignore_alternatives() local
954 sec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
955 if (!sec) in add_ignore_alternatives()
958 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignore_alternatives()
960 WARN("unexpected relocation symbol type in %s", sec->name); in add_ignore_alternatives()
964 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_ignore_alternatives()
994 insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1030 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in annotate_call_site()
1048 if (insn->sec->noinstr && sym->kcov) { in annotate_call_site()
1054 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1138 if (add && insn->sec->text) in add_return_call()
1146 static bool is_cfi_section(struct section *sec) in is_cfi_section() argument
1148 return (sec->name && in is_cfi_section()
1149 (!strncmp(sec->name, ".text..L.cfi.jumptable", 22) || in is_cfi_section()
1150 !strcmp(sec->name, ".text.__cfi_check"))); in is_cfi_section()
1158 struct section *sec; in add_cfi_jumptables() local
1162 for_each_sec(file, sec) { in add_cfi_jumptables()
1163 if (!is_cfi_section(sec)) in add_cfi_jumptables()
1166 list_for_each_entry(func, &sec->symbol_list, list) { in add_cfi_jumptables()
1189 dest_sec = insn->sec; in add_jump_destinations()
1192 dest_sec = reloc->sym->sec; in add_jump_destinations()
1204 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1205 dest_sec = reloc->sym->sec; in add_jump_destinations()
1226 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in add_jump_destinations()
1229 if (is_cfi_section(insn->sec)) in add_jump_destinations()
1246 insn->sec, insn->offset, dest_sec->name, in add_jump_destinations()
1288 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1292 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1294 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1316 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1324 WARN_FUNC("unannotated intra-function call", insn->sec, insn->offset); in add_call_destinations()
1330 insn->sec, insn->offset); in add_call_destinations()
1336 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1338 if (is_cfi_section(reloc->sym->sec)) in add_call_destinations()
1342 insn->sec, insn->offset, in add_call_destinations()
1343 reloc->sym->sec->name, in add_call_destinations()
1423 nop->sec = special_alt->new_sec; in handle_group_alt()
1463 insn->sec, insn->offset); in handle_group_alt()
1479 insn->sec, insn->offset); in handle_group_alt()
1515 orig_insn->sec, orig_insn->offset); in handle_jump_alt()
1568 orig_insn->sec, orig_insn->offset); in add_special_section_alts()
1616 list_for_each_entry_from(reloc, &table->sec->reloc_list, list) { in add_jump_table()
1627 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
1631 dest_insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_jump_table()
1652 insn->sec, insn->offset); in add_jump_table()
1692 dest_insn = find_insn(file, table_reloc->sym->sec, table_reloc->addend); in find_jump_table()
1766 struct section *sec; in add_jump_table_alts() local
1773 for_each_sec(file, sec) { in add_jump_table_alts()
1774 list_for_each_entry(func, &sec->symbol_list, list) { in add_jump_table_alts()
1799 struct section *sec, *relocsec; in read_unwind_hints() local
1805 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
1806 if (!sec) in read_unwind_hints()
1809 relocsec = sec->reloc; in read_unwind_hints()
1815 if (sec->len % sizeof(struct unwind_hint)) { in read_unwind_hints()
1822 for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
1823 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
1825 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
1831 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_unwind_hints()
1851 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
1873 insn->sec, insn->offset, hint->sp_reg); in read_unwind_hints()
1889 struct section *sec; in read_retpoline_hints() local
1893 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
1894 if (!sec) in read_retpoline_hints()
1897 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_retpoline_hints()
1899 WARN("unexpected relocation symbol type in %s", sec->name); in read_retpoline_hints()
1903 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_retpoline_hints()
1914 insn->sec, insn->offset); in read_retpoline_hints()
1926 struct section *sec; in read_instr_hints() local
1930 sec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
1931 if (!sec) in read_instr_hints()
1934 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1936 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1940 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1949 sec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
1950 if (!sec) in read_instr_hints()
1953 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1955 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1959 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1974 struct section *sec; in read_intra_function_calls() local
1977 sec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
1978 if (!sec) in read_intra_function_calls()
1981 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_intra_function_calls()
1986 sec->name); in read_intra_function_calls()
1990 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_intra_function_calls()
1998 insn->sec, insn->offset); in read_intra_function_calls()
2010 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
2013 insn->sec, insn->offset, in read_intra_function_calls()
2014 insn->sec->name, dest_off); in read_intra_function_calls()
2024 struct section *sec; in classify_symbols() local
2027 for_each_sec(file, sec) { in classify_symbols()
2028 list_for_each_entry(func, &sec->symbol_list, list) { in classify_symbols()
2055 struct section *sec; in mark_rodata() local
2068 for_each_sec(file, sec) { in mark_rodata()
2069 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
2070 !strstr(sec->name, ".str1.")) { in mark_rodata()
2071 sec->rodata = true; in mark_rodata()
2300 WARN_FUNC("undefined stack state", insn->sec, insn->offset); in update_cfi_state()
2439 insn->sec, insn->offset); in update_cfi_state()
2450 insn->sec, insn->offset); in update_cfi_state()
2525 insn->sec, insn->offset); in update_cfi_state()
2604 insn->sec, insn->offset); in update_cfi_state()
2623 insn->sec, insn->offset); in update_cfi_state()
2636 insn->sec, insn->offset); in update_cfi_state()
2673 insn->sec, insn->offset); in propagate_alt_cfi()
2695 insn->sec, insn->offset); in handle_insn_ops()
2728 insn->sec, insn->offset, in insn_cfi_match()
2739 insn->sec, insn->offset, in insn_cfi_match()
2748 insn->sec, insn->offset, cfi1->type, cfi2->type); in insn_cfi_match()
2755 insn->sec, insn->offset, in insn_cfi_match()
2793 if (func->sec->noinstr) in noinstr_call_dest()
2812 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2818 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2824 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2835 insn->sec, insn->offset); in validate_sibling_call()
2846 insn->sec, insn->offset); in validate_return()
2852 insn->sec, insn->offset); in validate_return()
2858 insn->sec, insn->offset); in validate_return()
2864 insn->sec, insn->offset); in validate_return()
2870 insn->sec, insn->offset); in validate_return()
2876 insn->sec, insn->offset); in validate_return()
2910 struct section *sec; in validate_branch() local
2914 sec = insn->sec; in validate_branch()
2927 sec, insn->offset); in validate_branch()
2961 sec, insn->offset); in validate_branch()
2967 sec, insn->offset); in validate_branch()
3020 insn->sec, insn->offset); in validate_branch()
3033 sec, insn->offset); in validate_branch()
3068 insn->sec, insn->offset); in validate_branch()
3087 sec, insn->offset); in validate_branch()
3094 WARN_FUNC("recursive UACCESS enable", sec, insn->offset); in validate_branch()
3103 WARN_FUNC("redundant UACCESS disable", sec, insn->offset); in validate_branch()
3108 WARN_FUNC("UACCESS-safe disables UACCESS", sec, insn->offset); in validate_branch()
3117 WARN_FUNC("recursive STD", sec, insn->offset); in validate_branch()
3126 WARN_FUNC("redundant CLD", sec, insn->offset); in validate_branch()
3143 WARN("%s: unexpected end of section", sec->name); in validate_branch()
3154 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3163 init_insn_state(&state, sec); in validate_unwind_hints()
3165 if (sec) { in validate_unwind_hints()
3166 insn = find_insn(file, sec, 0); in validate_unwind_hints()
3173 while (&insn->list != &file->insn_list && (!sec || insn->sec == sec)) { in validate_unwind_hints()
3231 WARN_FUNC("early indirect call", insn->sec, insn->offset); in validate_entry()
3239 insn->sec, insn->offset); in validate_entry()
3259 dest = find_insn(file, insn->call_dest->sec, in validate_entry()
3280 WARN_FUNC("RET before UNTRAIN", insn->sec, insn->offset); in validate_entry()
3293 WARN_FUNC("teh end!", insn->sec, insn->offset); in validate_entry()
3317 WARN_FUNC("Failed UNRET validation", insn->sec, insn->offset); in validate_unret()
3346 if (!strcmp(insn->sec->name, ".init.text") && !module) in validate_retpoline()
3352 insn->sec, insn->offset); in validate_retpoline()
3357 insn->sec, insn->offset, in validate_retpoline()
3395 if (!strcmp(insn->sec->name, ".fixup") || in ignore_unreachable_insn()
3396 !strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
3397 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
3448 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
3462 insn = find_insn(file, sec, sym->offset); in validate_symbol()
3474 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
3480 list_for_each_entry(func, &sec->symbol_list, list) { in validate_section()
3484 init_insn_state(&state, sec); in validate_section()
3487 warnings += validate_symbol(file, sec, func, &state); in validate_section()
3495 struct section *sec; in validate_vmlinux_functions() local
3498 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_vmlinux_functions()
3499 if (sec) { in validate_vmlinux_functions()
3500 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3501 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3504 sec = find_section_by_name(file->elf, ".entry.text"); in validate_vmlinux_functions()
3505 if (sec) { in validate_vmlinux_functions()
3506 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3507 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3515 struct section *sec; in validate_functions() local
3518 for_each_sec(file, sec) { in validate_functions()
3519 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
3522 warnings += validate_section(file, sec); in validate_functions()
3539 WARN_FUNC("unreachable instruction", insn->sec, insn->offset); in validate_reachable_instructions()