Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 56726
b: refs/heads/master
c: 0e0d314
h: refs/heads/master
v: v3
  • Loading branch information
Sam Ravnborg committed May 19, 2007
1 parent 3cf8ebe commit d9bb879
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ca967258b69eb65dcb07bbab90fdf964c6d2ec45
refs/heads/master: 0e0d314e6a01bb14d303e35e6f7ba24b17020044
6 changes: 4 additions & 2 deletions trunk/include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

/* .data section */
#define DATA_DATA \
*(.data)
*(.data) \
*(.data.init.refok)

#define RODATA \
. = ALIGN(4096); \
Expand Down Expand Up @@ -147,7 +148,8 @@
* during second ld run in second ld pass when generating System.map */
#define TEXT_TEXT \
ALIGN_FUNCTION(); \
*(.text)
*(.text) \
*(.text.init.refok)

/* sched.text is aling to function alignment to secure we have same
* address even at second ld pass when generating System.map */
Expand Down
13 changes: 13 additions & 0 deletions trunk/include/linux/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
#define __exitdata __attribute__ ((__section__(".exit.data")))
#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))

/* modpost check for section mismatches during the kernel build.
* A section mismatch happens when there are references from a
* code or data section to an init section (both code or data).
* The init sections are (for most archs) discarded by the kernel
* 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 markers follow same syntax rules as __init / __initdata. */
#define __init_refok noinline __attribute__ ((__section__ (".text.init.refok")))
#define __initdata_refok __attribute__ ((__section__ (".data.init.refok")))

#ifdef MODULE
#define __exit __attribute__ ((__section__(".exit.text")))
#else
Expand Down
11 changes: 11 additions & 0 deletions trunk/scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,12 @@ static int strrcmp(const char *s, const char *sub)

/**
* Whitelist to allow certain references to pass with no warning.
*
* Pattern 0:
* Do not warn if funtion/data are marked with __init_refok/__initdata_refok.
* The pattern is identified by:
* fromsec = .text.init.refok | .data.init.refok
*
* Pattern 1:
* If a module parameter is declared __initdata and permissions=0
* then this is legal despite the warning generated.
Expand Down Expand Up @@ -686,6 +692,11 @@ static int secref_whitelist(const char *modname, const char *tosec,
NULL
};

/* Check for pattern 0 */
if ((strcmp(fromsec, ".text.init.refok") == 0) ||
(strcmp(fromsec, ".data.init.refok") == 0))
return 1;

/* Check for pattern 1 */
if (strcmp(tosec, ".init.data") != 0)
f1 = 0;
Expand Down

0 comments on commit d9bb879

Please sign in to comment.