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); \
279 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
342 struct section *sec) in init_insn_state() argument
347 if (opts.noinstr && sec) in init_insn_state()
348 state->noinstr = sec->noinstr; in init_insn_state()
429 struct section *sec; in decode_instructions() local
435 for_each_sec(file, sec) { in decode_instructions()
440 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
443 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
444 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
445 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
446 sec->text = true; in decode_instructions()
448 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
449 !strcmp(sec->name, ".entry.text") || in decode_instructions()
450 !strcmp(sec->name, ".cpuidle.text") || in decode_instructions()
451 !strncmp(sec->name, ".text..__x86.", 13)) in decode_instructions()
452 sec->noinstr = true; in decode_instructions()
460 if (!strcmp(sec->name, ".init.text") && !opts.module) in decode_instructions()
461 sec->init = true; in decode_instructions()
463 for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { in decode_instructions()
478 insn->sec = sec; in decode_instructions()
482 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
483 sec->sh.sh_size - offset, in decode_instructions()
498 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
502 sec_for_each_sym(sec, func) { in decode_instructions()
506 if (func->offset == sec->sh.sh_size) { in decode_instructions()
517 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
561 reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
569 func = find_symbol_by_offset(reloc->sym->sec, in add_pv_ops()
572 ERROR_FUNC(reloc->sym->sec, reloc_addend(reloc), in add_pv_ops()
635 struct section *sec; in create_static_call_sections() local
641 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
642 if (sec) { in create_static_call_sections()
655 sec = elf_create_section_pair(file->elf, ".static_call_sites", in create_static_call_sections()
657 if (!sec) in create_static_call_sections()
661 sec->sh.sh_flags |= SHF_WRITE; in create_static_call_sections()
667 if (!elf_init_reloc_text_sym(file->elf, sec, in create_static_call_sections()
669 insn->sec, insn->offset)) in create_static_call_sections()
706 if (!elf_init_reloc_data_sym(file->elf, sec, in create_static_call_sections()
721 struct section *sec; in create_retpoline_sites_sections() local
724 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
725 if (sec) { in create_retpoline_sites_sections()
737 sec = elf_create_section_pair(file->elf, ".retpoline_sites", in create_retpoline_sites_sections()
739 if (!sec) in create_retpoline_sites_sections()
745 if (!elf_init_reloc_text_sym(file->elf, sec, in create_retpoline_sites_sections()
747 insn->sec, insn->offset)) in create_retpoline_sites_sections()
759 struct section *sec; in create_return_sites_sections() local
762 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
763 if (sec) { in create_return_sites_sections()
775 sec = elf_create_section_pair(file->elf, ".return_sites", in create_return_sites_sections()
777 if (!sec) in create_return_sites_sections()
783 if (!elf_init_reloc_text_sym(file->elf, sec, in create_return_sites_sections()
785 insn->sec, insn->offset)) in create_return_sites_sections()
797 struct section *sec; in create_ibt_endbr_seal_sections() local
800 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
801 if (sec) { in create_ibt_endbr_seal_sections()
819 sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal", in create_ibt_endbr_seal_sections()
821 if (!sec) in create_ibt_endbr_seal_sections()
827 int *site = (int *)sec->data->d_buf + idx; in create_ibt_endbr_seal_sections()
840 if (!elf_init_reloc_text_sym(file->elf, sec, in create_ibt_endbr_seal_sections()
842 insn->sec, insn->offset)) in create_ibt_endbr_seal_sections()
853 struct section *sec; in create_cfi_sections() local
857 sec = find_section_by_name(file->elf, ".cfi_sites"); in create_cfi_sections()
858 if (sec) { in create_cfi_sections()
875 sec = elf_create_section_pair(file->elf, ".cfi_sites", in create_cfi_sections()
877 if (!sec) in create_cfi_sections()
888 if (!elf_init_reloc_text_sym(file->elf, sec, in create_cfi_sections()
890 sym->sec, sym->offset)) in create_cfi_sections()
903 struct section *sec; in create_mcount_loc_sections() local
906 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
907 if (sec) { in create_mcount_loc_sections()
920 sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size, in create_mcount_loc_sections()
922 if (!sec) in create_mcount_loc_sections()
925 sec->sh.sh_addralign = addr_size; in create_mcount_loc_sections()
932 reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx, in create_mcount_loc_sections()
933 insn->sec, insn->offset); in create_mcount_loc_sections()
948 struct section *sec; in create_direct_call_sections() local
951 sec = find_section_by_name(file->elf, ".call_sites"); in create_direct_call_sections()
952 if (sec) { in create_direct_call_sections()
965 sec = elf_create_section_pair(file->elf, ".call_sites", in create_direct_call_sections()
967 if (!sec) in create_direct_call_sections()
973 if (!elf_init_reloc_text_sym(file->elf, sec, in create_direct_call_sections()
975 insn->sec, insn->offset)) in create_direct_call_sections()
1004 func = find_func_by_offset(reloc->sym->sec, reloc_addend(reloc)); in add_ignores()
1267 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1312 if (opts.hack_noinstr && insn->sec->noinstr && sym->profiling_func) { in annotate_call_site()
1316 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1345 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1358 if (insn->type == INSN_CALL && !insn->sec->init && in annotate_call_site()
1504 dest_sec = insn->sec; in add_jump_destinations()
1507 dest_sec = reloc->sym->sec; in add_jump_destinations()
1526 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1527 dest_sec = reloc->sym->sec; in add_jump_destinations()
1557 dest_sec == insn->sec && in add_jump_destinations()
1628 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1632 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1634 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1658 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1679 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1682 reloc->sym->sec->name, dest_off); in add_call_destinations()
1780 nop->sec = special_alt->new_sec; in handle_group_alt()
1876 if (elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
2002 for_each_reloc_from(table->sec, reloc) { in add_jump_table()
2017 if (reloc->sym->sec == pfunc->sec && sym_offset == pfunc->offset) in add_jump_table()
2024 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
2028 dest_insn = find_insn(file, reloc->sym->sec, sym_offset); in add_jump_table()
2094 dest_insn = find_insn(file, table_reloc->sym->sec, sym_offset); in find_jump_table()
2196 struct section *sec; in read_unwind_hints() local
2203 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2204 if (!sec) in read_unwind_hints()
2207 if (!sec->rsec) { in read_unwind_hints()
2212 if (sec->sh.sh_size % sizeof(struct unwind_hint)) { in read_unwind_hints()
2219 for (i = 0; i < sec->sh.sh_size / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
2220 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
2222 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2233 ERROR("unexpected relocation symbol type in %s", sec->rsec->name); in read_unwind_hints()
2237 insn = find_insn(file, reloc->sym->sec, offset); in read_unwind_hints()
2262 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
2298 struct section *sec; in read_annotate() local
2304 sec = find_section_by_name(file->elf, ".discard.annotate_insn"); in read_annotate()
2305 if (!sec) in read_annotate()
2308 if (!sec->rsec) in read_annotate()
2311 if (sec->sh.sh_entsize != 8) { in read_annotate()
2314 WARN("%s: dodgy linker, sh_entsize != 8", sec->name); in read_annotate()
2317 sec->sh.sh_entsize = 8; in read_annotate()
2320 for_each_reloc(sec->rsec, reloc) { in read_annotate()
2321 type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4); in read_annotate()
2325 insn = find_insn(file, reloc->sym->sec, offset); in read_annotate()
2383 insn->jump_dest = find_insn(file, insn->sec, dest_off); in __annotate_ifc()
2386 insn->sec->name, dest_off); in __annotate_ifc()
2505 struct section *sec; in mark_rodata() local
2518 for_each_sec(file, sec) { in mark_rodata()
2519 if ((!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
2520 !strstr(sec->name, ".str1.")) || in mark_rodata()
2521 !strncmp(sec->name, ".data.rel.ro", 12)) { in mark_rodata()
2522 sec->rodata = true; in mark_rodata()
3218 offstr(insn->sec, insn->offset)); in propagate_alt_cfi()
3363 if (!target->sec->noinstr) { in pv_call_dest()
3390 if (func->sec->noinstr) in noinstr_call_dest()
3552 struct section *sec; in validate_branch() local
3559 sec = insn->sec; in validate_branch()
3798 sec->name); in validate_branch()
3823 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3832 init_insn_state(file, &state, sec); in validate_unwind_hints()
3834 if (sec) { in validate_unwind_hints()
3835 sec_for_each_insn(file, sec, insn) in validate_unwind_hints()
3905 dest = find_insn(file, insn_call_dest(insn)->sec, in validate_unret()
3989 if (insn->sec->init) in validate_retpoline()
4034 if (!strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
4035 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
4047 int size = find_symbol_hole_containing(insn->sec, insn->offset); in ignore_unreachable_insn()
4135 insn = find_insn(file, func->sec, func->offset); in add_prefix_symbol()
4180 struct section *sec; in add_prefix_symbols() local
4183 for_each_sec(file, sec) { in add_prefix_symbols()
4184 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in add_prefix_symbols()
4187 sec_for_each_sym(sec, func) { in add_prefix_symbols()
4198 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
4212 insn = find_insn(file, sec, sym->offset); in validate_symbol()
4225 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
4231 sec_for_each_sym(sec, func) { in validate_section()
4235 init_insn_state(file, &state, sec); in validate_section()
4238 warnings += validate_symbol(file, sec, func, &state); in validate_section()
4246 struct section *sec; in validate_noinstr_sections() local
4249 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
4250 if (sec) { in validate_noinstr_sections()
4251 warnings += validate_section(file, sec); in validate_noinstr_sections()
4252 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4255 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
4256 if (sec) { in validate_noinstr_sections()
4257 warnings += validate_section(file, sec); in validate_noinstr_sections()
4258 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4261 sec = find_section_by_name(file->elf, ".cpuidle.text"); in validate_noinstr_sections()
4262 if (sec) { in validate_noinstr_sections()
4263 warnings += validate_section(file, sec); in validate_noinstr_sections()
4264 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4272 struct section *sec; in validate_functions() local
4275 for_each_sec(file, sec) { in validate_functions()
4276 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
4279 warnings += validate_section(file, sec); in validate_functions()
4293 struct symbol *sym = find_symbol_containing(insn->sec, insn->offset-1); in noendbr_range()
4299 first = find_insn(file, sym->sec, sym->offset); in noendbr_range()
4350 WARN_INSN(insn, "relocation to !ENDBR: %s", offstr(dest->sec, dest->offset)); in __validate_ibt_insn()
4383 dest = find_insn(file, insn->sec, off); in validate_ibt_insn()
4399 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4410 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4425 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4438 WARN_FUNC(reloc->sec->base, reloc_offset(reloc), in validate_ibt_data_reloc()
4439 "data relocation to !ENDBR: %s", offstr(dest->sec, dest->offset)); in validate_ibt_data_reloc()
4451 struct section *sec; in validate_ibt() local
4459 for_each_sec(file, sec) { in validate_ibt()
4462 if (sec->sh.sh_flags & SHF_EXECINSTR) in validate_ibt()
4465 if (!sec->rsec) in validate_ibt()
4472 if ((!strncmp(sec->name, ".discard", 8) && in validate_ibt()
4473 strcmp(sec->name, ".discard.ibt_endbr_noseal")) || in validate_ibt()
4474 !strncmp(sec->name, ".debug", 6) || in validate_ibt()
4475 !strcmp(sec->name, ".altinstructions") || in validate_ibt()
4476 !strcmp(sec->name, ".ibt_endbr_seal") || in validate_ibt()
4477 !strcmp(sec->name, ".orc_unwind_ip") || in validate_ibt()
4478 !strcmp(sec->name, ".parainstructions") || in validate_ibt()
4479 !strcmp(sec->name, ".retpoline_sites") || in validate_ibt()
4480 !strcmp(sec->name, ".smp_locks") || in validate_ibt()
4481 !strcmp(sec->name, ".static_call_sites") || in validate_ibt()
4482 !strcmp(sec->name, "_error_injection_whitelist") || in validate_ibt()
4483 !strcmp(sec->name, "_kprobe_blacklist") || in validate_ibt()
4484 !strcmp(sec->name, "__bug_table") || in validate_ibt()
4485 !strcmp(sec->name, "__ex_table") || in validate_ibt()
4486 !strcmp(sec->name, "__jump_table") || in validate_ibt()
4487 !strcmp(sec->name, "__mcount_loc") || in validate_ibt()
4488 !strcmp(sec->name, ".kcfi_traps") || in validate_ibt()
4489 !strcmp(sec->name, ".llvm.call-graph-profile") || in validate_ibt()
4490 !strcmp(sec->name, ".llvm_bb_addr_map") || in validate_ibt()
4491 !strcmp(sec->name, "__tracepoints") || in validate_ibt()
4492 strstr(sec->name, "__patchable_function_entries")) in validate_ibt()
4495 for_each_reloc(sec->rsec, reloc) in validate_ibt()