aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asm-generic/vmlinux.lds.h6
-rw-r--r--include/linux/init.h13
-rw-r--r--scripts/mod/modpost.c11
3 files changed, 28 insertions, 2 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 52e2d69ee535..8307b1bb337a 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -11,7 +11,8 @@
11 11
12/* .data section */ 12/* .data section */
13#define DATA_DATA \ 13#define DATA_DATA \
14 *(.data) 14 *(.data) \
15 *(.data.init.refok)
15 16
16#define RODATA \ 17#define RODATA \
17 . = ALIGN(4096); \ 18 . = ALIGN(4096); \
@@ -147,7 +148,8 @@
147 * during second ld run in second ld pass when generating System.map */ 148 * during second ld run in second ld pass when generating System.map */
148#define TEXT_TEXT \ 149#define TEXT_TEXT \
149 ALIGN_FUNCTION(); \ 150 ALIGN_FUNCTION(); \
150 *(.text) 151 *(.text) \
152 *(.text.init.refok)
151 153
152/* sched.text is aling to function alignment to secure we have same 154/* sched.text is aling to function alignment to secure we have same
153 * address even at second ld pass when generating System.map */ 155 * address even at second ld pass when generating System.map */
diff --git a/include/linux/init.h b/include/linux/init.h
index e007ae4dc41e..56ec4c62eee0 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -45,6 +45,19 @@
45#define __exitdata __attribute__ ((__section__(".exit.data"))) 45#define __exitdata __attribute__ ((__section__(".exit.data")))
46#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) 46#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
47 47
48/* modpost check for section mismatches during the kernel build.
49 * A section mismatch happens when there are references from a
50 * code or data section to an init section (both code or data).
51 * The init sections are (for most archs) discarded by the kernel
52 * when early init has completed so all such references are potential bugs.
53 * For exit sections the same issue exists.
54 * The following markers are used for the cases where the reference to
55 * the init/exit section (code or data) is valid and will teach modpost
56 * not to issue a warning.
57 * The markers follow same syntax rules as __init / __initdata. */
58#define __init_refok noinline __attribute__ ((__section__ (".text.init.refok")))
59#define __initdata_refok __attribute__ ((__section__ (".data.init.refok")))
60
48#ifdef MODULE 61#ifdef MODULE
49#define __exit __attribute__ ((__section__(".exit.text"))) 62#define __exit __attribute__ ((__section__(".exit.text")))
50#else 63#else
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2909391a8035..7c87267b6ff0 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -583,6 +583,12 @@ static int strrcmp(const char *s, const char *sub)
583 583
584/** 584/**
585 * Whitelist to allow certain references to pass with no warning. 585 * Whitelist to allow certain references to pass with no warning.
586 *
587 * Pattern 0:
588 * Do not warn if funtion/data are marked with __init_refok/__initdata_refok.
589 * The pattern is identified by:
590 * fromsec = .text.init.refok | .data.init.refok
591 *
586 * Pattern 1: 592 * Pattern 1:
587 * If a module parameter is declared __initdata and permissions=0 593 * If a module parameter is declared __initdata and permissions=0
588 * then this is legal despite the warning generated. 594 * then this is legal despite the warning generated.
@@ -686,6 +692,11 @@ static int secref_whitelist(const char *modname, const char *tosec,
686 NULL 692 NULL
687 }; 693 };
688 694
695 /* Check for pattern 0 */
696 if ((strcmp(fromsec, ".text.init.refok") == 0) ||
697 (strcmp(fromsec, ".data.init.refok") == 0))
698 return 1;
699
689 /* Check for pattern 1 */ 700 /* Check for pattern 1 */
690 if (strcmp(tosec, ".init.data") != 0) 701 if (strcmp(tosec, ".init.data") != 0)
691 f1 = 0; 702 f1 = 0;