#ifndef _LINUX_MODULE_H
#define _LINUX_MODULE_H
#include <linux/list.h>
#include <linux/stat.h>
#include <linux/buildid.h>
#include <linux/compiler.h>
#include <linux/cache.h>
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/elf.h>
#include <linux/stringify.h>
#include <linux/kobject.h>
#include <linux/moduleparam.h>
#include <linux/jump_label.h>
#include <linux/export.h>
#include <linux/rbtree_latch.h>
#include <linux/error-injection.h>
#include <linux/tracepoint-defs.h>
#include <linux/srcu.h>
#include <linux/static_call_types.h>
#include <linux/dynamic_debug.h>
#include <linux/percpu.h>
#include <asm/module.h>
#define MODULE_NAME_LEN …
struct modversion_info { … };
struct module;
struct exception_table_entry;
struct module_kobject { … } __randomize_layout;
struct module_attribute { … };
struct module_version_attribute { … };
extern ssize_t __modver_version_show(struct module_attribute *,
struct module_kobject *, char *);
extern struct module_attribute module_uevent;
extern int init_module(void);
extern void cleanup_module(void);
#ifndef MODULE
#define module_init(x) …
#define module_exit(x) …
#else
#define early_initcall …
#define core_initcall …
#define core_initcall_sync …
#define postcore_initcall …
#define postcore_initcall_sync …
#define arch_initcall …
#define subsys_initcall …
#define subsys_initcall_sync …
#define fs_initcall …
#define fs_initcall_sync …
#define rootfs_initcall …
#define device_initcall …
#define device_initcall_sync …
#define late_initcall …
#define late_initcall_sync …
#define console_initcall …
#define module_init …
#define module_exit …
#endif
#ifdef CONFIG_MODULES
#define __init_or_module
#define __initdata_or_module
#define __initconst_or_module
#define __INIT_OR_MODULE …
#define __INITDATA_OR_MODULE …
#define __INITRODATA_OR_MODULE …
#else
#define __init_or_module …
#define __initdata_or_module …
#define __initconst_or_module …
#define __INIT_OR_MODULE …
#define __INITDATA_OR_MODULE …
#define __INITRODATA_OR_MODULE …
#endif
#define MODULE_INFO(tag, info) …
#define MODULE_ALIAS(_alias) …
#define MODULE_SOFTDEP(_softdep) …
#define MODULE_WEAKDEP(_weakdep) …
#ifdef MODULE
#define MODULE_FILE
#else
#define MODULE_FILE …
#endif
#define MODULE_LICENSE(_license) …
#define MODULE_AUTHOR(_author) …
#define MODULE_DESCRIPTION(_description) …
#ifdef MODULE
#define MODULE_DEVICE_TABLE …
#else
#define MODULE_DEVICE_TABLE(type, name) …
#endif
#if defined(MODULE) || !defined(CONFIG_SYSFS)
#define MODULE_VERSION …
#else
#define MODULE_VERSION(_version) …
#endif
#define MODULE_FIRMWARE(_firmware) …
#define MODULE_IMPORT_NS(ns) …
struct notifier_block;
#ifdef CONFIG_MODULES
extern int modules_disabled;
void *__symbol_get(const char *symbol);
void *__symbol_get_gpl(const char *symbol);
#define symbol_get(x) …
struct module_use { … };
enum module_state { … };
struct mod_tree_node { … };
enum mod_mem_type { … };
#define mod_mem_type_is_init(type) …
#define mod_mem_type_is_core(type) …
#define mod_mem_type_is_text(type) …
#define mod_mem_type_is_data(type) …
#define mod_mem_type_is_core_data(type) …
#define for_each_mod_mem_type(type) …
#define for_class_mod_mem_type(type, class) …
struct module_memory { … };
#ifdef CONFIG_MODULES_TREE_LOOKUP
#define __module_memory_align …
#else
#define __module_memory_align
#endif
struct mod_kallsyms { … };
#ifdef CONFIG_LIVEPATCH
struct klp_modinfo {
Elf_Ehdr hdr;
Elf_Shdr *sechdrs;
char *secstrings;
unsigned int symndx;
};
#endif
struct module { … } ____cacheline_aligned __randomize_layout;
#ifndef MODULE_ARCH_INIT
#define MODULE_ARCH_INIT …
#endif
#ifndef HAVE_ARCH_KALLSYMS_SYMBOL_VALUE
static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym)
{ … }
#endif
static inline bool module_is_live(struct module *mod)
{ … }
static inline bool module_is_coming(struct module *mod)
{ … }
struct module *__module_text_address(unsigned long addr);
struct module *__module_address(unsigned long addr);
bool is_module_address(unsigned long addr);
bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr);
bool is_module_percpu_address(unsigned long addr);
bool is_module_text_address(unsigned long addr);
static inline bool within_module_mem_type(unsigned long addr,
const struct module *mod,
enum mod_mem_type type)
{ … }
static inline bool within_module_core(unsigned long addr,
const struct module *mod)
{ … }
static inline bool within_module_init(unsigned long addr,
const struct module *mod)
{ … }
static inline bool within_module(unsigned long addr, const struct module *mod)
{ … }
struct module *find_module(const char *name);
extern void __noreturn __module_put_and_kthread_exit(struct module *mod,
long code);
#define module_put_and_kthread_exit(code) …
#ifdef CONFIG_MODULE_UNLOAD
int module_refcount(struct module *mod);
void __symbol_put(const char *symbol);
#define symbol_put(x) …
void symbol_put_addr(void *addr);
extern void __module_get(struct module *module);
extern bool try_module_get(struct module *module);
extern void module_put(struct module *module);
#else
static inline bool try_module_get(struct module *module)
{
return !module || module_is_live(module);
}
static inline void module_put(struct module *module)
{
}
static inline void __module_get(struct module *module)
{
}
#define symbol_put …
#define symbol_put_addr …
#endif
#define module_name(mod) …
void *dereference_module_function_descriptor(struct module *mod, void *ptr);
int register_module_notifier(struct notifier_block *nb);
int unregister_module_notifier(struct notifier_block *nb);
extern void print_modules(void);
static inline bool module_requested_async_probing(struct module *module)
{ … }
static inline bool is_livepatch_module(struct module *mod)
{ … }
void set_module_sig_enforced(void);
#else
static inline struct module *__module_address(unsigned long addr)
{
return NULL;
}
static inline struct module *__module_text_address(unsigned long addr)
{
return NULL;
}
static inline bool is_module_address(unsigned long addr)
{
return false;
}
static inline bool is_module_percpu_address(unsigned long addr)
{
return false;
}
static inline bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
{
return false;
}
static inline bool is_module_text_address(unsigned long addr)
{
return false;
}
static inline bool within_module_core(unsigned long addr,
const struct module *mod)
{
return false;
}
static inline bool within_module_init(unsigned long addr,
const struct module *mod)
{
return false;
}
static inline bool within_module(unsigned long addr, const struct module *mod)
{
return false;
}
#define symbol_get …
#define symbol_put …
#define symbol_put_addr …
static inline void __module_get(struct module *module)
{
}
static inline bool try_module_get(struct module *module)
{
return true;
}
static inline void module_put(struct module *module)
{
}
#define module_name …
static inline int register_module_notifier(struct notifier_block *nb)
{
return 0;
}
static inline int unregister_module_notifier(struct notifier_block *nb)
{
return 0;
}
#define module_put_and_kthread_exit …
static inline void print_modules(void)
{
}
static inline bool module_requested_async_probing(struct module *module)
{
return false;
}
static inline void set_module_sig_enforced(void)
{
}
static inline
void *dereference_module_function_descriptor(struct module *mod, void *ptr)
{
return ptr;
}
static inline bool module_is_coming(struct module *mod)
{
return false;
}
#endif
#ifdef CONFIG_SYSFS
extern struct kset *module_kset;
extern const struct kobj_type module_ktype;
#endif
#define symbol_request(x) …
#define __MODULE_STRING(x) …
#ifdef CONFIG_GENERIC_BUG
void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
struct module *);
void module_bug_cleanup(struct module *);
#else
static inline void module_bug_finalize(const Elf_Ehdr *hdr,
const Elf_Shdr *sechdrs,
struct module *mod)
{
}
static inline void module_bug_cleanup(struct module *mod) {}
#endif
#ifdef CONFIG_MITIGATION_RETPOLINE
extern bool retpoline_module_ok(bool has_retpoline);
#else
static inline bool retpoline_module_ok(bool has_retpoline)
{
return true;
}
#endif
#ifdef CONFIG_MODULE_SIG
bool is_module_sig_enforced(void);
static inline bool module_sig_ok(struct module *module)
{ … }
#else
static inline bool is_module_sig_enforced(void)
{
return false;
}
static inline bool module_sig_ok(struct module *module)
{
return true;
}
#endif
#if defined(CONFIG_MODULES) && defined(CONFIG_KALLSYMS)
int module_kallsyms_on_each_symbol(const char *modname,
int (*fn)(void *, const char *, unsigned long),
void *data);
int module_address_lookup(unsigned long addr,
unsigned long *symbolsize,
unsigned long *offset,
char **modname, const unsigned char **modbuildid,
char *namebuf);
int lookup_module_symbol_name(unsigned long addr, char *symname);
int lookup_module_symbol_attrs(unsigned long addr,
unsigned long *size,
unsigned long *offset,
char *modname,
char *name);
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
char *name, char *module_name, int *exported);
unsigned long module_kallsyms_lookup_name(const char *name);
unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name);
#else
static inline int module_kallsyms_on_each_symbol(const char *modname,
int (*fn)(void *, const char *, unsigned long),
void *data)
{
return -EOPNOTSUPP;
}
static inline int module_address_lookup(unsigned long addr,
unsigned long *symbolsize,
unsigned long *offset,
char **modname,
const unsigned char **modbuildid,
char *namebuf)
{
return 0;
}
static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
{
return -ERANGE;
}
static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
char *type, char *name,
char *module_name, int *exported)
{
return -ERANGE;
}
static inline unsigned long module_kallsyms_lookup_name(const char *name)
{
return 0;
}
static inline unsigned long find_kallsyms_symbol_value(struct module *mod,
const char *name)
{
return 0;
}
#endif
#endif