⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module.c

📁 h内核
💻 C
字号:
#include <linux/module.h>#include <linux/spinlock.h>static LIST_HEAD(dbe_list);static DEFINE_SPINLOCK(dbe_lock);/* Given an address, look for it in the module exception tables. */const struct exception_table_entry *search_module_dbetables(unsigned long addr){	unsigned long flags;	const struct exception_table_entry *e = NULL;	struct mod_arch_specific *dbe;	spin_lock_irqsave(&dbe_lock, flags);	list_for_each_entry(dbe, &dbe_list, dbe_list) {		e = search_extable(dbe->dbe_start, dbe->dbe_end - 1, addr);		if (e)			break;	}	spin_unlock_irqrestore(&dbe_lock, flags);	/* Now, if we found one, we are running inside it now, hence           we cannot unload the module, hence no refcnt needed. */	return e;}/* Put in dbe list if neccessary. */int module_finalize(const Elf_Ehdr *hdr,		    const Elf_Shdr *sechdrs,		    struct module *me){	const Elf_Shdr *s;	char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;	INIT_LIST_HEAD(&me->arch.dbe_list);	for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {		if (strcmp("__dbe_table", secstrings + s->sh_name) != 0)			continue;		me->arch.dbe_start = (void *)s->sh_addr;		me->arch.dbe_end = (void *)s->sh_addr + s->sh_size;		spin_lock_irq(&dbe_lock);		list_add(&me->arch.dbe_list, &dbe_list);		spin_unlock_irq(&dbe_lock);	}	return 0;}void module_arch_cleanup(struct module *mod){	spin_lock_irq(&dbe_lock);	list_del(&mod->arch.dbe_list);	spin_unlock_irq(&dbe_lock);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -