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; \
200 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
262 static void init_insn_state(struct insn_state *state, struct section *sec) in init_insn_state() argument
269 * not correctly determine insn->call_dest->sec (external symbols do in init_insn_state()
272 if (vmlinux && sec) in init_insn_state()
273 state->noinstr = sec->noinstr; in init_insn_state()
354 struct section *sec; in decode_instructions() local
360 for_each_sec(file, sec) { in decode_instructions()
362 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
365 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
366 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
367 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
368 sec->text = true; in decode_instructions()
370 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
371 !strcmp(sec->name, ".entry.text") || in decode_instructions()
372 !strncmp(sec->name, ".text.__x86.", 12)) in decode_instructions()
373 sec->noinstr = true; in decode_instructions()
375 for (offset = 0; offset < sec->len; offset += insn->len) { in decode_instructions()
385 insn->sec = sec; in decode_instructions()
388 ret = arch_decode_instruction(file->elf, sec, offset, in decode_instructions()
389 sec->len - offset, in decode_instructions()
396 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
401 list_for_each_entry(func, &sec->symbol_list, list) { in decode_instructions()
405 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
427 struct section *sec) in find_last_insn() argument
431 unsigned int end = (sec->len > 10) ? sec->len - 10 : 0; in find_last_insn()
433 for (offset = sec->len - 1; offset >= end && !insn; offset--) in find_last_insn()
434 insn = find_insn(file, sec, offset); in find_last_insn()
444 struct section *sec; in add_dead_ends() local
459 sec = find_section_by_name(file->elf, ".rela.discard.unreachable"); in add_dead_ends()
460 if (!sec) in add_dead_ends()
463 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
465 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
468 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
471 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
472 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
475 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
480 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
494 sec = find_section_by_name(file->elf, ".rela.discard.reachable"); in add_dead_ends()
495 if (!sec) in add_dead_ends()
498 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
500 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
503 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
506 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
507 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
510 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
515 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
527 struct section *sec; in create_static_call_sections() local
534 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
535 if (sec) { in create_static_call_sections()
548 sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, in create_static_call_sections()
550 if (!sec) in create_static_call_sections()
556 site = (struct static_call_site *)sec->data->d_buf + idx; in create_static_call_sections()
560 if (elf_add_reloc_to_insn(file->elf, sec, in create_static_call_sections()
563 insn->sec, insn->offset)) in create_static_call_sections()
603 if (elf_add_reloc(file->elf, sec, in create_static_call_sections()
618 struct section *sec; in create_retpoline_sites_sections() local
621 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
622 if (sec) { in create_retpoline_sites_sections()
634 sec = elf_create_section(file->elf, ".retpoline_sites", 0, in create_retpoline_sites_sections()
636 if (!sec) { in create_retpoline_sites_sections()
644 int *site = (int *)sec->data->d_buf + idx; in create_retpoline_sites_sections()
647 if (elf_add_reloc_to_insn(file->elf, sec, in create_retpoline_sites_sections()
650 insn->sec, insn->offset)) { in create_retpoline_sites_sections()
664 struct section *sec; in create_return_sites_sections() local
667 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
668 if (sec) { in create_return_sites_sections()
680 sec = elf_create_section(file->elf, ".return_sites", 0, in create_return_sites_sections()
682 if (!sec) { in create_return_sites_sections()
690 int *site = (int *)sec->data->d_buf + idx; in create_return_sites_sections()
693 if (elf_add_reloc_to_insn(file->elf, sec, in create_return_sites_sections()
696 insn->sec, insn->offset)) { in create_return_sites_sections()
713 struct section *sec; in add_ignores() local
717 sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
718 if (!sec) in add_ignores()
721 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignores()
728 func = find_func_by_offset(reloc->sym->sec, reloc->addend); in add_ignores()
734 WARN("unexpected relocation symbol type in %s: %d", sec->name, reloc->sym->type); in add_ignores()
923 struct section *sec; in add_ignore_alternatives() local
927 sec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
928 if (!sec) in add_ignore_alternatives()
931 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignore_alternatives()
933 WARN("unexpected relocation symbol type in %s", sec->name); in add_ignore_alternatives()
937 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_ignore_alternatives()
967 insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1003 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in annotate_call_site()
1021 if (insn->sec->noinstr && sym->kcov) { in annotate_call_site()
1027 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1111 if (add && insn->sec->text) in add_return_call()
1131 dest_sec = insn->sec; in add_jump_destinations()
1134 dest_sec = reloc->sym->sec; in add_jump_destinations()
1146 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1147 dest_sec = reloc->sym->sec; in add_jump_destinations()
1164 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in add_jump_destinations()
1181 insn->sec, insn->offset, dest_sec->name, in add_jump_destinations()
1223 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1227 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1229 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1251 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1259 WARN_FUNC("unannotated intra-function call", insn->sec, insn->offset); in add_call_destinations()
1265 insn->sec, insn->offset); in add_call_destinations()
1271 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1274 insn->sec, insn->offset, in add_call_destinations()
1275 reloc->sym->sec->name, in add_call_destinations()
1355 nop->sec = special_alt->new_sec; in handle_group_alt()
1395 insn->sec, insn->offset); in handle_group_alt()
1411 insn->sec, insn->offset); in handle_group_alt()
1447 orig_insn->sec, orig_insn->offset); in handle_jump_alt()
1500 orig_insn->sec, orig_insn->offset); in add_special_section_alts()
1548 list_for_each_entry_from(reloc, &table->sec->reloc_list, list) { in add_jump_table()
1559 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
1563 dest_insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_jump_table()
1584 insn->sec, insn->offset); in add_jump_table()
1624 dest_insn = find_insn(file, table_reloc->sym->sec, table_reloc->addend); in find_jump_table()
1698 struct section *sec; in add_jump_table_alts() local
1705 for_each_sec(file, sec) { in add_jump_table_alts()
1706 list_for_each_entry(func, &sec->symbol_list, list) { in add_jump_table_alts()
1731 struct section *sec, *relocsec; in read_unwind_hints() local
1737 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
1738 if (!sec) in read_unwind_hints()
1741 relocsec = sec->reloc; in read_unwind_hints()
1747 if (sec->len % sizeof(struct unwind_hint)) { in read_unwind_hints()
1754 for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
1755 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
1757 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
1763 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_unwind_hints()
1783 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
1805 insn->sec, insn->offset, hint->sp_reg); in read_unwind_hints()
1821 struct section *sec; in read_retpoline_hints() local
1825 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
1826 if (!sec) in read_retpoline_hints()
1829 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_retpoline_hints()
1831 WARN("unexpected relocation symbol type in %s", sec->name); in read_retpoline_hints()
1835 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_retpoline_hints()
1846 insn->sec, insn->offset); in read_retpoline_hints()
1858 struct section *sec; in read_instr_hints() local
1862 sec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
1863 if (!sec) in read_instr_hints()
1866 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1868 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1872 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1881 sec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
1882 if (!sec) in read_instr_hints()
1885 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1887 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1891 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1906 struct section *sec; in read_intra_function_calls() local
1909 sec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
1910 if (!sec) in read_intra_function_calls()
1913 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_intra_function_calls()
1918 sec->name); in read_intra_function_calls()
1922 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_intra_function_calls()
1930 insn->sec, insn->offset); in read_intra_function_calls()
1942 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
1945 insn->sec, insn->offset, in read_intra_function_calls()
1946 insn->sec->name, dest_off); in read_intra_function_calls()
1956 struct section *sec; in classify_symbols() local
1959 for_each_sec(file, sec) { in classify_symbols()
1960 list_for_each_entry(func, &sec->symbol_list, list) { in classify_symbols()
1987 struct section *sec; in mark_rodata() local
2000 for_each_sec(file, sec) { in mark_rodata()
2001 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
2002 !strstr(sec->name, ".str1.")) { in mark_rodata()
2003 sec->rodata = true; in mark_rodata()
2231 WARN_FUNC("undefined stack state", insn->sec, insn->offset); in update_cfi_state()
2370 insn->sec, insn->offset); in update_cfi_state()
2381 insn->sec, insn->offset); in update_cfi_state()
2456 insn->sec, insn->offset); in update_cfi_state()
2535 insn->sec, insn->offset); in update_cfi_state()
2554 insn->sec, insn->offset); in update_cfi_state()
2567 insn->sec, insn->offset); in update_cfi_state()
2604 insn->sec, insn->offset); in propagate_alt_cfi()
2626 insn->sec, insn->offset); in handle_insn_ops()
2659 insn->sec, insn->offset, in insn_cfi_match()
2670 insn->sec, insn->offset, in insn_cfi_match()
2679 insn->sec, insn->offset, cfi1->type, cfi2->type); in insn_cfi_match()
2686 insn->sec, insn->offset, in insn_cfi_match()
2724 if (func->sec->noinstr) in noinstr_call_dest()
2743 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2749 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2755 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2766 insn->sec, insn->offset); in validate_sibling_call()
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()
2807 insn->sec, insn->offset); in validate_return()
2841 struct section *sec; in validate_branch() local
2845 sec = insn->sec; in validate_branch()
2858 sec, insn->offset); in validate_branch()
2892 sec, insn->offset); in validate_branch()
2898 sec, insn->offset); in validate_branch()
2951 insn->sec, insn->offset); in validate_branch()
2964 sec, insn->offset); in validate_branch()
2999 insn->sec, insn->offset); in validate_branch()
3018 sec, insn->offset); in validate_branch()
3025 WARN_FUNC("recursive UACCESS enable", sec, insn->offset); in validate_branch()
3034 WARN_FUNC("redundant UACCESS disable", sec, insn->offset); in validate_branch()
3039 WARN_FUNC("UACCESS-safe disables UACCESS", sec, insn->offset); in validate_branch()
3048 WARN_FUNC("recursive STD", sec, insn->offset); in validate_branch()
3057 WARN_FUNC("redundant CLD", sec, insn->offset); in validate_branch()
3074 WARN("%s: unexpected end of section", sec->name); in validate_branch()
3085 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3094 init_insn_state(&state, sec); in validate_unwind_hints()
3096 if (sec) { in validate_unwind_hints()
3097 insn = find_insn(file, sec, 0); in validate_unwind_hints()
3104 while (&insn->list != &file->insn_list && (!sec || insn->sec == sec)) { in validate_unwind_hints()
3162 WARN_FUNC("early indirect call", insn->sec, insn->offset); in validate_entry()
3170 insn->sec, insn->offset); in validate_entry()
3190 dest = find_insn(file, insn->call_dest->sec, in validate_entry()
3211 WARN_FUNC("RET before UNTRAIN", insn->sec, insn->offset); in validate_entry()
3224 WARN_FUNC("teh end!", insn->sec, insn->offset); in validate_entry()
3248 WARN_FUNC("Failed UNRET validation", insn->sec, insn->offset); in validate_unret()
3277 if (!strcmp(insn->sec->name, ".init.text") && !module) in validate_retpoline()
3283 insn->sec, insn->offset); in validate_retpoline()
3288 insn->sec, insn->offset, in validate_retpoline()
3326 if (!strcmp(insn->sec->name, ".fixup") || in ignore_unreachable_insn()
3327 !strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
3328 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
3379 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
3393 insn = find_insn(file, sec, sym->offset); in validate_symbol()
3405 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
3411 list_for_each_entry(func, &sec->symbol_list, list) { in validate_section()
3415 init_insn_state(&state, sec); in validate_section()
3418 warnings += validate_symbol(file, sec, func, &state); in validate_section()
3426 struct section *sec; in validate_vmlinux_functions() local
3429 sec = find_section_by_name(file->elf, ".noinstr.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()
3435 sec = find_section_by_name(file->elf, ".entry.text"); in validate_vmlinux_functions()
3436 if (sec) { in validate_vmlinux_functions()
3437 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3438 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3446 struct section *sec; in validate_functions() local
3449 for_each_sec(file, sec) { in validate_functions()
3450 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
3453 warnings += validate_section(file, sec); in validate_functions()
3470 WARN_FUNC("unreachable instruction", insn->sec, insn->offset); in validate_reachable_instructions()