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()
54 return find_insn(file, insn->sec, insn->offset + insn->len); in next_insn_same_sec()
80 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
88 return find_insn(file, insn->sec, insn->offset - insn->prev_len); in prev_insn_same_sec()
113 for (insn = find_insn(file, func->sec, func->offset); \
118 for (insn = find_insn(file, sym->sec, sym->offset); \
215 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
278 struct section *sec) in init_insn_state() argument
288 if (opts.link && opts.noinstr && sec) in init_insn_state()
289 state->noinstr = sec->noinstr; in init_insn_state()
370 struct section *sec; in decode_instructions() local
376 for_each_sec(file, sec) { in decode_instructions()
381 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
384 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
385 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
386 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
387 sec->text = true; in decode_instructions()
389 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
390 !strcmp(sec->name, ".entry.text") || in decode_instructions()
391 !strcmp(sec->name, ".cpuidle.text") || in decode_instructions()
392 !strncmp(sec->name, ".text..__x86.", 13)) in decode_instructions()
393 sec->noinstr = true; in decode_instructions()
401 if (!strcmp(sec->name, ".init.text") && !opts.module) in decode_instructions()
402 sec->init = true; in decode_instructions()
404 for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { in decode_instructions()
419 insn->sec = sec; in decode_instructions()
423 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
424 sec->sh.sh_size - offset, in decode_instructions()
439 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
445 sec_for_each_sym(sec, func) { in decode_instructions()
449 if (func->offset == sec->sh.sh_size) { in decode_instructions()
461 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
506 reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
512 func = find_symbol_by_offset(reloc->sym->sec, in add_pv_ops()
567 struct section *sec) in find_last_insn() argument
571 unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0; in find_last_insn()
573 for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--) in find_last_insn()
574 insn = find_insn(file, sec, offset); in find_last_insn()
605 insn = find_insn(file, reloc->sym->sec, addend); in add_dead_ends()
608 else if (addend == reloc->sym->sec->sh.sh_size) { in add_dead_ends()
609 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
612 reloc->sym->sec->name, addend); in add_dead_ends()
617 reloc->sym->sec->name, addend); in add_dead_ends()
644 insn = find_insn(file, reloc->sym->sec, addend); in add_dead_ends()
647 else if (addend == reloc->sym->sec->sh.sh_size) { in add_dead_ends()
648 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
651 reloc->sym->sec->name, addend); in add_dead_ends()
656 reloc->sym->sec->name, addend); in add_dead_ends()
669 struct section *sec; in create_static_call_sections() local
675 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
676 if (sec) { in create_static_call_sections()
689 sec = elf_create_section_pair(file->elf, ".static_call_sites", in create_static_call_sections()
691 if (!sec) in create_static_call_sections()
695 sec->sh.sh_flags |= SHF_WRITE; in create_static_call_sections()
701 if (!elf_init_reloc_text_sym(file->elf, sec, in create_static_call_sections()
703 insn->sec, insn->offset)) in create_static_call_sections()
743 if (!elf_init_reloc_data_sym(file->elf, sec, in create_static_call_sections()
758 struct section *sec; in create_retpoline_sites_sections() local
761 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
762 if (sec) { in create_retpoline_sites_sections()
774 sec = elf_create_section_pair(file->elf, ".retpoline_sites", in create_retpoline_sites_sections()
776 if (!sec) in create_retpoline_sites_sections()
782 if (!elf_init_reloc_text_sym(file->elf, sec, in create_retpoline_sites_sections()
784 insn->sec, insn->offset)) in create_retpoline_sites_sections()
796 struct section *sec; in create_return_sites_sections() local
799 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
800 if (sec) { in create_return_sites_sections()
812 sec = elf_create_section_pair(file->elf, ".return_sites", in create_return_sites_sections()
814 if (!sec) in create_return_sites_sections()
820 if (!elf_init_reloc_text_sym(file->elf, sec, in create_return_sites_sections()
822 insn->sec, insn->offset)) in create_return_sites_sections()
834 struct section *sec; in create_ibt_endbr_seal_sections() local
837 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
838 if (sec) { in create_ibt_endbr_seal_sections()
856 sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal", in create_ibt_endbr_seal_sections()
858 if (!sec) in create_ibt_endbr_seal_sections()
864 int *site = (int *)sec->data->d_buf + idx; in create_ibt_endbr_seal_sections()
874 if (!elf_init_reloc_text_sym(file->elf, sec, in create_ibt_endbr_seal_sections()
876 insn->sec, insn->offset)) in create_ibt_endbr_seal_sections()
887 struct section *sec; in create_cfi_sections() local
891 sec = find_section_by_name(file->elf, ".cfi_sites"); in create_cfi_sections()
892 if (sec) { in create_cfi_sections()
909 sec = elf_create_section_pair(file->elf, ".cfi_sites", in create_cfi_sections()
911 if (!sec) in create_cfi_sections()
922 if (!elf_init_reloc_text_sym(file->elf, sec, in create_cfi_sections()
924 sym->sec, sym->offset)) in create_cfi_sections()
937 struct section *sec; in create_mcount_loc_sections() local
940 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
941 if (sec) { in create_mcount_loc_sections()
954 sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size, in create_mcount_loc_sections()
956 if (!sec) in create_mcount_loc_sections()
959 sec->sh.sh_addralign = addr_size; in create_mcount_loc_sections()
966 reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx, in create_mcount_loc_sections()
967 insn->sec, insn->offset); in create_mcount_loc_sections()
982 struct section *sec; in create_direct_call_sections() local
985 sec = find_section_by_name(file->elf, ".call_sites"); in create_direct_call_sections()
986 if (sec) { in create_direct_call_sections()
999 sec = elf_create_section_pair(file->elf, ".call_sites", in create_direct_call_sections()
1001 if (!sec) in create_direct_call_sections()
1007 if (!elf_init_reloc_text_sym(file->elf, sec, in create_direct_call_sections()
1009 insn->sec, insn->offset)) in create_direct_call_sections()
1039 func = find_func_by_offset(reloc->sym->sec, reloc_addend(reloc)); in add_ignores()
1279 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in add_ignore_alternatives()
1328 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1364 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in annotate_call_site()
1382 if (opts.hack_noinstr && insn->sec->noinstr && sym->profiling_func) { in annotate_call_site()
1386 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1413 elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1424 if (insn->type == INSN_CALL && !insn->sec->init) in annotate_call_site()
1564 dest_sec = insn->sec; in add_jump_destinations()
1567 dest_sec = reloc->sym->sec; in add_jump_destinations()
1582 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1583 dest_sec = reloc->sym->sec; in add_jump_destinations()
1656 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1660 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1662 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1684 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1703 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1706 reloc->sym->sec->name, dest_off); in add_call_destinations()
1796 nop->sec = special_alt->new_sec; in handle_group_alt()
1892 elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
2016 for_each_reloc_from(table->sec, reloc) { in add_jump_table()
2027 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
2031 dest_insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in add_jump_table()
2092 dest_insn = find_insn(file, table_reloc->sym->sec, reloc_addend(table_reloc)); in find_jump_table()
2207 struct section *sec; in read_unwind_hints() local
2213 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2214 if (!sec) in read_unwind_hints()
2217 if (!sec->rsec) { in read_unwind_hints()
2222 if (sec->sh.sh_size % sizeof(struct unwind_hint)) { in read_unwind_hints()
2229 for (i = 0; i < sec->sh.sh_size / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
2230 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
2232 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2238 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_unwind_hints()
2263 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
2306 insn = find_insn(file, reloc->sym->sec, in read_noendbr_hints()
2335 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_retpoline_hints()
2371 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_instr_hints()
2390 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_instr_hints()
2418 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_validate_unret_hints()
2449 insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); in read_intra_function_calls()
2468 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
2471 insn->sec->name, dest_off); in read_intra_function_calls()
2537 struct section *sec; in mark_rodata() local
2550 for_each_sec(file, sec) { in mark_rodata()
2551 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
2552 !strstr(sec->name, ".str1.")) { in mark_rodata()
2553 sec->rodata = true; in mark_rodata()
3247 char *where = offstr(insn->sec, insn->offset); in propagate_alt_cfi()
3387 if (!target->sec->noinstr) { in pv_call_dest()
3414 if (func->sec->noinstr) in noinstr_call_dest()
3548 struct section *sec; in validate_branch() local
3552 sec = insn->sec; in validate_branch()
3767 WARN("%s: unexpected end of section", sec->name); in validate_branch()
3792 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3801 init_insn_state(file, &state, sec); in validate_unwind_hints()
3803 if (sec) { in validate_unwind_hints()
3804 sec_for_each_insn(file, sec, insn) in validate_unwind_hints()
3882 dest = find_insn(file, insn_call_dest(insn)->sec, in validate_unret()
3962 if (insn->sec->init) in validate_retpoline()
4006 if (!strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
4007 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
4019 int size = find_symbol_hole_containing(insn->sec, insn->offset); in ignore_unreachable_insn()
4109 insn = find_insn(file, func->sec, func->offset); in add_prefix_symbol()
4154 struct section *sec; in add_prefix_symbols() local
4157 for_each_sec(file, sec) { in add_prefix_symbols()
4158 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in add_prefix_symbols()
4161 sec_for_each_sym(sec, func) { in add_prefix_symbols()
4172 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
4186 insn = find_insn(file, sec, sym->offset); in validate_symbol()
4198 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
4204 sec_for_each_sym(sec, func) { in validate_section()
4208 init_insn_state(file, &state, sec); in validate_section()
4211 warnings += validate_symbol(file, sec, func, &state); in validate_section()
4219 struct section *sec; in validate_noinstr_sections() local
4222 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
4223 if (sec) { in validate_noinstr_sections()
4224 warnings += validate_section(file, sec); in validate_noinstr_sections()
4225 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4228 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
4229 if (sec) { in validate_noinstr_sections()
4230 warnings += validate_section(file, sec); in validate_noinstr_sections()
4231 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4234 sec = find_section_by_name(file->elf, ".cpuidle.text"); in validate_noinstr_sections()
4235 if (sec) { in validate_noinstr_sections()
4236 warnings += validate_section(file, sec); in validate_noinstr_sections()
4237 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4245 struct section *sec; in validate_functions() local
4248 for_each_sec(file, sec) { in validate_functions()
4249 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
4252 warnings += validate_section(file, sec); in validate_functions()
4266 struct symbol *sym = find_symbol_containing(insn->sec, insn->offset-1); in noendbr_range()
4272 first = find_insn(file, sym->sec, sym->offset); in noendbr_range()
4309 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4327 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4369 WARN_INSN(insn, "relocation to !ENDBR: %s", offstr(dest->sec, dest->offset)); in validate_ibt_insn()
4382 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4396 reloc->sec->base, reloc_offset(reloc), in validate_ibt_data_reloc()
4397 offstr(dest->sec, dest->offset)); in validate_ibt_data_reloc()
4409 struct section *sec; in validate_ibt() local
4417 for_each_sec(file, sec) { in validate_ibt()
4420 if (sec->sh.sh_flags & SHF_EXECINSTR) in validate_ibt()
4423 if (!sec->rsec) in validate_ibt()
4430 if ((!strncmp(sec->name, ".discard", 8) && in validate_ibt()
4431 strcmp(sec->name, ".discard.ibt_endbr_noseal")) || in validate_ibt()
4432 !strncmp(sec->name, ".debug", 6) || in validate_ibt()
4433 !strcmp(sec->name, ".altinstructions") || in validate_ibt()
4434 !strcmp(sec->name, ".ibt_endbr_seal") || in validate_ibt()
4435 !strcmp(sec->name, ".orc_unwind_ip") || in validate_ibt()
4436 !strcmp(sec->name, ".parainstructions") || in validate_ibt()
4437 !strcmp(sec->name, ".retpoline_sites") || in validate_ibt()
4438 !strcmp(sec->name, ".smp_locks") || in validate_ibt()
4439 !strcmp(sec->name, ".static_call_sites") || in validate_ibt()
4440 !strcmp(sec->name, "_error_injection_whitelist") || in validate_ibt()
4441 !strcmp(sec->name, "_kprobe_blacklist") || in validate_ibt()
4442 !strcmp(sec->name, "__bug_table") || in validate_ibt()
4443 !strcmp(sec->name, "__ex_table") || in validate_ibt()
4444 !strcmp(sec->name, "__jump_table") || in validate_ibt()
4445 !strcmp(sec->name, "__mcount_loc") || in validate_ibt()
4446 !strcmp(sec->name, ".kcfi_traps") || in validate_ibt()
4447 strstr(sec->name, "__patchable_function_entries")) in validate_ibt()
4450 for_each_reloc(sec->rsec, reloc) in validate_ibt()