tools/objtool/check.c
Source file repositories/reference/linux-study-clean/tools/objtool/check.c
File Facts
- System
- Linux kernel
- Corpus path
tools/objtool/check.c- Extension
.c- Size
- 116266 bytes
- Lines
- 4971
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fnmatch.hstring.hstdlib.hinttypes.hsys/mman.hobjtool/builtin.hobjtool/cfi.hobjtool/arch.hobjtool/disas.hobjtool/check.hobjtool/special.hobjtool/trace.hobjtool/warn.hobjtool/util.hlinux/objtool_types.hlinux/hashtable.hlinux/kernel.hlinux/static_call_types.hlinux/string.hnoreturns.h
Detected Declarations
struct insn_chunkfunction hash_for_each_possiblefunction insn_jump_table_sizefunction is_jump_table_jumpfunction is_sibling_callfunction is_rust_noreturnfunction __dead_end_functionfunction func_for_each_insnfunction dead_end_functionfunction init_cfi_statefunction init_insn_statefunction cficmpfunction cfi_keyfunction hlist_for_each_entryfunction cfi_hash_addfunction decode_instructionsfunction for_each_secfunction sec_for_each_symfunction sym_for_each_insnfunction pv_ops_idx_offfunction add_pv_opsfunction init_pv_opsfunction is_livepatch_modulefunction create_static_call_sectionsfunction create_retpoline_sites_sectionsfunction create_return_sites_sectionsfunction create_ibt_endbr_seal_sectionsfunction grow_cfi_symbolsfunction for_each_symfunction create_cfi_sectionsfunction create_mcount_loc_sectionsfunction create_direct_call_sectionsfunction add_ignoresfunction for_each_relocfunction add_uaccess_safefunction arch_is_retpolinefunction arch_is_rethunkfunction arch_is_embedded_insnfunction remove_insn_opsfunction annotate_call_sitefunction add_call_destfunction add_retpoline_callfunction add_return_callfunction is_first_func_insnfunction add_jump_destinationsfunction for_each_insnfunction retbleed_untrain_retfunction add_call_destinations
Annotated Snippet
ERROR("%s(): Magic init_module() function name is deprecated, use module_init(fn) instead",
func->name);
return -1;
}
if (!elf_init_reloc_text_sym(file->elf, sec,
idx * sizeof(int), idx,
insn->sec, insn->offset))
return -1;
idx++;
}
return 0;
}
/*
* Grow __cfi_ symbols to fill the NOP gap between the 'mov <hash>, %rax' and
* the start of the function.
*/
static int grow_cfi_symbols(struct objtool_file *file)
{
struct symbol *sym;
for_each_sym(file->elf, sym) {
if (!is_func_sym(sym) || !strstarts(sym->name, "__cfi_") ||
sym->len != 5)
continue;
if (!find_func_by_offset(sym->sec, sym->offset + sym->len + opts.prefix))
continue;
sym->len += opts.prefix;
sym->sym.st_size = sym->len;
if (elf_write_symbol(file->elf, sym))
return -1;
}
return 0;
}
static int create_cfi_sections(struct objtool_file *file)
{
struct section *sec;
struct symbol *sym;
int idx;
sec = find_section_by_name(file->elf, ".cfi_sites");
if (sec) {
WARN("file already has .cfi_sites section, skipping");
return 0;
}
idx = 0;
for_each_sym(file->elf, sym) {
if (!is_func_sym(sym))
continue;
if (strncmp(sym->name, "__cfi_", 6))
continue;
idx++;
}
sec = elf_create_section_pair(file->elf, ".cfi_sites",
sizeof(unsigned int), idx, idx);
if (!sec)
return -1;
idx = 0;
for_each_sym(file->elf, sym) {
if (!is_func_sym(sym))
continue;
if (strncmp(sym->name, "__cfi_", 6))
continue;
if (!elf_init_reloc_text_sym(file->elf, sec,
idx * sizeof(unsigned int), idx,
sym->sec, sym->offset))
return -1;
idx++;
}
return 0;
}
static int create_mcount_loc_sections(struct objtool_file *file)
{
Annotation
- Immediate include surface: `fnmatch.h`, `string.h`, `stdlib.h`, `inttypes.h`, `sys/mman.h`, `objtool/builtin.h`, `objtool/cfi.h`, `objtool/arch.h`.
- Detected declarations: `struct insn_chunk`, `function hash_for_each_possible`, `function insn_jump_table_size`, `function is_jump_table_jump`, `function is_sibling_call`, `function is_rust_noreturn`, `function __dead_end_function`, `function func_for_each_insn`, `function dead_end_function`, `function init_cfi_state`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.