Lines Matching full:sec
36 struct section *sec, unsigned long offset) in find_insn() argument
40 hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) { in find_insn()
41 if (insn->sec == sec && insn->offset == offset) in find_insn()
53 if (!next || &next->list == &file->insn_list || next->sec != insn->sec) in next_insn_same_sec()
76 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
91 for (insn = find_insn(file, func->sec, func->offset); \
96 for (insn = find_insn(file, sym->sec, sym->offset); \
98 insn->sec == sym->sec && \
105 insn->sec == sym->sec && insn->offset >= sym->offset; \
197 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
259 static void init_insn_state(struct insn_state *state, struct section *sec) in init_insn_state() argument
266 * not correctly determine insn->call_dest->sec (external symbols do in init_insn_state()
269 if (vmlinux && sec) in init_insn_state()
270 state->noinstr = sec->noinstr; in init_insn_state()
351 struct section *sec; in decode_instructions() local
357 for_each_sec(file, sec) { in decode_instructions()
359 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
362 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
363 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
364 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
365 sec->text = true; in decode_instructions()
367 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
368 !strcmp(sec->name, ".entry.text") || in decode_instructions()
369 !strncmp(sec->name, ".text.__x86.", 12)) in decode_instructions()
370 sec->noinstr = true; in decode_instructions()
372 for (offset = 0; offset < sec->len; offset += insn->len) { in decode_instructions()
382 insn->sec = sec; in decode_instructions()
385 ret = arch_decode_instruction(file->elf, sec, offset, in decode_instructions()
386 sec->len - offset, in decode_instructions()
393 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
398 list_for_each_entry(func, &sec->symbol_list, list) { in decode_instructions()
402 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
424 struct section *sec) in find_last_insn() argument
428 unsigned int end = (sec->len > 10) ? sec->len - 10 : 0; in find_last_insn()
430 for (offset = sec->len - 1; offset >= end && !insn; offset--) in find_last_insn()
431 insn = find_insn(file, sec, offset); in find_last_insn()
441 struct section *sec; in add_dead_ends() local
456 sec = find_section_by_name(file->elf, ".rela.discard.unreachable"); in add_dead_ends()
457 if (!sec) in add_dead_ends()
460 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
462 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
465 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
468 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
469 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
472 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
477 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
491 sec = find_section_by_name(file->elf, ".rela.discard.reachable"); in add_dead_ends()
492 if (!sec) in add_dead_ends()
495 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
497 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
500 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
503 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
504 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
507 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
512 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
524 struct section *sec; in create_static_call_sections() local
531 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
532 if (sec) { in create_static_call_sections()
545 sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, in create_static_call_sections()
547 if (!sec) in create_static_call_sections()
553 site = (struct static_call_site *)sec->data->d_buf + idx; in create_static_call_sections()
557 if (elf_add_reloc_to_insn(file->elf, sec, in create_static_call_sections()
560 insn->sec, insn->offset)) in create_static_call_sections()
598 if (elf_add_reloc(file->elf, sec, in create_static_call_sections()
613 struct section *sec; in create_retpoline_sites_sections() local
616 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
617 if (sec) { in create_retpoline_sites_sections()
629 sec = elf_create_section(file->elf, ".retpoline_sites", 0, in create_retpoline_sites_sections()
631 if (!sec) { in create_retpoline_sites_sections()
639 int *site = (int *)sec->data->d_buf + idx; in create_retpoline_sites_sections()
642 if (elf_add_reloc_to_insn(file->elf, sec, in create_retpoline_sites_sections()
645 insn->sec, insn->offset)) { in create_retpoline_sites_sections()
659 struct section *sec; in create_return_sites_sections() local
662 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
663 if (sec) { in create_return_sites_sections()
675 sec = elf_create_section(file->elf, ".return_sites", 0, in create_return_sites_sections()
677 if (!sec) { in create_return_sites_sections()
685 int *site = (int *)sec->data->d_buf + idx; in create_return_sites_sections()
688 if (elf_add_reloc_to_insn(file->elf, sec, in create_return_sites_sections()
691 insn->sec, insn->offset)) { in create_return_sites_sections()
708 struct section *sec; in add_ignores() local
712 sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
713 if (!sec) in add_ignores()
716 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignores()
723 func = find_func_by_offset(reloc->sym->sec, reloc->addend); in add_ignores()
729 WARN("unexpected relocation symbol type in %s: %d", sec->name, reloc->sym->type); in add_ignores()
906 struct section *sec; in add_ignore_alternatives() local
910 sec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
911 if (!sec) in add_ignore_alternatives()
914 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignore_alternatives()
916 WARN("unexpected relocation symbol type in %s", sec->name); in add_ignore_alternatives()
920 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_ignore_alternatives()
950 insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
986 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in annotate_call_site()
1004 if (insn->sec->noinstr && sym->kcov) { in annotate_call_site()
1010 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1094 if (add && insn->sec->text) in add_return_call()
1114 dest_sec = insn->sec; in add_jump_destinations()
1117 dest_sec = reloc->sym->sec; in add_jump_destinations()
1129 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1130 dest_sec = reloc->sym->sec; in add_jump_destinations()
1147 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in add_jump_destinations()
1164 insn->sec, insn->offset, dest_sec->name, in add_jump_destinations()
1206 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1210 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1212 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1234 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1242 WARN_FUNC("unannotated intra-function call", insn->sec, insn->offset); in add_call_destinations()
1248 insn->sec, insn->offset); in add_call_destinations()
1254 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1257 insn->sec, insn->offset, in add_call_destinations()
1258 reloc->sym->sec->name, in add_call_destinations()
1338 nop->sec = special_alt->new_sec; in handle_group_alt()
1378 insn->sec, insn->offset); in handle_group_alt()
1394 insn->sec, insn->offset); in handle_group_alt()
1430 orig_insn->sec, orig_insn->offset); in handle_jump_alt()
1483 orig_insn->sec, orig_insn->offset); in add_special_section_alts()
1531 list_for_each_entry_from(reloc, &table->sec->reloc_list, list) { in add_jump_table()
1542 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
1546 dest_insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_jump_table()
1567 insn->sec, insn->offset); in add_jump_table()
1607 dest_insn = find_insn(file, table_reloc->sym->sec, table_reloc->addend); in find_jump_table()
1681 struct section *sec; in add_jump_table_alts() local
1688 for_each_sec(file, sec) { in add_jump_table_alts()
1689 list_for_each_entry(func, &sec->symbol_list, list) { in add_jump_table_alts()
1714 struct section *sec, *relocsec; in read_unwind_hints() local
1720 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
1721 if (!sec) in read_unwind_hints()
1724 relocsec = sec->reloc; in read_unwind_hints()
1730 if (sec->len % sizeof(struct unwind_hint)) { in read_unwind_hints()
1737 for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
1738 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
1740 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
1746 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_unwind_hints()
1766 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
1788 insn->sec, insn->offset, hint->sp_reg); in read_unwind_hints()
1804 struct section *sec; in read_retpoline_hints() local
1808 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
1809 if (!sec) in read_retpoline_hints()
1812 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_retpoline_hints()
1814 WARN("unexpected relocation symbol type in %s", sec->name); in read_retpoline_hints()
1818 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_retpoline_hints()
1829 insn->sec, insn->offset); in read_retpoline_hints()
1841 struct section *sec; in read_instr_hints() local
1845 sec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
1846 if (!sec) in read_instr_hints()
1849 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1851 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1855 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1864 sec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
1865 if (!sec) in read_instr_hints()
1868 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1870 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1874 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1889 struct section *sec; in read_intra_function_calls() local
1892 sec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
1893 if (!sec) in read_intra_function_calls()
1896 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_intra_function_calls()
1901 sec->name); in read_intra_function_calls()
1905 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_intra_function_calls()
1913 insn->sec, insn->offset); in read_intra_function_calls()
1925 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
1928 insn->sec, insn->offset, in read_intra_function_calls()
1929 insn->sec->name, dest_off); in read_intra_function_calls()
1939 struct section *sec; in classify_symbols() local
1942 for_each_sec(file, sec) { in classify_symbols()
1943 list_for_each_entry(func, &sec->symbol_list, list) { in classify_symbols()
1970 struct section *sec; in mark_rodata() local
1983 for_each_sec(file, sec) { in mark_rodata()
1984 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
1985 !strstr(sec->name, ".str1.")) { in mark_rodata()
1986 sec->rodata = true; in mark_rodata()
2214 WARN_FUNC("undefined stack state", insn->sec, insn->offset); in update_cfi_state()
2353 insn->sec, insn->offset); in update_cfi_state()
2364 insn->sec, insn->offset); in update_cfi_state()
2439 insn->sec, insn->offset); in update_cfi_state()
2518 insn->sec, insn->offset); in update_cfi_state()
2537 insn->sec, insn->offset); in update_cfi_state()
2550 insn->sec, insn->offset); in update_cfi_state()
2587 insn->sec, insn->offset); in propagate_alt_cfi()
2609 insn->sec, insn->offset); in handle_insn_ops()
2642 insn->sec, insn->offset, in insn_cfi_match()
2653 insn->sec, insn->offset, in insn_cfi_match()
2662 insn->sec, insn->offset, cfi1->type, cfi2->type); in insn_cfi_match()
2669 insn->sec, insn->offset, in insn_cfi_match()
2707 if (func->sec->noinstr) in noinstr_call_dest()
2726 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2732 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2738 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2749 insn->sec, insn->offset); in validate_sibling_call()
2760 insn->sec, insn->offset); in validate_return()
2766 insn->sec, insn->offset); in validate_return()
2772 insn->sec, insn->offset); in validate_return()
2778 insn->sec, insn->offset); in validate_return()
2784 insn->sec, insn->offset); in validate_return()
2790 insn->sec, insn->offset); in validate_return()
2824 struct section *sec; in validate_branch() local
2828 sec = insn->sec; in validate_branch()
2841 sec, insn->offset); in validate_branch()
2875 sec, insn->offset); in validate_branch()
2881 sec, insn->offset); in validate_branch()
2934 insn->sec, insn->offset); in validate_branch()
2947 sec, insn->offset); in validate_branch()
2982 insn->sec, insn->offset); in validate_branch()
3001 sec, insn->offset); in validate_branch()
3008 WARN_FUNC("recursive UACCESS enable", sec, insn->offset); in validate_branch()
3017 WARN_FUNC("redundant UACCESS disable", sec, insn->offset); in validate_branch()
3022 WARN_FUNC("UACCESS-safe disables UACCESS", sec, insn->offset); in validate_branch()
3031 WARN_FUNC("recursive STD", sec, insn->offset); in validate_branch()
3040 WARN_FUNC("redundant CLD", sec, insn->offset); in validate_branch()
3057 WARN("%s: unexpected end of section", sec->name); in validate_branch()
3068 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3077 init_insn_state(&state, sec); in validate_unwind_hints()
3079 if (sec) { in validate_unwind_hints()
3080 insn = find_insn(file, sec, 0); in validate_unwind_hints()
3087 while (&insn->list != &file->insn_list && (!sec || insn->sec == sec)) { in validate_unwind_hints()
3145 WARN_FUNC("early indirect call", insn->sec, insn->offset); in validate_entry()
3153 insn->sec, insn->offset); in validate_entry()
3173 dest = find_insn(file, insn->call_dest->sec, in validate_entry()
3194 WARN_FUNC("RET before UNTRAIN", insn->sec, insn->offset); in validate_entry()
3207 WARN_FUNC("teh end!", insn->sec, insn->offset); in validate_entry()
3231 WARN_FUNC("Failed UNRET validation", insn->sec, insn->offset); in validate_unret()
3260 if (!strcmp(insn->sec->name, ".init.text") && !module) in validate_retpoline()
3266 insn->sec, insn->offset); in validate_retpoline()
3271 insn->sec, insn->offset, in validate_retpoline()
3309 if (!strcmp(insn->sec->name, ".fixup") || in ignore_unreachable_insn()
3310 !strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
3311 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
3362 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
3376 insn = find_insn(file, sec, sym->offset); in validate_symbol()
3388 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
3394 list_for_each_entry(func, &sec->symbol_list, list) { in validate_section()
3398 init_insn_state(&state, sec); in validate_section()
3401 warnings += validate_symbol(file, sec, func, &state); in validate_section()
3409 struct section *sec; in validate_vmlinux_functions() local
3412 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_vmlinux_functions()
3413 if (sec) { in validate_vmlinux_functions()
3414 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3415 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3418 sec = find_section_by_name(file->elf, ".entry.text"); in validate_vmlinux_functions()
3419 if (sec) { in validate_vmlinux_functions()
3420 warnings += validate_section(file, sec); in validate_vmlinux_functions()
3421 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
3429 struct section *sec; in validate_functions() local
3432 for_each_sec(file, sec) { in validate_functions()
3433 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
3436 warnings += validate_section(file, sec); in validate_functions()
3453 WARN_FUNC("unreachable instruction", insn->sec, insn->offset); in validate_reachable_instructions()