> One thing I'm not yet sure about is initcall.lds and whether we need an
> equivalent or not.

Sorry for answering an old email.

For gcc we have noreorder exactly for this, but could also use the LLVM
hack (but I'm not sure how they cover the other cases like schedule
domains or apic) 

here are the patches from Jiri's patchkit:
(cut and pasted patches)


diff --git a/include/linux/compiler_attributes.h 
b/include/linux/compiler_attributes.h
index c16d4199bf92..49cdb318c319 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -409,4 +409,14 @@
  */
 #define __fix_address noinline __noclone

+/*
+ * 
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
+ */
+
+#if __has_attribute(__no_reorder__)
+#define __noreorder                    __attribute__((no_reorder))
+#else
+#define __noreorder
+#endif
+
 #endif /* __LINUX_COMPILER_ATTRIBUTES_H */



and

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 23d86c9750b9..e6f09406921b 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -350,7 +350,7 @@ extern struct apic *apic;
  * of different apic driver files in the Makefile.
  */
 #define apic_driver(sym)                                       \
-       static const struct apic *__apicdrivers_##sym __used            \
+       static const struct apic *__apicdrivers_##sym __used __noreorder \
        __aligned(sizeof(struct apic *))                        \
        __section(".apicdrivers") = { &sym }


and

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 83e3aa917142..524bba94c9d7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2510,6 +2510,7 @@ static inline void put_prev_set_next_task(struct rq *rq,
  */
 #define DEFINE_SCHED_CLASS(name) \
 const struct sched_class name##_sched_class \
+       __noreorder \
        __aligned(__alignof__(struct sched_class)) \
        __section("__" #name "_sched_class")


and

diff --git a/include/linux/init.h b/include/linux/init.h
index ee1309473bc6..3c67516bbfea 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -266,7 +266,7 @@ extern struct module __this_module;
        static_assert(__same_type(initcall_t, &fn));
 #else
 #define ____define_initcall(fn, __unused, __name, __sec)       \
-       static initcall_t __name __used                         \
+       static initcall_t __name __used __noreorder             \
                __attribute__((__section__(__sec))) = fn;
 #endif




Reply via email to