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); \
277 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
340 struct section *sec) in init_insn_state() argument
345 if (opts.noinstr && sec) in init_insn_state()
346 state->noinstr = sec->noinstr; in init_insn_state()
427 struct section *sec; in decode_instructions() local
433 for_each_sec(file, sec) { in decode_instructions()
438 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
441 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
442 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
443 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
444 sec->text = true; in decode_instructions()
446 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
447 !strcmp(sec->name, ".entry.text") || in decode_instructions()
448 !strcmp(sec->name, ".cpuidle.text") || in decode_instructions()
449 !strncmp(sec->name, ".text..__x86.", 13)) in decode_instructions()
450 sec->noinstr = true; in decode_instructions()
458 if (!strcmp(sec->name, ".init.text") && !opts.module) in decode_instructions()
459 sec->init = true; in decode_instructions()
461 for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { in decode_instructions()
476 insn->sec = sec; in decode_instructions()
480 ret = arch_decode_instruction(file, sec, offset, in decode_instructions()
481 sec->sh.sh_size - offset, in decode_instructions()
496 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
500 sec_for_each_sym(sec, func) { in decode_instructions()
504 if (func->offset == sec->sh.sh_size) { in decode_instructions()
515 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
559 reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off); in add_pv_ops()
567 func = find_symbol_by_offset(reloc->sym->sec, in add_pv_ops()
570 ERROR_FUNC(reloc->sym->sec, reloc_addend(reloc), in add_pv_ops()
633 struct section *sec; in create_static_call_sections() local
639 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
640 if (sec) { in create_static_call_sections()
653 sec = elf_create_section_pair(file->elf, ".static_call_sites", in create_static_call_sections()
655 if (!sec) in create_static_call_sections()
659 sec->sh.sh_flags |= SHF_WRITE; in create_static_call_sections()
665 if (!elf_init_reloc_text_sym(file->elf, sec, in create_static_call_sections()
667 insn->sec, insn->offset)) in create_static_call_sections()
704 if (!elf_init_reloc_data_sym(file->elf, sec, in create_static_call_sections()
719 struct section *sec; in create_retpoline_sites_sections() local
722 sec = find_section_by_name(file->elf, ".retpoline_sites"); in create_retpoline_sites_sections()
723 if (sec) { in create_retpoline_sites_sections()
735 sec = elf_create_section_pair(file->elf, ".retpoline_sites", in create_retpoline_sites_sections()
737 if (!sec) in create_retpoline_sites_sections()
743 if (!elf_init_reloc_text_sym(file->elf, sec, in create_retpoline_sites_sections()
745 insn->sec, insn->offset)) in create_retpoline_sites_sections()
757 struct section *sec; in create_return_sites_sections() local
760 sec = find_section_by_name(file->elf, ".return_sites"); in create_return_sites_sections()
761 if (sec) { in create_return_sites_sections()
773 sec = elf_create_section_pair(file->elf, ".return_sites", in create_return_sites_sections()
775 if (!sec) in create_return_sites_sections()
781 if (!elf_init_reloc_text_sym(file->elf, sec, in create_return_sites_sections()
783 insn->sec, insn->offset)) in create_return_sites_sections()
795 struct section *sec; in create_ibt_endbr_seal_sections() local
798 sec = find_section_by_name(file->elf, ".ibt_endbr_seal"); in create_ibt_endbr_seal_sections()
799 if (sec) { in create_ibt_endbr_seal_sections()
817 sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal", in create_ibt_endbr_seal_sections()
819 if (!sec) in create_ibt_endbr_seal_sections()
825 int *site = (int *)sec->data->d_buf + idx; in create_ibt_endbr_seal_sections()
838 if (!elf_init_reloc_text_sym(file->elf, sec, in create_ibt_endbr_seal_sections()
840 insn->sec, insn->offset)) in create_ibt_endbr_seal_sections()
851 struct section *sec; in create_cfi_sections() local
855 sec = find_section_by_name(file->elf, ".cfi_sites"); in create_cfi_sections()
856 if (sec) { in create_cfi_sections()
873 sec = elf_create_section_pair(file->elf, ".cfi_sites", in create_cfi_sections()
875 if (!sec) in create_cfi_sections()
886 if (!elf_init_reloc_text_sym(file->elf, sec, in create_cfi_sections()
888 sym->sec, sym->offset)) in create_cfi_sections()
901 struct section *sec; in create_mcount_loc_sections() local
904 sec = find_section_by_name(file->elf, "__mcount_loc"); in create_mcount_loc_sections()
905 if (sec) { in create_mcount_loc_sections()
918 sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size, in create_mcount_loc_sections()
920 if (!sec) in create_mcount_loc_sections()
923 sec->sh.sh_addralign = addr_size; in create_mcount_loc_sections()
930 reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx, in create_mcount_loc_sections()
931 insn->sec, insn->offset); in create_mcount_loc_sections()
946 struct section *sec; in create_direct_call_sections() local
949 sec = find_section_by_name(file->elf, ".call_sites"); in create_direct_call_sections()
950 if (sec) { in create_direct_call_sections()
963 sec = elf_create_section_pair(file->elf, ".call_sites", in create_direct_call_sections()
965 if (!sec) in create_direct_call_sections()
971 if (!elf_init_reloc_text_sym(file->elf, sec, in create_direct_call_sections()
973 insn->sec, insn->offset)) in create_direct_call_sections()
1002 func = find_func_by_offset(reloc->sym->sec, reloc_addend(reloc)); in add_ignores()
1265 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in insn_reloc()
1310 if (opts.hack_noinstr && insn->sec->noinstr && sym->profiling_func) { in annotate_call_site()
1314 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1343 if (elf_write_insn(file->elf, insn->sec, in annotate_call_site()
1356 if (insn->type == INSN_CALL && !insn->sec->init && in annotate_call_site()
1502 dest_sec = insn->sec; in add_jump_destinations()
1505 dest_sec = reloc->sym->sec; in add_jump_destinations()
1524 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
1525 dest_sec = reloc->sym->sec; in add_jump_destinations()
1555 dest_sec == insn->sec && in add_jump_destinations()
1626 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
1630 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
1632 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
1656 dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
1677 dest = find_call_destination(reloc->sym->sec, dest_off); in add_call_destinations()
1680 reloc->sym->sec->name, dest_off); in add_call_destinations()
1778 nop->sec = special_alt->new_sec; in handle_group_alt()
1874 if (elf_write_insn(file->elf, orig_insn->sec, in handle_jump_alt()
2000 for_each_reloc_from(table->sec, reloc) { in add_jump_table()
2015 if (reloc->sym->sec == pfunc->sec && sym_offset == pfunc->offset) in add_jump_table()
2022 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
2026 dest_insn = find_insn(file, reloc->sym->sec, sym_offset); in add_jump_table()
2092 dest_insn = find_insn(file, table_reloc->sym->sec, sym_offset); in find_jump_table()
2194 struct section *sec; in read_unwind_hints() local
2201 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
2202 if (!sec) in read_unwind_hints()
2205 if (!sec->rsec) { in read_unwind_hints()
2210 if (sec->sh.sh_size % sizeof(struct unwind_hint)) { in read_unwind_hints()
2217 for (i = 0; i < sec->sh.sh_size / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
2218 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
2220 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
2231 ERROR("unexpected relocation symbol type in %s", sec->rsec->name); in read_unwind_hints()
2235 insn = find_insn(file, reloc->sym->sec, offset); in read_unwind_hints()
2260 struct symbol *sym = find_symbol_by_offset(insn->sec, insn->offset); in read_unwind_hints()
2296 struct section *sec; in read_annotate() local
2302 sec = find_section_by_name(file->elf, ".discard.annotate_insn"); in read_annotate()
2303 if (!sec) in read_annotate()
2306 if (!sec->rsec) in read_annotate()
2309 if (sec->sh.sh_entsize != 8) { in read_annotate()
2312 WARN("%s: dodgy linker, sh_entsize != 8", sec->name); in read_annotate()
2315 sec->sh.sh_entsize = 8; in read_annotate()
2318 for_each_reloc(sec->rsec, reloc) { in read_annotate()
2319 type = *(u32 *)(sec->data->d_buf + (reloc_idx(reloc) * sec->sh.sh_entsize) + 4); in read_annotate()
2322 insn = find_insn(file, reloc->sym->sec, offset); in read_annotate()
2380 insn->jump_dest = find_insn(file, insn->sec, dest_off); in __annotate_ifc()
2383 insn->sec->name, dest_off); in __annotate_ifc()
2502 struct section *sec; in mark_rodata() local
2515 for_each_sec(file, sec) { in mark_rodata()
2516 if ((!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
2517 !strstr(sec->name, ".str1.")) || in mark_rodata()
2518 !strncmp(sec->name, ".data.rel.ro", 12)) { in mark_rodata()
2519 sec->rodata = true; in mark_rodata()
3215 offstr(insn->sec, insn->offset)); in propagate_alt_cfi()
3360 if (!target->sec->noinstr) { in pv_call_dest()
3387 if (func->sec->noinstr) in noinstr_call_dest()
3549 struct section *sec; in validate_branch() local
3556 sec = insn->sec; in validate_branch()
3795 sec->name); in validate_branch()
3820 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
3829 init_insn_state(file, &state, sec); in validate_unwind_hints()
3831 if (sec) { in validate_unwind_hints()
3832 sec_for_each_insn(file, sec, insn) in validate_unwind_hints()
3902 dest = find_insn(file, insn_call_dest(insn)->sec, in validate_unret()
3986 if (insn->sec->init) in validate_retpoline()
4031 if (!strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
4032 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
4044 int size = find_symbol_hole_containing(insn->sec, insn->offset); in ignore_unreachable_insn()
4132 insn = find_insn(file, func->sec, func->offset); in add_prefix_symbol()
4177 struct section *sec; in add_prefix_symbols() local
4180 for_each_sec(file, sec) { in add_prefix_symbols()
4181 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in add_prefix_symbols()
4184 sec_for_each_sym(sec, func) { in add_prefix_symbols()
4195 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
4209 insn = find_insn(file, sec, sym->offset); in validate_symbol()
4222 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
4228 sec_for_each_sym(sec, func) { in validate_section()
4232 init_insn_state(file, &state, sec); in validate_section()
4235 warnings += validate_symbol(file, sec, func, &state); in validate_section()
4243 struct section *sec; in validate_noinstr_sections() local
4246 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_noinstr_sections()
4247 if (sec) { in validate_noinstr_sections()
4248 warnings += validate_section(file, sec); in validate_noinstr_sections()
4249 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4252 sec = find_section_by_name(file->elf, ".entry.text"); in validate_noinstr_sections()
4253 if (sec) { in validate_noinstr_sections()
4254 warnings += validate_section(file, sec); in validate_noinstr_sections()
4255 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4258 sec = find_section_by_name(file->elf, ".cpuidle.text"); in validate_noinstr_sections()
4259 if (sec) { in validate_noinstr_sections()
4260 warnings += validate_section(file, sec); in validate_noinstr_sections()
4261 warnings += validate_unwind_hints(file, sec); in validate_noinstr_sections()
4269 struct section *sec; in validate_functions() local
4272 for_each_sec(file, sec) { in validate_functions()
4273 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
4276 warnings += validate_section(file, sec); in validate_functions()
4290 struct symbol *sym = find_symbol_containing(insn->sec, insn->offset-1); in noendbr_range()
4296 first = find_insn(file, sym->sec, sym->offset); in noendbr_range()
4347 WARN_INSN(insn, "relocation to !ENDBR: %s", offstr(dest->sec, dest->offset)); in __validate_ibt_insn()
4380 dest = find_insn(file, insn->sec, off); in validate_ibt_insn()
4396 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in validate_ibt_insn()
4407 dest = find_insn(file, reloc->sym->sec, off); in validate_ibt_insn()
4422 dest = find_insn(file, reloc->sym->sec, in validate_ibt_data_reloc()
4435 WARN_FUNC(reloc->sec->base, reloc_offset(reloc), in validate_ibt_data_reloc()
4436 "data relocation to !ENDBR: %s", offstr(dest->sec, dest->offset)); in validate_ibt_data_reloc()
4448 struct section *sec; in validate_ibt() local
4456 for_each_sec(file, sec) { in validate_ibt()
4459 if (sec->sh.sh_flags & SHF_EXECINSTR) in validate_ibt()
4462 if (!sec->rsec) in validate_ibt()
4469 if ((!strncmp(sec->name, ".discard", 8) && in validate_ibt()
4470 strcmp(sec->name, ".discard.ibt_endbr_noseal")) || in validate_ibt()
4471 !strncmp(sec->name, ".debug", 6) || in validate_ibt()
4472 !strcmp(sec->name, ".altinstructions") || in validate_ibt()
4473 !strcmp(sec->name, ".ibt_endbr_seal") || in validate_ibt()
4474 !strcmp(sec->name, ".orc_unwind_ip") || in validate_ibt()
4475 !strcmp(sec->name, ".parainstructions") || in validate_ibt()
4476 !strcmp(sec->name, ".retpoline_sites") || in validate_ibt()
4477 !strcmp(sec->name, ".smp_locks") || in validate_ibt()
4478 !strcmp(sec->name, ".static_call_sites") || in validate_ibt()
4479 !strcmp(sec->name, "_error_injection_whitelist") || in validate_ibt()
4480 !strcmp(sec->name, "_kprobe_blacklist") || in validate_ibt()
4481 !strcmp(sec->name, "__bug_table") || in validate_ibt()
4482 !strcmp(sec->name, "__ex_table") || in validate_ibt()
4483 !strcmp(sec->name, "__jump_table") || in validate_ibt()
4484 !strcmp(sec->name, "__mcount_loc") || in validate_ibt()
4485 !strcmp(sec->name, ".kcfi_traps") || in validate_ibt()
4486 !strcmp(sec->name, ".llvm.call-graph-profile") || in validate_ibt()
4487 !strcmp(sec->name, ".llvm_bb_addr_map") || in validate_ibt()
4488 !strcmp(sec->name, "__tracepoints") || in validate_ibt()
4489 strstr(sec->name, "__patchable_function_entries")) in validate_ibt()
4492 for_each_reloc(sec->rsec, reloc) in validate_ibt()