Lines Matching refs:sec
38 struct section *sec, unsigned long offset) in find_insn() argument
42 hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) { in find_insn()
43 if (insn->sec == sec && insn->offset == offset) in find_insn()
55 if (!next || &next->list == &file->insn_list || next->sec != insn->sec) in next_insn_same_sec()
78 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
93 for (insn = find_insn(file, func->sec, func->offset); \
98 for (insn = find_insn(file, sym->sec, sym->offset); \
100 insn->sec == sym->sec && \
107 insn->sec == sym->sec && insn->offset >= sym->offset; \
209 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
272 struct section *sec) in init_insn_state() argument
282 if (opts.link && opts.noinstr && sec) in init_insn_state()
283 state->noinstr = sec->noinstr; in init_insn_state()
364 struct section *sec; in decode_instructions() local
370 for_each_sec(file, sec) { in decode_instructions()
372 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
375 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
376 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
377 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
378 sec->text = true; in decode_instructions()
380 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
381 !strcmp(sec->name, ".entry.text") || in decode_instructions()
382 !strncmp(sec->name, ".text.__x86.", 12)) in decode_instructions()
383 sec->noinstr = true; in decode_instructions()
385 for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { in decode_instructions()
396 insn->sec = sec; in decode_instructions()
399 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
400 sec->sh.sh_size - offset, in decode_instructions()
415 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
420 list_for_each_entry(func, &sec->symbol_list, list) { in decode_instructions()
424 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
471 rel = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
477 func = find_symbol_by_offset(rel->sym->sec, rel->addend); in add_pv_ops()
531 struct section *sec) in find_last_insn() argument
535 unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0; in find_last_insn()
537 for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--) in find_last_insn()
538 insn = find_insn(file, sec, offset); in find_last_insn()
548 struct section *sec; in add_dead_ends() local
555 sec = find_section_by_name(file->elf, ".rela.discard.unreachable"); in add_dead_ends()
556 if (!sec) in add_dead_ends()
559 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
561 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
564 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
567 else if (reloc->addend == reloc->sym->sec->sh.sh_size) { in add_dead_ends()
568 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
571 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
576 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
590 sec = find_section_by_name(file->elf, ".rela.discard.reachable"); in add_dead_ends()
591 if (!sec) in add_dead_ends()
594 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
596 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
599 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
602 else if (reloc->addend == reloc->sym->sec->sh.sh_size) { in add_dead_ends()
603 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
606 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
611 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
623 struct section *sec; in create_static_call_sections() local
630 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
631 if (sec) { in create_static_call_sections()
644 sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, in create_static_call_sections()
646 if (!sec) in create_static_call_sections()
652 site = (struct static_call_site *)sec->data->d_buf + idx; in create_static_call_sections()
656 if (elf_add_reloc_to_insn(file->elf, sec, in create_static_call_sections()
659 insn->sec, insn->offset)) in create_static_call_sections()
697 if (elf_add_reloc(file->elf, sec, in create_static_call_sections()
712 struct section *sec; in create_retpoline_sites_sections() local
715 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
716 if (sec) { in create_retpoline_sites_sections()
728 sec = elf_create_section(file->elf, ".retpoline_sites", 0, in create_retpoline_sites_sections()
730 if (!sec) { in create_retpoline_sites_sections()
738 int *site = (int *)sec->data->d_buf + idx; in create_retpoline_sites_sections()
741 if (elf_add_reloc_to_insn(file->elf, sec, in create_retpoline_sites_sections()
744 insn->sec, insn->offset)) { in create_retpoline_sites_sections()
758 struct section *sec; in create_return_sites_sections() local
761 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
762 if (sec) { in create_return_sites_sections()
774 sec = elf_create_section(file->elf, ".return_sites", 0, in create_return_sites_sections()
776 if (!sec) { in create_return_sites_sections()
784 int *site = (int *)sec->data->d_buf + idx; in create_return_sites_sections()
787 if (elf_add_reloc_to_insn(file->elf, sec, in create_return_sites_sections()
790 insn->sec, insn->offset)) { in create_return_sites_sections()
804 struct section *sec; in create_ibt_endbr_seal_sections() local
807 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
808 if (sec) { in create_ibt_endbr_seal_sections()
826 sec = elf_create_section(file->elf, ".ibt_endbr_seal", 0, in create_ibt_endbr_seal_sections()
828 if (!sec) { in create_ibt_endbr_seal_sections()
836 int *site = (int *)sec->data->d_buf + idx; in create_ibt_endbr_seal_sections()
839 if (elf_add_reloc_to_insn(file->elf, sec, in create_ibt_endbr_seal_sections()
842 insn->sec, insn->offset)) { in create_ibt_endbr_seal_sections()
855 struct section *sec; in create_mcount_loc_sections() local
860 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
861 if (sec) { in create_mcount_loc_sections()
874 sec = elf_create_section(file->elf, "__mcount_loc", 0, sizeof(unsigned long), idx); in create_mcount_loc_sections()
875 if (!sec) in create_mcount_loc_sections()
881 loc = (unsigned long *)sec->data->d_buf + idx; in create_mcount_loc_sections()
884 if (elf_add_reloc_to_insn(file->elf, sec, in create_mcount_loc_sections()
887 insn->sec, insn->offset)) in create_mcount_loc_sections()
902 struct section *sec; in add_ignores() local
906 sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
907 if (!sec) in add_ignores()
910 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignores()
917 func = find_func_by_offset(reloc->sym->sec, reloc->addend); in add_ignores()
923 WARN("unexpected relocation symbol type in %s: %d", sec->name, reloc->sym->type); in add_ignores()
1127 struct section *sec; in add_ignore_alternatives() local
1131 sec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
1132 if (!sec) in add_ignore_alternatives()
1135 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignore_alternatives()
1137 WARN("unexpected relocation symbol type in %s", sec->name); in add_ignore_alternatives()
1141 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_ignore_alternatives()
1174 insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1210 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in annotate_call_site()
1228 if (opts.hack_noinstr && insn->sec->noinstr && sym->profiling_func) { in annotate_call_site()
1234 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1256 WARN_FUNC("Tail call to __fentry__ !?!?", insn->sec, insn->offset); in annotate_call_site()
1263 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1387 dest_sec = insn->sec; in add_jump_destinations()
1390 dest_sec = reloc->sym->sec; in add_jump_destinations()
1405 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1406 dest_sec = reloc->sym->sec; in add_jump_destinations()
1432 insn->sec, insn->offset, dest_sec->name, in add_jump_destinations()
1480 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1484 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1486 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1508 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1516 WARN_FUNC("unannotated intra-function call", insn->sec, insn->offset); in add_call_destinations()
1522 insn->sec, insn->offset); in add_call_destinations()
1528 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1531 insn->sec, insn->offset, in add_call_destinations()
1532 reloc->sym->sec->name, in add_call_destinations()
1612 nop->sec = special_alt->new_sec; in handle_group_alt()
1652 insn->sec, insn->offset); in handle_group_alt()
1667 insn->sec, insn->offset); in handle_group_alt()
1703 orig_insn->sec, orig_insn->offset); in handle_jump_alt()
1714 elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
1783 orig_insn->sec, orig_insn->offset); in add_special_section_alts()
1837 list_for_each_entry_from(reloc, &table->sec->reloc_list, list) { in add_jump_table()
1848 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
1852 dest_insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_jump_table()
1873 insn->sec, insn->offset); in add_jump_table()
1913 dest_insn = find_insn(file, table_reloc->sym->sec, table_reloc->addend); in find_jump_table()
1987 struct section *sec; in add_jump_table_alts() local
1994 for_each_sec(file, sec) { in add_jump_table_alts()
1995 list_for_each_entry(func, &sec->symbol_list, list) { in add_jump_table_alts()
2020 struct section *sec, *relocsec; in read_unwind_hints() local
2026 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2027 if (!sec) in read_unwind_hints()
2030 relocsec = sec->reloc; in read_unwind_hints()
2036 if (sec->sh.sh_size % sizeof(struct unwind_hint)) { in read_unwind_hints()
2043 for (i = 0; i < sec->sh.sh_size / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
2044 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
2046 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2052 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_unwind_hints()
2072 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
2077 insn->sec, insn->offset); in read_unwind_hints()
2099 insn->sec, insn->offset, hint->sp_reg); in read_unwind_hints()
2115 struct section *sec; in read_noendbr_hints() local
2119 sec = find_section_by_name(file->elf, ".rela.discard.noendbr"); in read_noendbr_hints()
2120 if (!sec) in read_noendbr_hints()
2123 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_noendbr_hints()
2124 insn = find_insn(file, reloc->sym->sec, reloc->sym->offset + reloc->addend); in read_noendbr_hints()
2138 struct section *sec; in read_retpoline_hints() local
2142 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
2143 if (!sec) in read_retpoline_hints()
2146 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_retpoline_hints()
2148 WARN("unexpected relocation symbol type in %s", sec->name); in read_retpoline_hints()
2152 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_retpoline_hints()
2163 insn->sec, insn->offset); in read_retpoline_hints()
2175 struct section *sec; in read_instr_hints() local
2179 sec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
2180 if (!sec) in read_instr_hints()
2183 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
2185 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
2189 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
2198 sec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
2199 if (!sec) in read_instr_hints()
2202 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
2204 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
2208 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
2223 struct section *sec; in read_intra_function_calls() local
2226 sec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
2227 if (!sec) in read_intra_function_calls()
2230 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_intra_function_calls()
2235 sec->name); in read_intra_function_calls()
2239 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_intra_function_calls()
2247 insn->sec, insn->offset); in read_intra_function_calls()
2259 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
2262 insn->sec, insn->offset, in read_intra_function_calls()
2263 insn->sec->name, dest_off); in read_intra_function_calls()
2298 struct section *sec; in classify_symbols() local
2301 for_each_sec(file, sec) { in classify_symbols()
2302 list_for_each_entry(func, &sec->symbol_list, list) { in classify_symbols()
2329 struct section *sec; in mark_rodata() local
2342 for_each_sec(file, sec) { in mark_rodata()
2343 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
2344 !strstr(sec->name, ".str1.")) { in mark_rodata()
2345 sec->rodata = true; in mark_rodata()
2597 WARN_FUNC("undefined stack state", insn->sec, insn->offset); in update_cfi_state()
2792 insn->sec, insn->offset); in update_cfi_state()
2803 insn->sec, insn->offset); in update_cfi_state()
2899 insn->sec, insn->offset); in update_cfi_state()
2989 insn->sec, insn->offset); in update_cfi_state()
3002 insn->sec, insn->offset); in update_cfi_state()
3039 insn->sec, insn->offset); in propagate_alt_cfi()
3066 insn->sec, insn->offset); in handle_insn_ops()
3099 insn->sec, insn->offset, in insn_cfi_match()
3110 insn->sec, insn->offset, in insn_cfi_match()
3119 insn->sec, insn->offset, cfi1->type, cfi2->type); in insn_cfi_match()
3126 insn->sec, insn->offset, in insn_cfi_match()
3181 if (!target->sec->noinstr) { in pv_call_dest()
3208 if (func->sec->noinstr) in noinstr_call_dest()
3229 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
3235 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
3241 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
3254 insn->sec, insn->offset); in validate_sibling_call()
3265 insn->sec, insn->offset); in validate_return()
3271 insn->sec, insn->offset); in validate_return()
3277 insn->sec, insn->offset); in validate_return()
3283 insn->sec, insn->offset); in validate_return()
3289 insn->sec, insn->offset); in validate_return()
3295 insn->sec, insn->offset); in validate_return()
3329 struct section *sec; in validate_branch() local
3333 sec = insn->sec; in validate_branch()
3350 sec, insn->offset); in validate_branch()
3384 sec, insn->offset); in validate_branch()
3390 sec, insn->offset); in validate_branch()
3451 sec, insn->offset); in validate_branch()
3498 sec, insn->offset); in validate_branch()
3505 WARN_FUNC("recursive UACCESS enable", sec, insn->offset); in validate_branch()
3514 WARN_FUNC("redundant UACCESS disable", sec, insn->offset); in validate_branch()
3519 WARN_FUNC("UACCESS-safe disables UACCESS", sec, insn->offset); in validate_branch()
3528 WARN_FUNC("recursive STD", sec, insn->offset); in validate_branch()
3537 WARN_FUNC("redundant CLD", sec, insn->offset); in validate_branch()
3554 WARN("%s: unexpected end of section", sec->name); in validate_branch()
3565 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3574 init_insn_state(file, &state, sec); in validate_unwind_hints()
3576 if (sec) { in validate_unwind_hints()
3577 insn = find_insn(file, sec, 0); in validate_unwind_hints()
3584 while (&insn->list != &file->insn_list && (!sec || insn->sec == sec)) { in validate_unwind_hints()
3642 WARN_FUNC("early indirect call", insn->sec, insn->offset); in validate_entry()
3650 insn->sec, insn->offset); in validate_entry()
3670 dest = find_insn(file, insn->call_dest->sec, in validate_entry()
3691 WARN_FUNC("RET before UNTRAIN", insn->sec, insn->offset); in validate_entry()
3704 WARN_FUNC("teh end!", insn->sec, insn->offset); in validate_entry()
3728 WARN_FUNC("Failed UNRET validation", insn->sec, insn->offset); in validate_unret()
3757 if (!strcmp(insn->sec->name, ".init.text") && !opts.module) in validate_retpoline()
3763 insn->sec, insn->offset); in validate_retpoline()
3768 insn->sec, insn->offset, in validate_retpoline()
3803 if (!strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
3804 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
3816 int size = find_symbol_hole_containing(insn->sec, insn->offset); in ignore_unreachable_insn()
3901 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
3915 insn = find_insn(file, sec, sym->offset); in validate_symbol()
3927 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
3933 list_for_each_entry(func, &sec->symbol_list, list) { in validate_section()
3937 init_insn_state(file, &state, sec); in validate_section()
3940 warnings += validate_symbol(file, sec, func, &state); in validate_section()
3948 struct section *sec; in validate_noinstr_sections() local
3951 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
3952 if (sec) { in validate_noinstr_sections()
3953 warnings += validate_section(file, sec); in validate_noinstr_sections()
3954 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
3957 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
3958 if (sec) { in validate_noinstr_sections()
3959 warnings += validate_section(file, sec); in validate_noinstr_sections()
3960 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
3968 struct section *sec; in validate_functions() local
3971 for_each_sec(file, sec) { in validate_functions()
3972 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
3975 warnings += validate_section(file, sec); in validate_functions()
4014 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4031 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4063 insn->sec, insn->offset, in validate_ibt_insn()
4064 offstr(dest->sec, dest->offset)); in validate_ibt_insn()
4077 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4091 reloc->sec->base, reloc->offset, in validate_ibt_data_reloc()
4092 offstr(dest->sec, dest->offset)); in validate_ibt_data_reloc()
4104 struct section *sec; in validate_ibt() local
4112 for_each_sec(file, sec) { in validate_ibt()
4115 if (sec->sh.sh_flags & SHF_EXECINSTR) in validate_ibt()
4118 if (!sec->reloc) in validate_ibt()
4125 if ((!strncmp(sec->name, ".discard", 8) && in validate_ibt()
4126 strcmp(sec->name, ".discard.ibt_endbr_noseal")) || in validate_ibt()
4127 !strncmp(sec->name, ".debug", 6) || in validate_ibt()
4128 !strcmp(sec->name, ".altinstructions") || in validate_ibt()
4129 !strcmp(sec->name, ".ibt_endbr_seal") || in validate_ibt()
4130 !strcmp(sec->name, ".orc_unwind_ip") || in validate_ibt()
4131 !strcmp(sec->name, ".parainstructions") || in validate_ibt()
4132 !strcmp(sec->name, ".retpoline_sites") || in validate_ibt()
4133 !strcmp(sec->name, ".smp_locks") || in validate_ibt()
4134 !strcmp(sec->name, ".static_call_sites") || in validate_ibt()
4135 !strcmp(sec->name, "_error_injection_whitelist") || in validate_ibt()
4136 !strcmp(sec->name, "_kprobe_blacklist") || in validate_ibt()
4137 !strcmp(sec->name, "__bug_table") || in validate_ibt()
4138 !strcmp(sec->name, "__ex_table") || in validate_ibt()
4139 !strcmp(sec->name, "__jump_table") || in validate_ibt()
4140 !strcmp(sec->name, "__mcount_loc") || in validate_ibt()
4141 !strcmp(sec->name, ".kcfi_traps") || in validate_ibt()
4142 strstr(sec->name, "__patchable_function_entries")) in validate_ibt()
4145 list_for_each_entry(reloc, &sec->reloc->reloc_list, list) in validate_ibt()
4167 insn->sec, insn->offset); in validate_sls()
4175 insn->sec, insn->offset); in validate_sls()
4198 WARN_FUNC("unreachable instruction", insn->sec, insn->offset); in validate_reachable_instructions()