From 7664709b44a13e2e0b545e2dd8e7b8797a1748dc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 13 May 2007 00:31:33 +0200 Subject: all-archs: consolidate .text section definition in asm-generic Move definition of .text section to asm-generic. Signed-off-by: Sam Ravnborg --- include/asm-generic/vmlinux.lds.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index f3806a74c478..a464227a66b1 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -139,6 +139,12 @@ VMLINUX_SYMBOL(__security_initcall_end) = .; \ } +/* .text section. Map to function alignment to avoid address changes + * during second ld run in second ld pass when generating System.map */ +#define TEXT_TEXT \ + ALIGN_FUNCTION(); \ + *(.text) + /* sched.text is aling to function alignment to secure we have same * address even at second ld pass when generating System.map */ #define SCHED_TEXT \ -- cgit v1.2.3 From ca967258b69eb65dcb07bbab90fdf964c6d2ec45 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 17 May 2007 13:38:44 +0200 Subject: all-archs: consolidate .data section definition in asm-generic With this consolidation we can now modify the .data section definition in one spot for all archs. Signed-off-by: Sam Ravnborg --- arch/alpha/kernel/vmlinux.lds.S | 2 +- arch/arm/kernel/vmlinux.lds.S | 2 +- arch/arm26/kernel/vmlinux-arm26-xip.lds.in | 2 +- arch/arm26/kernel/vmlinux-arm26.lds.in | 2 +- arch/avr32/kernel/vmlinux.lds.c | 2 +- arch/blackfin/kernel/vmlinux.lds.S | 2 +- arch/frv/kernel/vmlinux.lds.S | 3 ++- arch/h8300/kernel/vmlinux.lds.S | 2 +- arch/i386/kernel/vmlinux.lds.S | 2 +- arch/ia64/kernel/vmlinux.lds.S | 7 ++++++- arch/m32r/kernel/vmlinux.lds.S | 2 +- arch/m68k/kernel/vmlinux-std.lds | 2 +- arch/m68k/kernel/vmlinux-sun3.lds | 2 +- arch/m68knommu/kernel/vmlinux.lds.S | 2 +- arch/mips/kernel/vmlinux.lds.S | 2 +- arch/parisc/kernel/vmlinux.lds.S | 2 +- arch/powerpc/kernel/vmlinux.lds.S | 2 +- arch/ppc/kernel/vmlinux.lds.S | 2 +- arch/s390/kernel/vmlinux.lds.S | 2 +- arch/sh/kernel/vmlinux.lds.S | 2 +- arch/sh64/kernel/vmlinux.lds.S | 2 +- arch/sparc/kernel/vmlinux.lds.S | 2 +- arch/sparc64/kernel/vmlinux.lds.S | 2 +- arch/um/kernel/dyn.lds.S | 3 ++- arch/um/kernel/uml.lds.S | 2 +- arch/v850/kernel/vmlinux.lds.S | 2 +- arch/x86_64/kernel/vmlinux.lds.S | 2 +- arch/xtensa/kernel/vmlinux.lds.S | 3 ++- include/asm-generic/vmlinux.lds.h | 4 ++++ 29 files changed, 40 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S index ab60e81540b5..449e76f118d3 100644 --- a/arch/alpha/kernel/vmlinux.lds.S +++ b/arch/alpha/kernel/vmlinux.lds.S @@ -89,7 +89,7 @@ SECTIONS _data = .; .data : { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 8d4e248a9544..2b7a8f5d8cf2 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -158,7 +158,7 @@ SECTIONS /* * and the usual data section */ - *(.data) + DATA_DATA CONSTRUCTORS _edata = .; diff --git a/arch/arm26/kernel/vmlinux-arm26-xip.lds.in b/arch/arm26/kernel/vmlinux-arm26-xip.lds.in index 89c806a3a51b..4ec715c25dea 100644 --- a/arch/arm26/kernel/vmlinux-arm26-xip.lds.in +++ b/arch/arm26/kernel/vmlinux-arm26-xip.lds.in @@ -111,7 +111,7 @@ SECTIONS /* * and the usual data section */ - *(.data) + DATA_DATA CONSTRUCTORS *(.init.data) diff --git a/arch/arm26/kernel/vmlinux-arm26.lds.in b/arch/arm26/kernel/vmlinux-arm26.lds.in index e3f9b18d9d23..6c44f6a17bf7 100644 --- a/arch/arm26/kernel/vmlinux-arm26.lds.in +++ b/arch/arm26/kernel/vmlinux-arm26.lds.in @@ -106,7 +106,7 @@ SECTIONS /* * and the usual data section */ - *(.data) + DATA_DATA CONSTRUCTORS _edata = .; diff --git a/arch/avr32/kernel/vmlinux.lds.c b/arch/avr32/kernel/vmlinux.lds.c index dbba3912f7ce..db0438f35c00 100644 --- a/arch/avr32/kernel/vmlinux.lds.c +++ b/arch/avr32/kernel/vmlinux.lds.c @@ -112,7 +112,7 @@ SECTIONS /* And the rest... */ *(.data.rel*) - *(.data) + DATA_DATA CONSTRUCTORS _edata = .; diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S index 36fcc777ea81..86fe67995802 100644 --- a/arch/blackfin/kernel/vmlinux.lds.S +++ b/arch/blackfin/kernel/vmlinux.lds.S @@ -200,7 +200,7 @@ SECTIONS __sdata = .; . = ALIGN(0x2000); *(.data.init_task) - *(.data) + DATA_DATA . = ALIGN(32); *(.data.cacheline_aligned) diff --git a/arch/frv/kernel/vmlinux.lds.S b/arch/frv/kernel/vmlinux.lds.S index 7e0998f7f70f..481dc1374640 100644 --- a/arch/frv/kernel/vmlinux.lds.S +++ b/arch/frv/kernel/vmlinux.lds.S @@ -136,7 +136,8 @@ SECTIONS _sdata = .; .data : { /* Data */ - *(.data .data.*) + DATA_DATA + *(.data.*) *(.exit.data) CONSTRUCTORS } diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S index 4365162952e4..a2e72d495551 100644 --- a/arch/h8300/kernel/vmlinux.lds.S +++ b/arch/h8300/kernel/vmlinux.lds.S @@ -103,7 +103,7 @@ SECTIONS . = ALIGN(0x2000) ; *(.data.init_task) . = ALIGN(0x4) ; - *(.data) + DATA_DATA . = ALIGN(0x4) ; *(.data.*) diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S index dfc439a570d0..aa87b06c7c82 100644 --- a/arch/i386/kernel/vmlinux.lds.S +++ b/arch/i386/kernel/vmlinux.lds.S @@ -74,7 +74,7 @@ SECTIONS /* writeable */ . = ALIGN(4096); .data : AT(ADDR(.data) - LOAD_OFFSET) { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS } :data diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S index 19108d0bb060..5a65965c8b53 100644 --- a/arch/ia64/kernel/vmlinux.lds.S +++ b/arch/ia64/kernel/vmlinux.lds.S @@ -214,7 +214,12 @@ SECTIONS data : { } :data .data : AT(ADDR(.data) - LOAD_OFFSET) - { *(.data) *(.data1) *(.gnu.linkonce.d*) CONSTRUCTORS } + { + DATA_DATA + *(.data1) + *(.gnu.linkonce.d*) + CONSTRUCTORS + } . = ALIGN(16); /* gp must be 16-byte aligned for exc. table */ .got : AT(ADDR(.got) - LOAD_OFFSET) diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S index bb1a2f50255e..4e2d5b9f0a9a 100644 --- a/arch/m32r/kernel/vmlinux.lds.S +++ b/arch/m32r/kernel/vmlinux.lds.S @@ -50,7 +50,7 @@ SECTIONS .data : { /* Data */ *(.spu) *(.spi) - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds index a65cef826976..78f139226a1b 100644 --- a/arch/m68k/kernel/vmlinux-std.lds +++ b/arch/m68k/kernel/vmlinux-std.lds @@ -28,7 +28,7 @@ SECTIONS _etext = .; /* End of text section */ .data : { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds index fa44d6c49acc..c8999b2db23b 100644 --- a/arch/m68k/kernel/vmlinux-sun3.lds +++ b/arch/m68k/kernel/vmlinux-sun3.lds @@ -23,7 +23,7 @@ SECTIONS _etext = .; /* End of text section */ .data : { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS . = ALIGN(16); /* Exception table */ __start___ex_table = .; diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S index 6d4585eb6e79..07a0055602f4 100644 --- a/arch/m68knommu/kernel/vmlinux.lds.S +++ b/arch/m68knommu/kernel/vmlinux.lds.S @@ -133,7 +133,7 @@ SECTIONS { .data DATA_ADDR : { . = ALIGN(4); _sdata = . ; - *(.data) + DATA_DATA . = ALIGN(8192) ; *(.data.init_task) _edata = . ; diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index cfe4b67ef268..9b9992cd562a 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -62,7 +62,7 @@ SECTIONS . = ALIGN(_PAGE_SIZE); *(.data.init_task) - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S index 321de82fa867..4d96ba4b9849 100644 --- a/arch/parisc/kernel/vmlinux.lds.S +++ b/arch/parisc/kernel/vmlinux.lds.S @@ -91,7 +91,7 @@ SECTIONS . = ALIGN(L1_CACHE_BYTES); .data : { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index f26620988860..f7d7bf19e4fb 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -168,7 +168,7 @@ SECTIONS #ifdef CONFIG_PPC32 .data : { - *(.data) + DATA_DATA *(.sdata) *(.got.plt) *(.got) } diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S index 419ef7e8e384..19db8746ff14 100644 --- a/arch/ppc/kernel/vmlinux.lds.S +++ b/arch/ppc/kernel/vmlinux.lds.S @@ -67,7 +67,7 @@ SECTIONS . = ALIGN(4096); .data : { - *(.data) + DATA_DATA *(.data1) *(.sdata) *(.sdata2) diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 89c2ec5c85ff..7158a804a5e4 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S @@ -48,7 +48,7 @@ SECTIONS BUG_TABLE .data : { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S index 2367869d2141..4c5b57e9c3c1 100644 --- a/arch/sh/kernel/vmlinux.lds.S +++ b/arch/sh/kernel/vmlinux.lds.S @@ -41,7 +41,7 @@ SECTIONS BUG_TABLE .data : { /* Data */ - *(.data) + DATA_DATA /* Align the initial ramdisk image (INITRD) on page boundaries. */ . = ALIGN(PAGE_SIZE); diff --git a/arch/sh64/kernel/vmlinux.lds.S b/arch/sh64/kernel/vmlinux.lds.S index fdf72ceff869..02aea86c5907 100644 --- a/arch/sh64/kernel/vmlinux.lds.S +++ b/arch/sh64/kernel/vmlinux.lds.S @@ -78,7 +78,7 @@ SECTIONS _etext = .; /* End of text section */ .data : C_PHYS(.data) { /* Data */ - *(.data) + DATA_DATA CONSTRUCTORS } diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S index 5cb600e29875..f75a1b822789 100644 --- a/arch/sparc/kernel/vmlinux.lds.S +++ b/arch/sparc/kernel/vmlinux.lds.S @@ -22,7 +22,7 @@ SECTIONS RODATA .data : { - *(.data) + DATA_DATA CONSTRUCTORS } .data1 : { *(.data1) } diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S index f06da20533f5..fb648de18a8d 100644 --- a/arch/sparc64/kernel/vmlinux.lds.S +++ b/arch/sparc64/kernel/vmlinux.lds.S @@ -27,7 +27,7 @@ SECTIONS .data : { - *(.data) + DATA_DATA CONSTRUCTORS } .data1 : { *(.data1) } diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S index ec8477d0feb3..24547741b205 100644 --- a/arch/um/kernel/dyn.lds.S +++ b/arch/um/kernel/dyn.lds.S @@ -99,7 +99,8 @@ SECTIONS *(.data.init_task) . = ALIGN(KERNEL_STACK_SIZE); *(.data.init_irqstack) - *(.data .data.* .gnu.linkonce.d.*) + DATA_DATA + *(.data.* .gnu.linkonce.d.*) SORT(CONSTRUCTORS) } .data1 : { *(.data1) } diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 84351059c356..307b9373676b 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S @@ -61,7 +61,7 @@ SECTIONS *(.data.init_task) . = ALIGN(KERNEL_STACK_SIZE); *(.data.init_irqstack) - *(.data) + DATA_DATA *(.gnu.linkonce.d*) CONSTRUCTORS } diff --git a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S index 9e2b4bc06c68..6172599b4ce2 100644 --- a/arch/v850/kernel/vmlinux.lds.S +++ b/arch/v850/kernel/vmlinux.lds.S @@ -113,7 +113,7 @@ /* Kernel data segment. */ #define DATA_CONTENTS \ __sdata = . ; \ - *(.data) \ + DATA_DATA \ *(.exit.data) /* 2.5 convention */ \ *(.data.exit) /* 2.4 convention */ \ . = ALIGN (16) ; \ diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S index c77142d9fba9..dbccfda8364f 100644 --- a/arch/x86_64/kernel/vmlinux.lds.S +++ b/arch/x86_64/kernel/vmlinux.lds.S @@ -55,7 +55,7 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */ /* Data */ .data : AT(ADDR(.data) - LOAD_OFFSET) { - *(.data) + DATA_DATA CONSTRUCTORS } :data diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S index 7d2dfb286a92..4b7b4ff79973 100644 --- a/arch/xtensa/kernel/vmlinux.lds.S +++ b/arch/xtensa/kernel/vmlinux.lds.S @@ -145,7 +145,8 @@ SECTIONS _fdata = .; .data : { - *(.data) CONSTRUCTORS + DATA_DATA + CONSTRUCTORS . = ALIGN(XCHAL_ICACHE_LINESIZE); *(.data.cacheline_aligned) } diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index a464227a66b1..52e2d69ee535 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -9,6 +9,10 @@ /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION() . = ALIGN(8) +/* .data section */ +#define DATA_DATA \ + *(.data) + #define RODATA \ . = ALIGN(4096); \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ -- cgit v1.2.3 From 0e0d314e6a01bb14d303e35e6f7ba24b17020044 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 17 May 2007 20:14:48 +0200 Subject: kbuild: introduce __init_refok/__initdata_refok to supress section mismatch warnings Throughout the kernel there are a few legitimite references to init or exit sections. Most of these are covered by the patterns included in modpost but a few nees special attention. To avoid hardcoding a lot of function names in modpost introduce a marker so relevant function/data can be marked. When modpost see a reference to a init/exit function from a function/data marked no warning will be issued. Idea from: Andrew Morton Signed-off-by: Sam Ravnborg Cc: Andrew Morton --- include/asm-generic/vmlinux.lds.h | 6 ++++-- include/linux/init.h | 13 +++++++++++++ scripts/mod/modpost.c | 11 +++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'include') 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 @@ /* .data section */ #define DATA_DATA \ - *(.data) + *(.data) \ + *(.data.init.refok) #define RODATA \ . = ALIGN(4096); \ @@ -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 */ 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 @@ #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 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) /** * 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. @@ -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; -- cgit v1.2.3