scripts/mod/modpost.h

Source file repositories/reference/linux-study-clean/scripts/mod/modpost.h

File Facts

System
Linux kernel
Corpus path
scripts/mod/modpost.h
Extension
.h
Size
6818 bytes
Lines
245
Domain
Support Tooling And Documentation
Bucket
scripts
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct buffer {
	char *p;
	int pos;
	int size;
};

void __attribute__((format(printf, 2, 3)))
buf_printf(struct buffer *buf, const char *fmt, ...);

void
buf_write(struct buffer *buf, const char *s, int len);

/**
 * struct module_alias - auto-generated MODULE_ALIAS()
 *
 * @node: linked to module::aliases
 * @modname: name of the builtin module (only for vmlinux)
 * @str: a string for MODULE_ALIAS()
 */
struct module_alias {
	struct list_head node;
	char *builtin_modname;
	char str[];
};

/**
 * struct module - represent a module (vmlinux or *.ko)
 *
 * @dump_file: path to the .symvers file if loaded from a file
 * @aliases: list head for module_aliases
 * @no_trim_symbol: .no_trim_symbol section data
 * @no_trim_symbol_len: length of the .no_trim_symbol section
 */
struct module {
	struct list_head list;
	struct list_head exported_symbols;
	struct list_head unresolved_symbols;
	const char *dump_file;
	bool is_gpl_compatible;
	bool is_vmlinux;
	bool seen;
	bool has_init;
	bool has_cleanup;
	char	     srcversion[25];
	// Missing namespace dependencies
	struct list_head missing_namespaces;
	// Actual imported namespaces
	struct list_head imported_namespaces;
	struct list_head aliases;
	char *no_trim_symbol;
	unsigned int no_trim_symbol_len;
	char name[];
};

struct elf_info {
	size_t size;
	Elf_Ehdr     *hdr;
	Elf_Shdr     *sechdrs;
	Elf_Sym      *symtab_start;
	Elf_Sym      *symtab_stop;
	unsigned int export_symbol_secndx;	/* .export_symbol section */
	char         *strtab;
	char	     *modinfo;
	unsigned int modinfo_len;
	char         *no_trim_symbol;
	unsigned int no_trim_symbol_len;

	/* support for 32bit section numbers */

	unsigned int num_sections; /* max_secindex + 1 */
	unsigned int secindex_strings;
	/* if Nth symbol table entry has .st_shndx = SHN_XINDEX,
	 * take shndx from symtab_shndx_start[N] instead */
	Elf32_Word   *symtab_shndx_start;
	Elf32_Word   *symtab_shndx_stop;

	struct symsearch *symsearch;
};

/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
static inline unsigned int get_secindex(const struct elf_info *info,
					const Elf_Sym *sym)
{
	unsigned int index = sym->st_shndx;

	/*
	 * Elf{32,64}_Sym::st_shndx is 2 byte. Big section numbers are available
	 * in the .symtab_shndx section.
	 */
	if (index == SHN_XINDEX)

Annotation

Implementation Notes