diff options
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 1 | ||||
-rw-r--r-- | kernel/module.c | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 83e2c31e8b00..bc2121fa9132 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -473,6 +473,7 @@ | |||
473 | #define KERNEL_CTORS() . = ALIGN(8); \ | 473 | #define KERNEL_CTORS() . = ALIGN(8); \ |
474 | VMLINUX_SYMBOL(__ctors_start) = .; \ | 474 | VMLINUX_SYMBOL(__ctors_start) = .; \ |
475 | *(.ctors) \ | 475 | *(.ctors) \ |
476 | *(.init_array) \ | ||
476 | VMLINUX_SYMBOL(__ctors_end) = .; | 477 | VMLINUX_SYMBOL(__ctors_end) = .; |
477 | #else | 478 | #else |
478 | #define KERNEL_CTORS() | 479 | #define KERNEL_CTORS() |
diff --git a/kernel/module.c b/kernel/module.c index 947105fd4cab..5c9cf84017d5 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2708,7 +2708,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags) | |||
2708 | return 0; | 2708 | return 0; |
2709 | } | 2709 | } |
2710 | 2710 | ||
2711 | static void find_module_sections(struct module *mod, struct load_info *info) | 2711 | static int find_module_sections(struct module *mod, struct load_info *info) |
2712 | { | 2712 | { |
2713 | mod->kp = section_objs(info, "__param", | 2713 | mod->kp = section_objs(info, "__param", |
2714 | sizeof(*mod->kp), &mod->num_kp); | 2714 | sizeof(*mod->kp), &mod->num_kp); |
@@ -2738,6 +2738,18 @@ static void find_module_sections(struct module *mod, struct load_info *info) | |||
2738 | #ifdef CONFIG_CONSTRUCTORS | 2738 | #ifdef CONFIG_CONSTRUCTORS |
2739 | mod->ctors = section_objs(info, ".ctors", | 2739 | mod->ctors = section_objs(info, ".ctors", |
2740 | sizeof(*mod->ctors), &mod->num_ctors); | 2740 | sizeof(*mod->ctors), &mod->num_ctors); |
2741 | if (!mod->ctors) | ||
2742 | mod->ctors = section_objs(info, ".init_array", | ||
2743 | sizeof(*mod->ctors), &mod->num_ctors); | ||
2744 | else if (find_sec(info, ".init_array")) { | ||
2745 | /* | ||
2746 | * This shouldn't happen with same compiler and binutils | ||
2747 | * building all parts of the module. | ||
2748 | */ | ||
2749 | printk(KERN_WARNING "%s: has both .ctors and .init_array.\n", | ||
2750 | mod->name); | ||
2751 | return -EINVAL; | ||
2752 | } | ||
2741 | #endif | 2753 | #endif |
2742 | 2754 | ||
2743 | #ifdef CONFIG_TRACEPOINTS | 2755 | #ifdef CONFIG_TRACEPOINTS |
@@ -2776,6 +2788,8 @@ static void find_module_sections(struct module *mod, struct load_info *info) | |||
2776 | 2788 | ||
2777 | info->debug = section_objs(info, "__verbose", | 2789 | info->debug = section_objs(info, "__verbose", |
2778 | sizeof(*info->debug), &info->num_debug); | 2790 | sizeof(*info->debug), &info->num_debug); |
2791 | |||
2792 | return 0; | ||
2779 | } | 2793 | } |
2780 | 2794 | ||
2781 | static int move_module(struct module *mod, struct load_info *info) | 2795 | static int move_module(struct module *mod, struct load_info *info) |
@@ -3233,7 +3247,9 @@ static int load_module(struct load_info *info, const char __user *uargs, | |||
3233 | 3247 | ||
3234 | /* Now we've got everything in the final locations, we can | 3248 | /* Now we've got everything in the final locations, we can |
3235 | * find optional sections. */ | 3249 | * find optional sections. */ |
3236 | find_module_sections(mod, info); | 3250 | err = find_module_sections(mod, info); |
3251 | if (err) | ||
3252 | goto free_unload; | ||
3237 | 3253 | ||
3238 | err = check_module_license_and_versions(mod); | 3254 | err = check_module_license_and_versions(mod); |
3239 | if (err) | 3255 | if (err) |