|
116 | 116 | typedef int (*initcall_t)(void); |
117 | 117 | typedef void (*exitcall_t)(void); |
118 | 118 |
|
119 | | -extern initcall_t __con_initcall_start[], __con_initcall_end[]; |
120 | | -extern initcall_t __security_initcall_start[], __security_initcall_end[]; |
| 119 | +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS |
| 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 | 138 | /* Used for contructor calls. */ |
123 | 139 | typedef void (*ctor_fn_t)(void); |
@@ -167,9 +183,20 @@ extern bool initcall_debug; |
167 | 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 | 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 | 202 | * Early initcalls run before initializing SMP. |
@@ -208,13 +235,8 @@ extern bool initcall_debug; |
208 | 235 | #define __exitcall(fn) \ |
209 | 236 | static exitcall_t __exitcall_##fn __exit_call = fn |
210 | 237 |
|
211 | | -#define console_initcall(fn) \ |
212 | | - static initcall_t __initcall_##fn \ |
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 |
| 238 | +#define console_initcall(fn) ___define_initcall(fn,, .con_initcall) |
| 239 | +#define security_initcall(fn) ___define_initcall(fn,, .security_initcall) |
218 | 240 |
|
219 | 241 | struct obs_kernel_param { |
220 | 242 | const char *str; |
|
0 commit comments