| .. | .. |
|---|
| 47 | 47 | |
|---|
| 48 | 48 | /* These are for everybody (although not all archs will actually |
|---|
| 49 | 49 | discard it in modules) */ |
|---|
| 50 | | -#define __init __section(.init.text) __cold __latent_entropy __noinitretpoline __nocfi |
|---|
| 51 | | -#define __initdata __section(.init.data) |
|---|
| 52 | | -#define __initconst __section(.init.rodata) |
|---|
| 53 | | -#define __exitdata __section(.exit.data) |
|---|
| 54 | | -#define __exit_call __used __section(.exitcall.exit) |
|---|
| 50 | +#define __init __section(".init.text") __cold __latent_entropy __noinitretpoline __nocfi |
|---|
| 51 | +#define __initdata __section(".init.data") |
|---|
| 52 | +#define __initconst __section(".init.rodata") |
|---|
| 53 | +#define __exitdata __section(".exit.data") |
|---|
| 54 | +#define __exit_call __used __section(".exitcall.exit") |
|---|
| 55 | 55 | |
|---|
| 56 | 56 | /* |
|---|
| 57 | 57 | * modpost check for section mismatches during the kernel build. |
|---|
| .. | .. |
|---|
| 70 | 70 | * |
|---|
| 71 | 71 | * The markers follow same syntax rules as __init / __initdata. |
|---|
| 72 | 72 | */ |
|---|
| 73 | | -#define __ref __section(.ref.text) noinline |
|---|
| 74 | | -#define __refdata __section(.ref.data) |
|---|
| 75 | | -#define __refconst __section(.ref.rodata) |
|---|
| 73 | +#define __ref __section(".ref.text") noinline |
|---|
| 74 | +#define __refdata __section(".ref.data") |
|---|
| 75 | +#define __refconst __section(".ref.rodata") |
|---|
| 76 | 76 | |
|---|
| 77 | 77 | #ifdef MODULE |
|---|
| 78 | 78 | #define __exitused |
|---|
| .. | .. |
|---|
| 80 | 80 | #define __exitused __used |
|---|
| 81 | 81 | #endif |
|---|
| 82 | 82 | |
|---|
| 83 | | -#define __exit __section(.exit.text) __exitused __cold notrace |
|---|
| 83 | +#define __exit __section(".exit.text") __exitused __cold notrace |
|---|
| 84 | 84 | |
|---|
| 85 | 85 | /* Used for MEMORY_HOTPLUG */ |
|---|
| 86 | | -#define __meminit __section(.meminit.text) __cold notrace \ |
|---|
| 86 | +#define __meminit __section(".meminit.text") __cold notrace \ |
|---|
| 87 | 87 | __latent_entropy |
|---|
| 88 | | -#define __meminitdata __section(.meminit.data) |
|---|
| 89 | | -#define __meminitconst __section(.meminit.rodata) |
|---|
| 90 | | -#define __memexit __section(.memexit.text) __exitused __cold notrace |
|---|
| 91 | | -#define __memexitdata __section(.memexit.data) |
|---|
| 92 | | -#define __memexitconst __section(.memexit.rodata) |
|---|
| 88 | +#define __meminitdata __section(".meminit.data") |
|---|
| 89 | +#define __meminitconst __section(".meminit.rodata") |
|---|
| 90 | +#define __memexit __section(".memexit.text") __exitused __cold notrace |
|---|
| 91 | +#define __memexitdata __section(".memexit.data") |
|---|
| 92 | +#define __memexitconst __section(".memexit.rodata") |
|---|
| 93 | 93 | |
|---|
| 94 | 94 | /* For assembly routines */ |
|---|
| 95 | 95 | #define __HEAD .section ".head.text","ax" |
|---|
| .. | .. |
|---|
| 133 | 133 | #endif |
|---|
| 134 | 134 | |
|---|
| 135 | 135 | extern initcall_entry_t __con_initcall_start[], __con_initcall_end[]; |
|---|
| 136 | | -extern initcall_entry_t __security_initcall_start[], __security_initcall_end[]; |
|---|
| 137 | 136 | |
|---|
| 138 | 137 | /* Used for contructor calls. */ |
|---|
| 139 | 138 | typedef void (*ctor_fn_t)(void); |
|---|
| 139 | + |
|---|
| 140 | +struct file_system_type; |
|---|
| 140 | 141 | |
|---|
| 141 | 142 | /* Defined in init/main.c */ |
|---|
| 142 | 143 | extern int do_one_initcall(initcall_t fn); |
|---|
| .. | .. |
|---|
| 147 | 148 | /* used by init/main.c */ |
|---|
| 148 | 149 | void setup_arch(char **); |
|---|
| 149 | 150 | void prepare_namespace(void); |
|---|
| 150 | | -void __init load_default_modules(void); |
|---|
| 151 | | -int __init init_rootfs(void); |
|---|
| 151 | +void __init init_rootfs(void); |
|---|
| 152 | +extern struct file_system_type rootfs_fs_type; |
|---|
| 152 | 153 | |
|---|
| 153 | 154 | #if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_STRICT_MODULE_RWX) |
|---|
| 154 | 155 | extern bool rodata_enabled; |
|---|
| .. | .. |
|---|
| 183 | 184 | * as KEEP() in the linker script. |
|---|
| 184 | 185 | */ |
|---|
| 185 | 186 | |
|---|
| 187 | +/* Format: <modname>__<counter>_<line>_<fn> */ |
|---|
| 188 | +#define __initcall_id(fn) \ |
|---|
| 189 | + __PASTE(__KBUILD_MODNAME, \ |
|---|
| 190 | + __PASTE(__, \ |
|---|
| 191 | + __PASTE(__COUNTER__, \ |
|---|
| 192 | + __PASTE(_, \ |
|---|
| 193 | + __PASTE(__LINE__, \ |
|---|
| 194 | + __PASTE(_, fn)))))) |
|---|
| 195 | + |
|---|
| 196 | +/* Format: __<prefix>__<iid><id> */ |
|---|
| 197 | +#define __initcall_name(prefix, __iid, id) \ |
|---|
| 198 | + __PASTE(__, \ |
|---|
| 199 | + __PASTE(prefix, \ |
|---|
| 200 | + __PASTE(__, \ |
|---|
| 201 | + __PASTE(__iid, id)))) |
|---|
| 202 | + |
|---|
| 203 | +#ifdef CONFIG_LTO_CLANG |
|---|
| 204 | +/* |
|---|
| 205 | + * With LTO, the compiler doesn't necessarily obey link order for |
|---|
| 206 | + * initcalls. In order to preserve the correct order, we add each |
|---|
| 207 | + * variable into its own section and generate a linker script (in |
|---|
| 208 | + * scripts/link-vmlinux.sh) to specify the order of the sections. |
|---|
| 209 | + */ |
|---|
| 210 | +#define __initcall_section(__sec, __iid) \ |
|---|
| 211 | + #__sec ".init.." #__iid |
|---|
| 212 | + |
|---|
| 213 | +/* |
|---|
| 214 | + * With LTO, the compiler can rename static functions to avoid |
|---|
| 215 | + * global naming collisions. We use a global stub function for |
|---|
| 216 | + * initcalls to create a stable symbol name whose address can be |
|---|
| 217 | + * taken in inline assembly when PREL32 relocations are used. |
|---|
| 218 | + */ |
|---|
| 219 | +#define __initcall_stub(fn, __iid, id) \ |
|---|
| 220 | + __initcall_name(initstub, __iid, id) |
|---|
| 221 | + |
|---|
| 222 | +#define __define_initcall_stub(__stub, fn) \ |
|---|
| 223 | + int __init __cficanonical __stub(void); \ |
|---|
| 224 | + int __init __cficanonical __stub(void) \ |
|---|
| 225 | + { \ |
|---|
| 226 | + return fn(); \ |
|---|
| 227 | + } \ |
|---|
| 228 | + __ADDRESSABLE(__stub) |
|---|
| 229 | +#else |
|---|
| 230 | +#define __initcall_section(__sec, __iid) \ |
|---|
| 231 | + #__sec ".init" |
|---|
| 232 | + |
|---|
| 233 | +#define __initcall_stub(fn, __iid, id) fn |
|---|
| 234 | + |
|---|
| 235 | +#define __define_initcall_stub(__stub, fn) \ |
|---|
| 236 | + __ADDRESSABLE(fn) |
|---|
| 237 | +#endif |
|---|
| 238 | + |
|---|
| 186 | 239 | #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" \ |
|---|
| 240 | +#define ____define_initcall(fn, __stub, __name, __sec) \ |
|---|
| 241 | + __define_initcall_stub(__stub, fn) \ |
|---|
| 242 | + asm(".section \"" __sec "\", \"a\" \n" \ |
|---|
| 243 | + __stringify(__name) ": \n" \ |
|---|
| 244 | + ".long " __stringify(__stub) " - . \n" \ |
|---|
| 192 | 245 | ".previous \n"); |
|---|
| 193 | 246 | #else |
|---|
| 194 | | -#ifdef CONFIG_LTO_CLANG |
|---|
| 195 | | - /* |
|---|
| 196 | | - * With LTO, the compiler doesn't necessarily obey link order for |
|---|
| 197 | | - * initcalls, and the initcall variable needs to be globally unique |
|---|
| 198 | | - * to avoid naming collisions. In order to preserve the correct |
|---|
| 199 | | - * order, we add each variable into its own section and generate a |
|---|
| 200 | | - * linker script (in scripts/link-vmlinux.sh) to ensure the order |
|---|
| 201 | | - * remains correct. We also add a __COUNTER__ prefix to the name, |
|---|
| 202 | | - * so we can retain the order of initcalls within each compilation |
|---|
| 203 | | - * unit, and __LINE__ to make the names more unique. |
|---|
| 204 | | - */ |
|---|
| 205 | | - #define ___lto_initcall(c, l, fn, id, __sec) \ |
|---|
| 206 | | - static initcall_t __initcall_##c##_##l##_##fn##id __used \ |
|---|
| 207 | | - __attribute__((__section__( #__sec \ |
|---|
| 208 | | - __stringify(.init..##c##_##l##_##fn)))) = fn; |
|---|
| 209 | | - #define __lto_initcall(c, l, fn, id, __sec) \ |
|---|
| 210 | | - ___lto_initcall(c, l, fn, id, __sec) |
|---|
| 247 | +#define ____define_initcall(fn, __unused, __name, __sec) \ |
|---|
| 248 | + static initcall_t __name __used \ |
|---|
| 249 | + __attribute__((__section__(__sec))) = fn; |
|---|
| 250 | +#endif |
|---|
| 211 | 251 | |
|---|
| 212 | | - #define ___define_initcall(fn, id, __sec) \ |
|---|
| 213 | | - __lto_initcall(__COUNTER__, __LINE__, fn, id, __sec) |
|---|
| 214 | | -#else |
|---|
| 215 | | - #define ___define_initcall(fn, id, __sec) \ |
|---|
| 216 | | - static initcall_t __initcall_##fn##id __used \ |
|---|
| 217 | | - __attribute__((__section__(#__sec ".init"))) = fn; |
|---|
| 218 | | -#endif |
|---|
| 219 | | -#endif |
|---|
| 252 | +#define __unique_initcall(fn, id, __sec, __iid) \ |
|---|
| 253 | + ____define_initcall(fn, \ |
|---|
| 254 | + __initcall_stub(fn, __iid, id), \ |
|---|
| 255 | + __initcall_name(initcall, __iid, id), \ |
|---|
| 256 | + __initcall_section(__sec, __iid)) |
|---|
| 257 | + |
|---|
| 258 | +#define ___define_initcall(fn, id, __sec) \ |
|---|
| 259 | + __unique_initcall(fn, id, __sec, __initcall_id(fn)) |
|---|
| 220 | 260 | |
|---|
| 221 | 261 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id) |
|---|
| 222 | 262 | |
|---|
| .. | .. |
|---|
| 258 | 298 | static exitcall_t __exitcall_##fn __exit_call = fn |
|---|
| 259 | 299 | |
|---|
| 260 | 300 | #define console_initcall(fn) ___define_initcall(fn, con, .con_initcall) |
|---|
| 261 | | -#define security_initcall(fn) ___define_initcall(fn, security, .security_initcall) |
|---|
| 262 | 301 | |
|---|
| 263 | 302 | struct obs_kernel_param { |
|---|
| 264 | 303 | const char *str; |
|---|
| .. | .. |
|---|
| 276 | 315 | static const char __setup_str_##unique_id[] __initconst \ |
|---|
| 277 | 316 | __aligned(1) = str; \ |
|---|
| 278 | 317 | static struct obs_kernel_param __setup_##unique_id \ |
|---|
| 279 | | - __used __section(.init.setup) \ |
|---|
| 318 | + __used __section(".init.setup") \ |
|---|
| 280 | 319 | __attribute__((aligned((sizeof(long))))) \ |
|---|
| 281 | 320 | = { __setup_str_##unique_id, fn, early } |
|---|
| 282 | 321 | |
|---|
| .. | .. |
|---|
| 320 | 359 | #endif |
|---|
| 321 | 360 | |
|---|
| 322 | 361 | /* Data marked not to be saved by software suspend */ |
|---|
| 323 | | -#define __nosavedata __section(.data..nosave) |
|---|
| 362 | +#define __nosavedata __section(".data..nosave") |
|---|
| 324 | 363 | |
|---|
| 325 | 364 | #ifdef MODULE |
|---|
| 326 | 365 | #define __exit_p(x) x |
|---|