include/linux/kallsyms.h
Source file repositories/reference/linux-study-clean/include/linux/kallsyms.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/kallsyms.h- Extension
.h- Size
- 4342 bytes
- Lines
- 175
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/buildid.hlinux/kernel.hlinux/stddef.hlinux/mm.hlinux/module.hasm/sections.h
Detected Declarations
struct credstruct modulefunction is_kernel_textfunction is_kernelfunction is_ksym_addrfunction kallsyms_lookup_namefunction kallsyms_lookup_size_offsetfunction sprint_symbolfunction sprint_symbol_build_idfunction sprint_symbol_no_offsetfunction sprint_backtracefunction sprint_backtrace_build_idfunction lookup_symbol_namefunction kallsyms_on_each_symbolfunction kallsyms_on_each_match_symbolfunction print_ip_sym
Annotated Snippet
#ifndef _LINUX_KALLSYMS_H
#define _LINUX_KALLSYMS_H
#include <linux/errno.h>
#include <linux/buildid.h>
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <asm/sections.h>
#define KSYM_NAME_LEN 512
#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s %s]") + \
(KSYM_NAME_LEN - 1) + \
2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + \
(BUILD_ID_SIZE_MAX * 2) + 1)
struct cred;
struct module;
static inline int is_kernel_text(unsigned long addr)
{
if (__is_kernel_text(addr))
return 1;
return in_gate_area_no_mm(addr);
}
static inline int is_kernel(unsigned long addr)
{
if (__is_kernel(addr))
return 1;
return in_gate_area_no_mm(addr);
}
static inline int is_ksym_addr(unsigned long addr)
{
if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
return is_kernel(addr);
return is_kernel_text(addr) || is_kernel_inittext(addr);
}
static inline void *dereference_symbol_descriptor(void *ptr)
{
#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
struct module *mod;
ptr = dereference_kernel_function_descriptor(ptr);
if (is_ksym_addr((unsigned long)ptr))
return ptr;
guard(rcu)();
mod = __module_address((unsigned long)ptr);
if (mod)
ptr = dereference_module_function_descriptor(mod, ptr);
#endif
return ptr;
}
/* How and when do we show kallsyms values? */
extern bool kallsyms_show_value(const struct cred *cred);
#ifdef CONFIG_KALLSYMS
unsigned long kallsyms_sym_address(int idx);
int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long),
void *data);
int kallsyms_on_each_match_symbol(int (*fn)(void *, unsigned long),
const char *name, void *data);
/* Lookup the address for a symbol. Returns 0 if not found. */
unsigned long kallsyms_lookup_name(const char *name);
extern int kallsyms_lookup_size_offset(unsigned long addr,
unsigned long *symbolsize,
unsigned long *offset);
/* Lookup an address. modname is set to NULL if it's in the kernel. */
const char *kallsyms_lookup(unsigned long addr,
unsigned long *symbolsize,
unsigned long *offset,
char **modname, char *namebuf);
/* Look up a kernel symbol and return it in a text buffer. */
extern int sprint_symbol(char *buffer, unsigned long address);
extern int sprint_symbol_build_id(char *buffer, unsigned long address);
extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
extern int sprint_backtrace(char *buffer, unsigned long address);
extern int sprint_backtrace_build_id(char *buffer, unsigned long address);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/buildid.h`, `linux/kernel.h`, `linux/stddef.h`, `linux/mm.h`, `linux/module.h`, `asm/sections.h`.
- Detected declarations: `struct cred`, `struct module`, `function is_kernel_text`, `function is_kernel`, `function is_ksym_addr`, `function kallsyms_lookup_name`, `function kallsyms_lookup_size_offset`, `function sprint_symbol`, `function sprint_symbol_build_id`, `function sprint_symbol_no_offset`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
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.