Lines Matching full:sec
33 struct section *sec, unsigned long offset) in find_insn() argument
37 hash_for_each_possible(file->insn_hash, insn, hash, sec_offset_hash(sec, offset)) { in find_insn()
38 if (insn->sec == sec && insn->offset == offset) in find_insn()
50 if (!next || &next->list == &file->insn_list || next->sec != insn->sec) in next_insn_same_sec()
73 return find_insn(file, func->cfunc->sec, func->cfunc->offset); in next_insn_same_func()
88 for (insn = find_insn(file, func->sec, func->offset); \
93 for (insn = find_insn(file, sym->sec, sym->offset); \
95 insn->sec == sym->sec && \
102 insn->sec == sym->sec && insn->offset >= sym->offset; \
175 insn = find_insn(file, func->sec, func->offset); in __dead_end_function()
237 static void init_insn_state(struct insn_state *state, struct section *sec) in init_insn_state() argument
244 * not correctly determine insn->call_dest->sec (external symbols do in init_insn_state()
247 if (vmlinux && sec) in init_insn_state()
248 state->noinstr = sec->noinstr; in init_insn_state()
257 struct section *sec; in decode_instructions() local
264 for_each_sec(file, sec) { in decode_instructions()
266 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in decode_instructions()
269 if (strcmp(sec->name, ".altinstr_replacement") && in decode_instructions()
270 strcmp(sec->name, ".altinstr_aux") && in decode_instructions()
271 strncmp(sec->name, ".discard.", 9)) in decode_instructions()
272 sec->text = true; in decode_instructions()
274 if (!strcmp(sec->name, ".noinstr.text") || in decode_instructions()
275 !strcmp(sec->name, ".entry.text")) in decode_instructions()
276 sec->noinstr = true; in decode_instructions()
278 for (offset = 0; offset < sec->len; offset += insn->len) { in decode_instructions()
289 insn->sec = sec; in decode_instructions()
292 ret = arch_decode_instruction(file->elf, sec, offset, in decode_instructions()
293 sec->len - offset, in decode_instructions()
300 hash_add(file->insn_hash, &insn->hash, sec_offset_hash(sec, insn->offset)); in decode_instructions()
305 list_for_each_entry(func, &sec->symbol_list, list) { in decode_instructions()
309 if (!find_insn(file, sec, func->offset)) { in decode_instructions()
331 struct section *sec) in find_last_insn() argument
335 unsigned int end = (sec->len > 10) ? sec->len - 10 : 0; in find_last_insn()
337 for (offset = sec->len - 1; offset >= end && !insn; offset--) in find_last_insn()
338 insn = find_insn(file, sec, offset); in find_last_insn()
348 struct section *sec; in add_dead_ends() local
363 sec = find_section_by_name(file->elf, ".rela.discard.unreachable"); in add_dead_ends()
364 if (!sec) in add_dead_ends()
367 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
369 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
372 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
375 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
376 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
379 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
384 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
398 sec = find_section_by_name(file->elf, ".rela.discard.reachable"); in add_dead_ends()
399 if (!sec) in add_dead_ends()
402 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_dead_ends()
404 WARN("unexpected relocation symbol type in %s", sec->name); in add_dead_ends()
407 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_dead_ends()
410 else if (reloc->addend == reloc->sym->sec->len) { in add_dead_ends()
411 insn = find_last_insn(file, reloc->sym->sec); in add_dead_ends()
414 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
419 reloc->sym->sec->name, reloc->addend); in add_dead_ends()
431 struct section *sec, *reloc_sec; in create_static_call_sections() local
439 sec = find_section_by_name(file->elf, ".static_call_sites"); in create_static_call_sections()
440 if (sec) { in create_static_call_sections()
453 sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, in create_static_call_sections()
455 if (!sec) in create_static_call_sections()
458 reloc_sec = elf_create_reloc_section(file->elf, sec, SHT_RELA); in create_static_call_sections()
465 site = (struct static_call_site *)sec->data->d_buf + idx; in create_static_call_sections()
475 reloc->sym = insn->sec->sym; in create_static_call_sections()
479 reloc->sec = reloc_sec; in create_static_call_sections()
514 reloc->sec = reloc_sec; in create_static_call_sections()
532 struct section *sec; in add_ignores() local
536 sec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard"); in add_ignores()
537 if (!sec) in add_ignores()
540 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignores()
547 func = find_func_by_offset(reloc->sym->sec, reloc->addend); in add_ignores()
553 WARN("unexpected relocation symbol type in %s: %d", sec->name, reloc->sym->type); in add_ignores()
730 struct section *sec; in add_ignore_alternatives() local
734 sec = find_section_by_name(file->elf, ".rela.discard.ignore_alts"); in add_ignore_alternatives()
735 if (!sec) in add_ignore_alternatives()
738 list_for_each_entry(reloc, &sec->reloc_list, list) { in add_ignore_alternatives()
740 WARN("unexpected relocation symbol type in %s", sec->name); in add_ignore_alternatives()
744 insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_ignore_alternatives()
773 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in add_jump_destinations()
776 dest_sec = insn->sec; in add_jump_destinations()
779 dest_sec = reloc->sym->sec; in add_jump_destinations()
781 } else if (reloc->sym->sec->idx) { in add_jump_destinations()
782 dest_sec = reloc->sym->sec; in add_jump_destinations()
815 if (!strcmp(insn->sec->name, ".altinstr_replacement")) in add_jump_destinations()
819 insn->sec, insn->offset, dest_sec->name, in add_jump_destinations()
876 static struct symbol *find_call_destination(struct section *sec, unsigned long offset) in find_call_destination() argument
880 call_dest = find_func_by_offset(sec, offset); in find_call_destination()
882 call_dest = find_symbol_by_offset(sec, offset); in find_call_destination()
900 reloc = find_reloc_by_dest_range(file->elf, insn->sec, in add_call_destinations()
904 insn->call_dest = find_call_destination(insn->sec, dest_off); in add_call_destinations()
910 WARN_FUNC("unannotated intra-function call", insn->sec, insn->offset); in add_call_destinations()
916 insn->sec, insn->offset); in add_call_destinations()
922 insn->call_dest = find_call_destination(reloc->sym->sec, in add_call_destinations()
926 insn->sec, insn->offset, in add_call_destinations()
927 reloc->sym->sec->name, in add_call_destinations()
939 if (insn->sec->noinstr && in add_call_destinations()
946 elf_write_insn(file->elf, insn->sec, in add_call_destinations()
1013 fake_jump->sec = special_alt->new_sec; in handle_group_alt()
1054 alt_reloc = find_reloc_by_dest_range(file->elf, insn->sec, in handle_group_alt()
1060 insn->sec, insn->offset); in handle_group_alt()
1082 insn->sec, insn->offset); in handle_group_alt()
1114 orig_insn->sec, orig_insn->offset); in handle_jump_alt()
1167 orig_insn->sec, orig_insn->offset); in add_special_section_alts()
1215 list_for_each_entry_from(reloc, &table->sec->reloc_list, list) { in add_jump_table()
1226 if (reloc->sym->sec == pfunc->sec && in add_jump_table()
1230 dest_insn = find_insn(file, reloc->sym->sec, reloc->addend); in add_jump_table()
1251 insn->sec, insn->offset); in add_jump_table()
1291 dest_insn = find_insn(file, table_reloc->sym->sec, table_reloc->addend); in find_jump_table()
1365 struct section *sec; in add_jump_table_alts() local
1372 for_each_sec(file, sec) { in add_jump_table_alts()
1373 list_for_each_entry(func, &sec->symbol_list, list) { in add_jump_table_alts()
1389 struct section *sec, *relocsec; in read_unwind_hints() local
1396 sec = find_section_by_name(file->elf, ".discard.unwind_hints"); in read_unwind_hints()
1397 if (!sec) in read_unwind_hints()
1400 relocsec = sec->reloc; in read_unwind_hints()
1406 if (sec->len % sizeof(struct unwind_hint)) { in read_unwind_hints()
1413 for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { in read_unwind_hints()
1414 hint = (struct unwind_hint *)sec->data->d_buf + i; in read_unwind_hints()
1416 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint)); in read_unwind_hints()
1422 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_unwind_hints()
1439 insn->sec, insn->offset, hint->sp_reg); in read_unwind_hints()
1453 struct section *sec; in read_retpoline_hints() local
1457 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe"); in read_retpoline_hints()
1458 if (!sec) in read_retpoline_hints()
1461 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_retpoline_hints()
1463 WARN("unexpected relocation symbol type in %s", sec->name); in read_retpoline_hints()
1467 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_retpoline_hints()
1476 insn->sec, insn->offset); in read_retpoline_hints()
1488 struct section *sec; in read_instr_hints() local
1492 sec = find_section_by_name(file->elf, ".rela.discard.instr_end"); in read_instr_hints()
1493 if (!sec) in read_instr_hints()
1496 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1498 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1502 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1511 sec = find_section_by_name(file->elf, ".rela.discard.instr_begin"); in read_instr_hints()
1512 if (!sec) in read_instr_hints()
1515 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_instr_hints()
1517 WARN("unexpected relocation symbol type in %s", sec->name); in read_instr_hints()
1521 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_instr_hints()
1536 struct section *sec; in read_intra_function_calls() local
1539 sec = find_section_by_name(file->elf, ".rela.discard.intra_function_calls"); in read_intra_function_calls()
1540 if (!sec) in read_intra_function_calls()
1543 list_for_each_entry(reloc, &sec->reloc_list, list) { in read_intra_function_calls()
1548 sec->name); in read_intra_function_calls()
1552 insn = find_insn(file, reloc->sym->sec, reloc->addend); in read_intra_function_calls()
1560 insn->sec, insn->offset); in read_intra_function_calls()
1572 insn->jump_dest = find_insn(file, insn->sec, dest_off); in read_intra_function_calls()
1575 insn->sec, insn->offset, in read_intra_function_calls()
1576 insn->sec->name, dest_off); in read_intra_function_calls()
1586 struct section *sec; in read_static_call_tramps() local
1589 for_each_sec(file, sec) { in read_static_call_tramps()
1590 list_for_each_entry(func, &sec->symbol_list, list) { in read_static_call_tramps()
1603 struct section *sec; in mark_rodata() local
1616 for_each_sec(file, sec) { in mark_rodata()
1617 if (!strncmp(sec->name, ".rodata", 7) && in mark_rodata()
1618 !strstr(sec->name, ".str1.")) { in mark_rodata()
1619 sec->rodata = true; in mark_rodata()
1845 WARN_FUNC("undefined stack state", insn->sec, insn->offset); in update_cfi_state()
1984 insn->sec, insn->offset); in update_cfi_state()
1995 insn->sec, insn->offset); in update_cfi_state()
2070 insn->sec, insn->offset); in update_cfi_state()
2149 insn->sec, insn->offset); in update_cfi_state()
2168 insn->sec, insn->offset); in update_cfi_state()
2181 insn->sec, insn->offset); in update_cfi_state()
2201 WARN_FUNC("alternative modifies stack", insn->sec, insn->offset); in handle_insn_ops()
2210 insn->sec, insn->offset); in handle_insn_ops()
2238 insn->sec, insn->offset, in insn_cfi_match()
2249 insn->sec, insn->offset, in insn_cfi_match()
2258 insn->sec, insn->offset, cfi1->type, cfi2->type); in insn_cfi_match()
2265 insn->sec, insn->offset, in insn_cfi_match()
2303 if (func->sec->noinstr) in noinstr_call_dest()
2322 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2328 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2334 insn->sec, insn->offset, call_dest_name(insn)); in validate_call()
2345 insn->sec, insn->offset); in validate_sibling_call()
2356 insn->sec, insn->offset); in validate_return()
2362 insn->sec, insn->offset); in validate_return()
2368 insn->sec, insn->offset); in validate_return()
2374 insn->sec, insn->offset); in validate_return()
2380 insn->sec, insn->offset); in validate_return()
2386 insn->sec, insn->offset); in validate_return()
2428 struct section *sec; in validate_branch() local
2432 sec = insn->sec; in validate_branch()
2445 sec, insn->offset); in validate_branch()
2507 sec, insn->offset); in validate_branch()
2559 sec, insn->offset); in validate_branch()
2566 WARN_FUNC("recursive UACCESS enable", sec, insn->offset); in validate_branch()
2575 WARN_FUNC("redundant UACCESS disable", sec, insn->offset); in validate_branch()
2580 WARN_FUNC("UACCESS-safe disables UACCESS", sec, insn->offset); in validate_branch()
2589 WARN_FUNC("recursive STD", sec, insn->offset); in validate_branch()
2596 WARN_FUNC("redundant CLD", sec, insn->offset); in validate_branch()
2611 WARN("%s: unexpected end of section", sec->name); in validate_branch()
2621 static int validate_unwind_hints(struct objtool_file *file, struct section *sec) in validate_unwind_hints() argument
2630 init_insn_state(&state, sec); in validate_unwind_hints()
2632 if (sec) { in validate_unwind_hints()
2633 insn = find_insn(file, sec, 0); in validate_unwind_hints()
2640 while (&insn->list != &file->insn_list && (!sec || insn->sec == sec)) { in validate_unwind_hints()
2673 if (!strcmp(insn->sec->name, ".init.text") && !module) in validate_retpoline()
2677 insn->sec, insn->offset, in validate_retpoline()
2714 if (!strcmp(insn->sec->name, ".fixup") || in ignore_unreachable_insn()
2715 !strcmp(insn->sec->name, ".altinstr_replacement") || in ignore_unreachable_insn()
2716 !strcmp(insn->sec->name, ".altinstr_aux")) in ignore_unreachable_insn()
2770 static int validate_symbol(struct objtool_file *file, struct section *sec, in validate_symbol() argument
2784 insn = find_insn(file, sec, sym->offset); in validate_symbol()
2796 static int validate_section(struct objtool_file *file, struct section *sec) in validate_section() argument
2802 list_for_each_entry(func, &sec->symbol_list, list) { in validate_section()
2806 init_insn_state(&state, sec); in validate_section()
2812 warnings += validate_symbol(file, sec, func, &state); in validate_section()
2820 struct section *sec; in validate_vmlinux_functions() local
2823 sec = find_section_by_name(file->elf, ".noinstr.text"); in validate_vmlinux_functions()
2824 if (sec) { in validate_vmlinux_functions()
2825 warnings += validate_section(file, sec); in validate_vmlinux_functions()
2826 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
2829 sec = find_section_by_name(file->elf, ".entry.text"); in validate_vmlinux_functions()
2830 if (sec) { in validate_vmlinux_functions()
2831 warnings += validate_section(file, sec); in validate_vmlinux_functions()
2832 warnings += validate_unwind_hints(file, sec); in validate_vmlinux_functions()
2840 struct section *sec; in validate_functions() local
2843 for_each_sec(file, sec) { in validate_functions()
2844 if (!(sec->sh.sh_flags & SHF_EXECINSTR)) in validate_functions()
2847 warnings += validate_section(file, sec); in validate_functions()
2864 WARN_FUNC("unreachable instruction", insn->sec, insn->offset); in validate_reachable_instructions()