diff options
Diffstat (limited to 'include/linux/init.h')
-rw-r--r-- | include/linux/init.h | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/include/linux/init.h b/include/linux/init.h index bc27cf03c41e..2538d176dd1f 100644 --- a/include/linux/init.h +++ b/include/linux/init.h | |||
@@ -116,8 +116,24 @@ | |||
116 | typedef int (*initcall_t)(void); | 116 | typedef int (*initcall_t)(void); |
117 | typedef void (*exitcall_t)(void); | 117 | typedef void (*exitcall_t)(void); |
118 | 118 | ||
119 | extern initcall_t __con_initcall_start[], __con_initcall_end[]; | 119 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
120 | extern initcall_t __security_initcall_start[], __security_initcall_end[]; | 120 | typedef int initcall_entry_t; |
121 | |||
122 | static inline initcall_t initcall_from_entry(initcall_entry_t *entry) | ||
123 | { | ||
124 | return offset_to_ptr(entry); | ||
125 | } | ||
126 | #else | ||
127 | typedef initcall_t initcall_entry_t; | ||
128 | |||
129 | static inline initcall_t initcall_from_entry(initcall_entry_t *entry) | ||
130 | { | ||
131 | return *entry; | ||
132 | } | ||
133 | #endif | ||
134 | |||
135 | extern initcall_entry_t __con_initcall_start[], __con_initcall_end[]; | ||
136 | extern initcall_entry_t __security_initcall_start[], __security_initcall_end[]; | ||
121 | 137 | ||
122 | /* Used for contructor calls. */ | 138 | /* Used for contructor calls. */ |
123 | typedef void (*ctor_fn_t)(void); | 139 | typedef void (*ctor_fn_t)(void); |
@@ -167,9 +183,20 @@ extern bool initcall_debug; | |||
167 | * as KEEP() in the linker script. | 183 | * as KEEP() in the linker script. |
168 | */ | 184 | */ |
169 | 185 | ||
170 | #define __define_initcall(fn, id) \ | 186 | #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
187 | #define ___define_initcall(fn, id, __sec) \ | ||
188 | __ADDRESSABLE(fn) \ | ||
189 | asm(".section \"" #__sec ".init\", \"a\" \n" \ | ||
190 | "__initcall_" #fn #id ": \n" \ | ||
191 | ".long " #fn " - . \n" \ | ||
192 | ".previous \n"); | ||
193 | #else | ||
194 | #define ___define_initcall(fn, id, __sec) \ | ||
171 | static initcall_t __initcall_##fn##id __used \ | 195 | static initcall_t __initcall_##fn##id __used \ |
172 | __attribute__((__section__(".initcall" #id ".init"))) = fn; | 196 | __attribute__((__section__(#__sec ".init"))) = fn; |
197 | #endif | ||
198 | |||
199 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id) | ||
173 | 200 | ||
174 | /* | 201 | /* |
175 | * Early initcalls run before initializing SMP. | 202 | * Early initcalls run before initializing SMP. |
@@ -208,13 +235,8 @@ extern bool initcall_debug; | |||
208 | #define __exitcall(fn) \ | 235 | #define __exitcall(fn) \ |
209 | static exitcall_t __exitcall_##fn __exit_call = fn | 236 | static exitcall_t __exitcall_##fn __exit_call = fn |
210 | 237 | ||
211 | #define console_initcall(fn) \ | 238 | #define console_initcall(fn) ___define_initcall(fn,, .con_initcall) |
212 | static initcall_t __initcall_##fn \ | 239 | #define security_initcall(fn) ___define_initcall(fn,, .security_initcall) |
213 | __used __section(.con_initcall.init) = fn | ||
214 | |||
215 | #define security_initcall(fn) \ | ||
216 | static initcall_t __initcall_##fn \ | ||
217 | __used __section(.security_initcall.init) = fn | ||
218 | 240 | ||
219 | struct obs_kernel_param { | 241 | struct obs_kernel_param { |
220 | const char *str; | 242 | const char *str; |