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 && 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()
709 struct section *sec; in add_ignores() local
713 sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
714 if (!sec) in add_ignores()
717 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignores()
724 func = find_func_by_offset(reloc->sym->sec, reloc->addend); in add_ignores()
730 WARN("unexpected relocation symbol type in %s: %d", sec->name, reloc->sym->type); in add_ignores()
917 struct section *sec; in add_ignore_alternatives() local
921 sec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
922 if (!sec) in add_ignore_alternatives()
925 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignore_alternatives()
927 WARN("unexpected relocation symbol type in %s", sec->name); in add_ignore_alternatives()
931 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_ignore_alternatives()
961 insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
997 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in annotate_call_site()
1015 if (insn->sec->noinstr && sym->kcov) { in annotate_call_site()
1021 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1105 if (add && insn->sec->text) in add_return_call()
1125 dest_sec = insn->sec; in add_jump_destinations()
1128 dest_sec = reloc->sym->sec; in add_jump_destinations()
1140 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1141 dest_sec = reloc->sym->sec; in add_jump_destinations()
1158 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in add_jump_destinations()
1175 insn->sec, insn->offset, dest_sec->name, in add_jump_destinations()
1217 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1221 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1223 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1245 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1253 WARN_FUNC("unannotated intra-function call", insn->sec, insn->offset); in add_call_destinations()
1259 insn->sec, insn->offset); in add_call_destinations()
1265 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1268 insn->sec, insn->offset, in add_call_destinations()
1269 reloc->sym->sec->name, in add_call_destinations()
1349 nop->sec = special_alt->new_sec; in handle_group_alt()
1389 insn->sec, insn->offset); in handle_group_alt()
1405 insn->sec, insn->offset); in handle_group_alt()
1441 orig_insn->sec, orig_insn->offset); in handle_jump_alt()
1494 orig_insn->sec, orig_insn->offset); in add_special_section_alts()
1542 list_for_each_entry_from(reloc, &table->sec->reloc_list, list) { in add_jump_table()
1553 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
1557 dest_insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_jump_table()
1578 insn->sec, insn->offset); in add_jump_table()
1618 dest_insn = find_insn(file, table_reloc->sym->sec, table_reloc->addend); in find_jump_table()
1692 struct section *sec; in add_jump_table_alts() local
1699 for_each_sec(file, sec) { in add_jump_table_alts()
1700 list_for_each_entry(func, &sec->symbol_list, list) { in add_jump_table_alts()
1725 struct section *sec, *relocsec; in read_unwind_hints() local
1731 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
1732 if (!sec) in read_unwind_hints()
1735 relocsec = sec->reloc; in read_unwind_hints()
1741 if (sec->len % sizeof(struct unwind_hint)) { in read_unwind_hints()
1748 for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
1749 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
1751 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
1757 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_unwind_hints()
1777 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
1799 insn->sec, insn->offset, hint->sp_reg); in read_unwind_hints()
1815 struct section *sec; in read_retpoline_hints() local
1819 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
1820 if (!sec) in read_retpoline_hints()
1823 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_retpoline_hints()
1825 WARN("unexpected relocation symbol type in %s", sec->name); in read_retpoline_hints()
1829 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_retpoline_hints()
1840 insn->sec, insn->offset); in read_retpoline_hints()
1852 struct section *sec; in read_instr_hints() local
1856 sec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
1857 if (!sec) in read_instr_hints()
1860 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1862 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1866 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1875 sec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
1876 if (!sec) in read_instr_hints()
1879 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1881 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1885 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1900 struct section *sec; in read_intra_function_calls() local
1903 sec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
1904 if (!sec) in read_intra_function_calls()
1907 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_intra_function_calls()
1912 sec->name); in read_intra_function_calls()
1916 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_intra_function_calls()
1924 insn->sec, insn->offset); in read_intra_function_calls()
1936 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
1939 insn->sec, insn->offset, in read_intra_function_calls()
1940 insn->sec->name, dest_off); in read_intra_function_calls()
1950 struct section *sec; in classify_symbols() local
1953 for_each_sec(file, sec) { in classify_symbols()
1954 list_for_each_entry(func, &sec->symbol_list, list) { in classify_symbols()
1981 struct section *sec; in mark_rodata() local
1994 for_each_sec(file, sec) { in mark_rodata()
1995 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
1996 !strstr(sec->name, ".str1.")) { in mark_rodata()
1997 sec->rodata = true; in mark_rodata()
2225 WARN_FUNC("undefined stack state", insn->sec, insn->offset); in update_cfi_state()
2364 insn->sec, insn->offset); in update_cfi_state()
2375 insn->sec, insn->offset); in update_cfi_state()
2450 insn->sec, insn->offset); in update_cfi_state()
2529 insn->sec, insn->offset); in update_cfi_state()
2548 insn->sec, insn->offset); in update_cfi_state()
2561 insn->sec, insn->offset); in update_cfi_state()
2598 insn->sec, insn->offset); in propagate_alt_cfi()
2620 insn->sec, insn->offset); in handle_insn_ops()
2653 insn->sec, insn->offset, in insn_cfi_match()
2664 insn->sec, insn->offset, in insn_cfi_match()
2673 insn->sec, insn->offset, cfi1->type, cfi2->type); in insn_cfi_match()
2680 insn->sec, insn->offset, in insn_cfi_match()
2718 if (func->sec->noinstr) in noinstr_call_dest()
2737 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2743 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2749 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2760 insn->sec, insn->offset); in validate_sibling_call()
2771 insn->sec, insn->offset); in validate_return()
2777 insn->sec, insn->offset); in validate_return()
2783 insn->sec, insn->offset); in validate_return()
2789 insn->sec, insn->offset); in validate_return()
2795 insn->sec, insn->offset); in validate_return()
2801 insn->sec, insn->offset); in validate_return()
2835 struct section *sec; in validate_branch() local
2839 sec = insn->sec; in validate_branch()
2852 sec, insn->offset); in validate_branch()
2886 sec, insn->offset); in validate_branch()
2892 sec, insn->offset); in validate_branch()
2945 insn->sec, insn->offset); in validate_branch()
2958 sec, insn->offset); in validate_branch()
2993 insn->sec, insn->offset); in validate_branch()
3012 sec, insn->offset); in validate_branch()
3019 WARN_FUNC("recursive UACCESS enable", sec, insn->offset); in validate_branch()
3028 WARN_FUNC("redundant UACCESS disable", sec, insn->offset); in validate_branch()
3033 WARN_FUNC("UACCESS-safe disables UACCESS", sec, insn->offset); in validate_branch()
3042 WARN_FUNC("recursive STD", sec, insn->offset); in validate_branch()
3051 WARN_FUNC("redundant CLD", sec, insn->offset); in validate_branch()
3068 WARN("%s: unexpected end of section", sec->name); in validate_branch()
3079 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3088 init_insn_state(&state, sec); in validate_unwind_hints()
3090 if (sec) { in validate_unwind_hints()
3091 insn = find_insn(file, sec, 0); in validate_unwind_hints()
3098 while (&insn->list != &file->insn_list && (!sec || insn->sec == sec)) { in validate_unwind_hints()
3156 WARN_FUNC("early indirect call", insn->sec, insn->offset); in validate_entry()
3164 insn->sec, insn->offset); in validate_entry()
3184 dest = find_insn(file, insn->call_dest->sec, in validate_entry()
3205 WARN_FUNC("RET before UNTRAIN", insn->sec, insn->offset); in validate_entry()
3218 WARN_FUNC("teh end!", insn->sec, insn->offset); in validate_entry()
3242 WARN_FUNC("Failed UNRET validation", insn->sec, insn->offset); in validate_unret()
3271 if (!strcmp(insn->sec->name, ".init.text") && !module) in validate_retpoline()
3277 insn->sec, insn->offset); in validate_retpoline()
3282 insn->sec, insn->offset, in validate_retpoline()
3320 if (!strcmp(insn->sec->name, ".fixup") || in ignore_unreachable_insn()
3321 !strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
3322 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
3373 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
3387 insn = find_insn(file, sec, sym->offset); in validate_symbol()
3399 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
3405 list_for_each_entry(func, &sec->symbol_list, list) { in validate_section()
3409 init_insn_state(&state, sec); in validate_section()
3412 warnings += validate_symbol(file, sec, func, &state); in validate_section()
3420 struct section *sec; in validate_vmlinux_functions() local
3423 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_vmlinux_functions()
3424 if (sec) { in validate_vmlinux_functions()
3425 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3426 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3429 sec = find_section_by_name(file->elf, ".entry.text"); in validate_vmlinux_functions()
3430 if (sec) { in validate_vmlinux_functions()
3431 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3432 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3440 struct section *sec; in validate_functions() local
3443 for_each_sec(file, sec) { in validate_functions()
3444 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
3447 warnings += validate_section(file, sec); in validate_functions()
3464 WARN_FUNC("unreachable instruction", insn->sec, insn->offset); in validate_reachable_instructions()