]> err.no Git - linux-2.6/commitdiff
Introduce new section reference annotations tags: __ref, __refdata, __refconst
authorSam Ravnborg <sam@ravnborg.org>
Mon, 28 Jan 2008 19:21:15 +0000 (20:21 +0100)
committerSam Ravnborg <sam@ravnborg.org>
Mon, 28 Jan 2008 22:21:19 +0000 (23:21 +0100)
Today we have the following annotations for functions/data
referencing __init/__exit functions / data:

__init_refok     => for init functions
__initdata_refok => for init data
__exit_refok     => for exit functions

There is really no difference between the __init and __exit
versions and simplify it and to introduce a shorter annotation
the following new annotations are introduced:

__ref      => for functions (code) that
              references __*init / __*exit
__refdata  => for variables
__refconst => for const variables

Whit this annotation is it more obvious what the annotation
is for and there is no longer the arbitary division
between __init and __exit code.

The mechanishm is the same as before - a special section
is created which is made part of the usual sections
in the linker script.

We will start to see annotations like this:

-static struct pci_serial_quirk pci_serial_quirks[] = {
+static const struct pci_serial_quirk pci_serial_quirks[] __refconst = {
-----------------
-static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier =
+static struct notifier_block cpuid_class_cpu_notifier __refdata =
----------------
-static int threshold_cpu_callback(struct notifier_block *nfb,
+static int __ref threshold_cpu_callback(struct notifier_block *nfb,

[The above is just random samples].

Note: No modifications were needed in modpost
to support the new sections due to the newly introduced
blacklisting.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
include/asm-generic/vmlinux.lds.h
include/linux/init.h

index 294853053707913170ecf168291144dd4e81df59..76df771be58566171cd5b74ab16489ae1c5f2cea 100644 (file)
@@ -42,6 +42,7 @@
 #define DATA_DATA                                                      \
        *(.data)                                                        \
        *(.data.init.refok)                                             \
+       *(.ref.data)                                                    \
        DEV_KEEP(init.data)                                             \
        DEV_KEEP(exit.data)                                             \
        CPU_KEEP(init.data)                                             \
                                                                        \
        /* __*init sections */                                          \
        __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {         \
+               *(.ref.rodata)                                          \
                DEV_KEEP(init.rodata)                                   \
                DEV_KEEP(exit.rodata)                                   \
                CPU_KEEP(init.rodata)                                   \
 #define TEXT_TEXT                                                      \
                ALIGN_FUNCTION();                                       \
                *(.text)                                                \
+               *(.ref.text)                                            \
                *(.text.init.refok)                                     \
                *(.exit.text.refok)                                     \
        DEV_KEEP(init.text)                                             \
index dde1eaa7766bfab13da57f4c64f4211242831be9..2efbda01674186d166671dbf2455063970c52bfa 100644 (file)
  * when early init has completed so all such references are potential bugs.
  * For exit sections the same issue exists.
  * The following markers are used for the cases where the reference to
- * the init/exit section (code or data) is valid and will teach modpost
- * not to issue a warning.
+ * the *init / *exit section (code or data) is valid and will teach
+ * modpost not to issue a warning.
  * The markers follow same syntax rules as __init / __initdata. */
-#define __init_refok     noinline __section(.text.init.refok)
-#define __initdata_refok          __section(.data.init.refok)
-#define __exit_refok     noinline __section(.exit.text.refok)
+#define __ref            __section(.ref.text) noinline
+#define __refdata        __section(.ref.data)
+#define __refconst       __section(.ref.rodata)
+
+/* backward compatibility note
+ *  A few places hardcode the old section names:
+ *  .text.init.refok
+ *  .data.init.refok
+ *  .exit.text.refok
+ *  They should be converted to use the defines from this file
+ */
+
+/* compatibility defines */
+#define __init_refok     __ref
+#define __initdata_refok __refdata
+#define __exit_refok     __ref
+
 
 #ifdef MODULE
 #define __exitused
 
 /* For assembly routines */
 #define __INIT         .section        ".init.text","ax"
-#define __INIT_REFOK   .section        ".text.init.refok","ax"
 #define __FINIT                .previous
 
 #define __INITDATA     .section        ".init.data","aw"
-#define __INITDATA_REFOK .section      ".data.init.refok","aw"
 
 #define __DEVINIT        .section      ".devinit.text", "ax"
 #define __DEVINITDATA    .section      ".devinit.data", "aw"
 #define __MEMINIT        .section      ".meminit.text", "ax"
 #define __MEMINITDATA    .section      ".meminit.data", "aw"
 
+/* silence warnings when references are OK */
+#define __REF            .section       ".ref.text", "ax"
+#define __REFDATA        .section       ".ref.data", "aw"
+#define __REFCONST       .section       ".ref.rodata", "aw"
+/* backward compatibility */
+#define __INIT_REFOK     .section      __REF
+#define __INITDATA_REFOK .section      __REFDATA
+
 #ifndef __ASSEMBLY__
 /*
  * Used for initialization calls..