Move relocs, symbols, sections into a new struct ksplice_code.
[ksplice.git] / kmodsrc / primary.c
blob5e9bcbdbf5781dc29ceb270c2ebb03f7dd83b4dd
1 /* Copyright (C) 2007-2009 Ksplice, Inc.
2 * Authors: Jeff Arnold, Anders Kaseorg, Tim Abbott
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
15 * 02110-1301, USA.
18 #ifdef KSPLICE_STANDALONE
19 #include "ksplice.h"
20 #else
21 #include <linux/ksplice.h>
22 #endif
24 extern struct ksplice_reloc ksplice_relocs[], ksplice_relocs_end[];
25 extern struct ksplice_section ksplice_sections[], ksplice_sections_end[];
26 extern struct ksplice_symbol ksplice_symbols[], ksplice_symbols_end[];
27 extern struct ksplice_patch ksplice_patches[], ksplice_patches_end[];
28 extern const typeof(int (*)(void)) ksplice_call_pre_apply[],
29 ksplice_call_pre_apply_end[], ksplice_call_check_apply[],
30 ksplice_call_check_apply_end[];
31 extern const typeof(void (*)(void)) ksplice_call_apply[],
32 ksplice_call_apply_end[], ksplice_call_post_apply[],
33 ksplice_call_post_apply_end[], ksplice_call_fail_apply[],
34 ksplice_call_fail_apply_end[];
35 extern const typeof(int (*)(void)) ksplice_call_pre_reverse[],
36 ksplice_call_pre_reverse_end[], ksplice_call_check_reverse[],
37 ksplice_call_check_reverse_end[];
38 extern const typeof(void (*)(void)) ksplice_call_reverse[],
39 ksplice_call_reverse_end[], ksplice_call_post_reverse[],
40 ksplice_call_post_reverse_end[], ksplice_call_fail_reverse[],
41 ksplice_call_fail_reverse_end[];
43 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
44 extern struct paravirt_patch_site parainstructions[], parainstructions_end[];
45 #endif
46 #ifdef KSPLICE_STANDALONE
47 extern struct ksplice_system_map ksplice_system_map[],
48 ksplice_system_map_end[];
49 #endif /* KSPLICE_STANDALONE */
51 #define change KSPLICE_UNIQ(change)
52 struct ksplice_mod_change change = {
53 .name = "ksplice_" __stringify(KSPLICE_MID),
54 .kid = __stringify(KSPLICE_KID),
55 .target_name = __stringify(KSPLICE_TARGET),
56 #ifdef KSPLICE_STANDALONE
57 .map_printk = MAP_PRINTK,
58 #endif /* KSPLICE_STANDALONE */
59 .primary = THIS_MODULE,
60 .new_code = {
61 .relocs = ksplice_relocs,
62 .relocs_end = ksplice_relocs_end,
63 .sections = ksplice_sections,
64 .sections_end = ksplice_sections_end,
65 .symbols = ksplice_symbols,
66 .symbols_end = ksplice_symbols_end,
67 #ifdef KSPLICE_NEED_PARAINSTRUCTIONS
68 .parainstructions = parainstructions,
69 .parainstructions_end = parainstructions_end,
70 #endif
71 #ifdef KSPLICE_STANDALONE
72 .system_map = ksplice_system_map,
73 .system_map_end = ksplice_system_map_end,
74 #endif /* KSPLICE_STANDALONE */
76 .patches = ksplice_patches,
77 .patches_end = ksplice_patches_end,
78 .pre_apply = ksplice_call_pre_apply,
79 .pre_apply_end = ksplice_call_pre_apply_end,
80 .check_apply = ksplice_call_check_apply,
81 .check_apply_end = ksplice_call_check_apply_end,
82 .apply = ksplice_call_apply,
83 .apply_end = ksplice_call_apply_end,
84 .post_apply = ksplice_call_post_apply,
85 .post_apply_end = ksplice_call_post_apply_end,
86 .fail_apply = ksplice_call_fail_apply,
87 .fail_apply_end = ksplice_call_fail_apply_end,
88 .pre_reverse = ksplice_call_pre_reverse,
89 .pre_reverse_end = ksplice_call_pre_reverse_end,
90 .check_reverse = ksplice_call_check_reverse,
91 .check_reverse_end = ksplice_call_check_reverse_end,
92 .reverse = ksplice_call_reverse,
93 .reverse_end = ksplice_call_reverse_end,
94 .post_reverse = ksplice_call_post_reverse,
95 .post_reverse_end = ksplice_call_post_reverse_end,
96 .fail_reverse = ksplice_call_fail_reverse,
97 .fail_reverse_end = ksplice_call_fail_reverse_end,
99 EXPORT_SYMBOL_GPL(change);
101 static int init_primary(void)
103 return 0;
106 static void cleanup_primary(void)
108 cleanup_ksplice_mod_change(&change);
111 module_init(init_primary);
112 module_exit(cleanup_primary);
114 MODULE_AUTHOR("Ksplice, Inc.");
115 MODULE_DESCRIPTION("Ksplice rebootless update primary module");
116 #ifdef KSPLICE_VERSION
117 MODULE_VERSION(KSPLICE_VERSION);
118 #endif
119 MODULE_LICENSE("GPL v2");