/* Allocate and load the module: note that size of section 0 is always
zero, and we rely on this for optional sections. */
static struct module *load_module(void __user *umod,
unsigned long len,
const char __user *uargs)
{
struct load_info info = { NULL, };
struct module *mod;
long err;
……
/* Copy in the blobs from userspace, check they are vaguely sane. */
err = copy_and_check(&info, umod, len, uargs);//拷贝到内核
if (err)
return ERR_PTR(err);
/* Figure out module layout, and allocate all the memory. */
mod = layout_and_allocate(&info);//地址空间分配
if (IS_ERR(mod)) {
err = PTR_ERR(mod);
goto free_copy;
}
……
/* Fix up syms, so that st_value is a pointer to location. */
err = simplify_symbols(mod, &info);//符号解析
if (err < 0)
goto free_modinfo;
err = apply_relocations(mod, &info);//重定位
if (err < 0)
goto free_modinfo;
……