LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Discardable strings for init and exit sections
@ 2007-10-12 16:50 Maciej W. Rozycki
  2007-10-12 17:19 ` Adrian Bunk
  2007-10-12 17:45 ` Sam Ravnborg
  0 siblings, 2 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2007-10-12 16:50 UTC (permalink / raw)
  To: Franck Bui-Huu, Ralf Baechle, linux-arch, linux-mips
  Cc: Andrew Morton, linux-kernel

 We currently have infrastructure for discardable text and data, but no 
such thing for strings.  This is especially notable for inline strings 
such as ones used by printk() which are left behind resident in the memory 
throughout the life of the system even though code referring to them has 
been removed.

 Following a short discussion at the linux-mips list, here is a proposed 
implementation for discardable strings.  It adds __initstr and __exitstr 
plus most of the usual variations, but most importantly it adds wrapper 
macros that may be used for inline strings that make them be put in
separate sections which may then be discarded, while still preserving the 
usual merging property of sections containing strings.  The macros are 
called _i() and _e(), with the other alternatives adding at most two 
letters each.  This has been inspired by how the GNU gettext handles 
localised strings in a way that does not add too much clutter and the 
result is still reasonably well readable.  Some use examples have been 
included in <linux/init.h>.

 There is one pitfall here -- GCC does not let one specify section flags 
explicitly and provides its own set based on the type of the variable 
instead.  The guess, which is "aw", is not what we want here, so I had to 
circumvent it somehow.  The solution is to provide the flags and the 
further necessary parameters as a part of the section "name" and then emit 
a newline and an assembly comment character so that what GCC produces for 
section flags is ignored.  A newline is required for a reasonable 
implementation, because only the line comment character is almost 
universal across targets supported by binutils (except from a couple of 
obscure platforms we do not aim to support), while the trailing comment 
character varies wildly and may not even be available at all (cf. 
blackfin).  This is what this strange __strflags macro is for.

 Of course for this to work all the linker scripts have to be updated 
accordingly.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
---
 I did some proof-of-concept testing only of this change as for it to be 
of use, strings have to be annotated appropriately.  I do not expect it to 
happen soon or automatically, but I rely on people for whom the size 
matters to make the necessary adjustments.

 For testing I made the obvious choice ;-) of drivers/net/defxx.c; for 
which I have a patch that I will send separately.  The driver is nice 
enough to have a duplicate string that can be used to verify that merging 
still works and then the results of the discarding can be examined through 
/proc/kcore.  I have built the changes for MIPS, albeit with a slightly 
older kernel as the current version does not build for my configuration of 
interest, and successfully verified at the run time.

 Architecture maintainers, I have made a reasonable attempt to get the 
linker script changes right, but for a few of the more complicated setups 
I may have not done everything necessary or I may have misplaced the 
sections in the output even.  Please let me know of any adjustments 
necessary.

 Comments are welcome, whether positive or negative, but I do hope overall 
the feature is reasonable enough to be accepted.  This patch applies to 
the current Linus tree.

  Maciej

patch-2.6.23-20071012-inexitstr-5
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/alpha/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/alpha/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/alpha/kernel/vmlinux.lds.S	2007-09-04 04:55:16.000000000 +0000
+++ linux-2.6.23-20071012/arch/alpha/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -42,6 +42,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
 
   . = ALIGN(16);
@@ -107,7 +108,7 @@ SECTIONS
   _end = .;
 
   /* Sections to be discarded */
-  /DISCARD/ : { *(.exit.text) *(.exit.data) *(.exitcall.exit) }
+  /DISCARD/ : { *(.exit.text) *(.exit.str1) *(.exit.data) *(.exitcall.exit) }
 
   .mdebug 0 : { *(.mdebug) }
   .note 0 : { *(.note) }
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/arm/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/arm/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/arm/kernel/vmlinux.lds.S	2007-09-04 04:55:16.000000000 +0000
+++ linux-2.6.23-20071012/arch/arm/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -41,6 +41,7 @@ SECTIONS
 		__tagtable_begin = .;
 			*(.taglist.init)
 		__tagtable_end = .;
+			*(.init.str1)
 		. = ALIGN(16);
 		__setup_start = .;
 			*(.init.setup)
@@ -78,6 +79,7 @@ SECTIONS
 
 	/DISCARD/ : {			/* Exit code and data		*/
 		*(.exit.text)
+		*(.exit.str1)
 		*(.exit.data)
 		*(.exitcall.exit)
 #ifndef CONFIG_MMU
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/blackfin/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/blackfin/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/blackfin/kernel/vmlinux.lds.S	2007-10-12 02:56:53.000000000 +0000
+++ linux-2.6.23-20071012/arch/blackfin/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -94,6 +94,10 @@ SECTIONS
 		*(.init.text)
 		__einittext = .;
 	}
+	.init.str1 :
+	{
+		*(.init.str1)
+	}
 	.init.data :
 	{
 		. = ALIGN(16);
@@ -194,6 +198,7 @@ SECTIONS
 	/DISCARD/ :
 	{
 		*(.exit.text)
+		*(.exit.str1)
 		*(.exit.data)
 		*(.exitcall.exit)
 	}
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/frv/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/frv/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/frv/kernel/vmlinux.lds.S	2007-09-04 04:55:18.000000000 +0000
+++ linux-2.6.23-20071012/arch/frv/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -35,6 +35,7 @@ SECTIONS
 #endif
   }
   _einittext = .;
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
 
   . = ALIGN(8);
@@ -124,6 +125,7 @@ SECTIONS
 	__trap_fixup_tables = .;
 	*(.trap.fixup.user .trap.fixup.kernel)
 
+	*(.exit.str1)
 	}
 
   . = ALIGN(8);		/* Exception table */
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/h8300/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/h8300/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/h8300/kernel/vmlinux.lds.S	2007-07-10 04:55:29.000000000 +0000
+++ linux-2.6.23-20071012/arch/h8300/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -112,6 +112,7 @@ SECTIONS
 	__sinittext = .; 
 		*(.init.text)
 	__einittext = .; 
+		*(.init.str1)
 		*(.init.data)
 	. = ALIGN(0x4) ;
 	___setup_start = .;
@@ -125,6 +126,7 @@ SECTIONS
 		*(.con_initcall.init)
 	___con_initcall_end = .;
 		*(.exit.text)
+		*(.exit.str1)
 		*(.exit.data)
 #if defined(CONFIG_BLK_DEV_INITRD)
 		. = ALIGN(4);
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/ia64/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/ia64/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/ia64/kernel/vmlinux.lds.S	2007-09-04 04:55:19.000000000 +0000
+++ linux-2.6.23-20071012/arch/ia64/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -28,6 +28,7 @@ SECTIONS
   /* Sections to be discarded */
   /DISCARD/ : {
 	*(.exit.text)
+	*(.exit.str1)
 	*(.exit.data)
 	*(.exitcall.exit)
 	*(.IA_64.unwind.exit.text)
@@ -123,6 +124,9 @@ SECTIONS
 	  _einittext = .;
 	}
 
+  .exit.str1 : AT(ADDR(.init.str1) - LOAD_OFFSET)
+	{ *(.exit.str1) }
+
   .init.data : AT(ADDR(.init.data) - LOAD_OFFSET)
 	{ *(.init.data) }
 
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/m32r/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/m32r/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/m32r/kernel/vmlinux.lds.S	2007-09-04 04:55:19.000000000 +0000
+++ linux-2.6.23-20071012/arch/m32r/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -79,6 +79,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
   . = ALIGN(16);
   __setup_start = .;
@@ -101,6 +102,7 @@ SECTIONS
   /* .exit.text is discard at runtime, not link time, to deal with references
      from .altinstructions and .eh_frame */
   .exit.text : { *(.exit.text) }
+  .exit.str1 : { *(.exit.str1) }
   .exit.data : { *(.exit.data) }
 
 #ifdef CONFIG_BLK_DEV_INITRD
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/m68k/kernel/vmlinux-std.lds linux-2.6.23-20071012/arch/m68k/kernel/vmlinux-std.lds
--- linux-2.6.23-20071012.macro/arch/m68k/kernel/vmlinux-std.lds	2007-09-04 04:55:19.000000000 +0000
+++ linux-2.6.23-20071012/arch/m68k/kernel/vmlinux-std.lds	2007-10-12 13:53:22.000000000 +0000
@@ -48,6 +48,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
   . = ALIGN(16);
   __setup_start = .;
@@ -83,6 +84,7 @@ SECTIONS
   /* Sections to be discarded */
   /DISCARD/ : {
 	*(.exit.text)
+	*(.exit.str1)
 	*(.exit.data)
 	*(.exitcall.exit)
 	}
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/m68k/kernel/vmlinux-sun3.lds linux-2.6.23-20071012/arch/m68k/kernel/vmlinux-sun3.lds
--- linux-2.6.23-20071012.macro/arch/m68k/kernel/vmlinux-sun3.lds	2007-09-04 04:55:19.000000000 +0000
+++ linux-2.6.23-20071012/arch/m68k/kernel/vmlinux-sun3.lds	2007-10-12 13:53:22.000000000 +0000
@@ -41,6 +41,7 @@ __init_begin = .;
 		*(.init.text)
 		_einittext = .;
 	}
+	.init.str1 : { *(.init.str1) }
 	.init.data : { *(.init.data) }
 	. = ALIGN(16);
 	__setup_start = .;
@@ -78,6 +79,7 @@ __init_begin = .;
   /* Sections to be discarded */
   /DISCARD/ : {
 	*(.exit.text)
+	*(.exit.str1)
 	*(.exit.data)
 	*(.exitcall.exit)
 	}
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/m68knommu/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/m68knommu/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/m68knommu/kernel/vmlinux.lds.S	2007-07-10 04:55:30.000000000 +0000
+++ linux-2.6.23-20071012/arch/m68knommu/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -145,6 +145,7 @@ SECTIONS {
 		_sinittext = .;
 		*(.init.text)
 		_einittext = .;
+		*(.init.str1)
 		*(.init.data)
 		. = ALIGN(16);
 		__setup_start = .;
@@ -171,6 +172,7 @@ SECTIONS {
 
 	/DISCARD/ : {
 		*(.exit.text)
+		*(.exit.str1)
 		*(.exit.data)
 		*(.exitcall.exit)
 	}
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/mips/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/mips/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/mips/kernel/vmlinux.lds.S	2007-10-11 04:56:52.000000000 +0000
+++ linux-2.6.23-20071012/arch/mips/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -107,6 +107,9 @@ SECTIONS
 		*(.init.text)
 		_einittext = .;
 	}
+	.init.str1 : {
+		*(.init.str1)
+	}
 	.init.data : {
 		*(.init.data)
 	}
@@ -136,6 +139,9 @@ SECTIONS
 	.exit.text : {
 		*(.exit.text)
 	}
+	.exit.str1 : {
+		*(.exit.str1)
+	}
 	.exit.data : {
 		*(.exit.data)
 	}
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/parisc/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/parisc/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/parisc/kernel/vmlinux.lds.S	2007-09-04 04:55:20.000000000 +0000
+++ linux-2.6.23-20071012/arch/parisc/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -150,6 +150,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
   . = ALIGN(16);
   __setup_start = .;
@@ -176,6 +177,7 @@ SECTIONS
   /* .exit.text is discard at runtime, not link time, to deal with references
      from .altinstructions and .eh_frame */
   .exit.text : { *(.exit.text) }
+  .exit.str1 : { *(.exit.str1) }
   .exit.data : { *(.exit.data) }
 #ifdef CONFIG_BLK_DEV_INITRD
   . = ALIGN(ASM_PAGE_SIZE);
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/powerpc/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/powerpc/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/powerpc/kernel/vmlinux.lds.S	2007-09-04 04:55:20.000000000 +0000
+++ linux-2.6.23-20071012/arch/powerpc/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -23,6 +23,7 @@ SECTIONS
 	/* Sections to be discarded. */
 	/DISCARD/ : {
 	*(.exitcall.exit)
+	*(.exit.str1)
 	*(.exit.data)
 	}
 
@@ -84,6 +85,8 @@ SECTIONS
 	 */
 	.exit.text : { *(.exit.text) }
 
+	.init.str1 : { *(.init.str1) }
+
 	.init.data : {
 		*(.init.data);
 		__vtop_table_begin = .;
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/ppc/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/ppc/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/ppc/kernel/vmlinux.lds.S	2007-09-04 04:55:26.000000000 +0000
+++ linux-2.6.23-20071012/arch/ppc/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -101,6 +101,7 @@ SECTIONS
   /* .exit.text is discarded at runtime, not link time,
      to deal with references from __bug_table */
   .exit.text : { *(.exit.text) }
+  .init.str1 : { *(.init.str1) }
   .init.data : {
     *(.init.data);
     __vtop_table_begin = .;
@@ -162,6 +163,7 @@ SECTIONS
   /* Sections to be discarded. */
   /DISCARD/ : {
     *(.exitcall.exit)
+    *(.exit.str1)
     *(.exit.data)
   }
 }
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/s390/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/s390/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/s390/kernel/vmlinux.lds.S	2007-09-04 04:55:27.000000000 +0000
+++ linux-2.6.23-20071012/arch/s390/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -87,6 +87,7 @@ SECTIONS
    * to deal with references from __bug_table
    */
   .exit.text :	 { *(.exit.text) }
+  .init.str1 : { *(.init.str1) }
 
   .init.data : { *(.init.data) }
   . = ALIGN(256);
@@ -124,7 +125,7 @@ SECTIONS
 
   /* Sections to be discarded */
   /DISCARD/ : {
-	*(.exit.data) *(.exitcall.exit)
+	*(.exit.str1) *(.exit.data) *(.exitcall.exit)
 	}
 
   /* Stabs debugging sections.  */
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/sh/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/sh/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/sh/kernel/vmlinux.lds.S	2007-09-04 04:55:28.000000000 +0000
+++ linux-2.6.23-20071012/arch/sh/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -74,6 +74,7 @@ SECTIONS
   _sinittext = .;
   .init.text : { *(.init.text) }
   _einittext = .;
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
   . = ALIGN(16);
   __setup_start = .;
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/sh64/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/sh64/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/sh64/kernel/vmlinux.lds.S	2007-09-04 04:55:29.000000000 +0000
+++ linux-2.6.23-20071012/arch/sh64/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -105,6 +105,7 @@ SECTIONS
   _sinittext = .;
   .init.text : C_PHYS(.init.text) { *(.init.text) }
   _einittext = .;
+  .init.str1 : C_PHYS(.init.str1) { *(.init.str1) }
   .init.data : C_PHYS(.init.data) { *(.init.data) }
   . = ALIGN(L1_CACHE_BYTES);	/* Better if Cache Line aligned */
   __setup_start = .;
@@ -141,6 +142,7 @@ SECTIONS
   /* Sections to be discarded */
   /DISCARD/ : {
 	*(.exit.text)
+	*(.exit.str1)
 	*(.exit.data)
 	*(.exitcall.exit)
 	}
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/sparc/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/sparc/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/sparc/kernel/vmlinux.lds.S	2007-09-04 04:55:29.000000000 +0000
+++ linux-2.6.23-20071012/arch/sparc/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -45,6 +45,7 @@ SECTIONS
   }
   _einittext = .;
   __init_text_end = .;
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
   . = ALIGN(16);
   __setup_start = .;
@@ -83,7 +84,7 @@ SECTIONS
   }
   _end = . ;
   PROVIDE (end = .);
-  /DISCARD/ : { *(.exit.text) *(.exit.data) *(.exitcall.exit) }
+  /DISCARD/ : { *(.exit.text) *(.exit.str1) *(.exit.data) *(.exitcall.exit) }
 
   STABS_DEBUG
 
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/sparc64/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/sparc64/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/sparc64/kernel/vmlinux.lds.S	2007-09-04 04:55:30.000000000 +0000
+++ linux-2.6.23-20071012/arch/sparc64/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -54,6 +54,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
   .init.data : { *(.init.data) }
   . = ALIGN(16);
   __setup_start = .;
@@ -106,7 +107,7 @@ SECTIONS
   }
   _end = . ;
   PROVIDE (end = .);
-  /DISCARD/ : { *(.exit.text) *(.exit.data) *(.exitcall.exit) }
+  /DISCARD/ : { *(.exit.text) *(.exit.str1) *(.exit.data) *(.exitcall.exit) }
 
   STABS_DEBUG
 
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/um/kernel/dyn.lds.S linux-2.6.23-20071012/arch/um/kernel/dyn.lds.S
--- linux-2.6.23-20071012.macro/arch/um/kernel/dyn.lds.S	2007-09-04 04:55:30.000000000 +0000
+++ linux-2.6.23-20071012/arch/um/kernel/dyn.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -22,6 +22,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
 
   . = ALIGN(4096);
 
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/um/kernel/uml.lds.S linux-2.6.23-20071012/arch/um/kernel/uml.lds.S
--- linux-2.6.23-20071012.macro/arch/um/kernel/uml.lds.S	2007-09-04 04:55:30.000000000 +0000
+++ linux-2.6.23-20071012/arch/um/kernel/uml.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -33,6 +33,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : { *(.init.str1) }
   . = ALIGN(4096);
 
   .text      :
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/v850/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/v850/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/v850/kernel/vmlinux.lds.S	2007-07-10 04:55:50.000000000 +0000
+++ linux-2.6.23-20071012/arch/v850/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -99,6 +99,7 @@
 			*(.text.lock)					      \
 			*(.exitcall.exit)				      \
 		__real_etext = . ;	/* There may be data after here.  */  \
+			*(.exit.str1)					      \
 		RODATA_CONTENTS						      \
 		. = ALIGN (4) ;						      \
 		    	*(.call_table_data)				      \
@@ -159,6 +160,7 @@
 			__sinittext = .;				      \
 			*(.init.text)	/* 2.5 convention */		      \
 			__einittext = .;				      \
+			*(.init.str1)					      \
 			*(.init.data)					      \
 			*(.text.init)	/* 2.4 convention */		      \
 			*(.data.init)					      \
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/x86/kernel/vmlinux_32.lds.S linux-2.6.23-20071012/arch/x86/kernel/vmlinux_32.lds.S
--- linux-2.6.23-20071012.macro/arch/x86/kernel/vmlinux_32.lds.S	2007-10-12 02:56:54.000000000 +0000
+++ linux-2.6.23-20071012/arch/x86/kernel/vmlinux_32.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -134,6 +134,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : AT(ADDR(.init.str1) - LOAD_OFFSET) { *(.init.str1) }
   .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
   . = ALIGN(16);
   .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
@@ -170,6 +171,7 @@ SECTIONS
   /* .exit.text is discard at runtime, not link time, to deal with references
      from .altinstructions and .eh_frame */
   .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
+  .exit.str1 : AT(ADDR(.exit.str1) - LOAD_OFFSET) { *(.exit.str1) }
   .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
 #if defined(CONFIG_BLK_DEV_INITRD)
   . = ALIGN(4096);
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/x86/kernel/vmlinux_64.lds.S linux-2.6.23-20071012/arch/x86/kernel/vmlinux_64.lds.S
--- linux-2.6.23-20071012.macro/arch/x86/kernel/vmlinux_64.lds.S	2007-10-12 02:56:54.000000000 +0000
+++ linux-2.6.23-20071012/arch/x86/kernel/vmlinux_64.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -158,6 +158,7 @@ SECTIONS
 	*(.init.text)
 	_einittext = .;
   }
+  .init.str1 : AT(ADDR(.init.str1) - LOAD_OFFSET) { *(.init.str1) }
   __initdata_begin = .;
   .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
   __initdata_end = .;
@@ -188,6 +189,7 @@ SECTIONS
   /* .exit.text is discard at runtime, not link time, to deal with references
      from .altinstructions and .eh_frame */
   .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
+  .exit.str1 : AT(ADDR(.exit.str1) - LOAD_OFFSET) { *(.exit.str1) }
   .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
 
 /* vdso blob that is mapped into user space */
diff -up --recursive --new-file linux-2.6.23-20071012.macro/arch/xtensa/kernel/vmlinux.lds.S linux-2.6.23-20071012/arch/xtensa/kernel/vmlinux.lds.S
--- linux-2.6.23-20071012.macro/arch/xtensa/kernel/vmlinux.lds.S	2007-09-04 04:55:30.000000000 +0000
+++ linux-2.6.23-20071012/arch/xtensa/kernel/vmlinux.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -140,6 +140,8 @@ SECTIONS
 	_einittext = .;
   }
 
+  .init.str1 : { *(.init.str1) }
+
   .init.data :
   {
     *(.init.data)
@@ -279,6 +281,7 @@ SECTIONS
   /DISCARD/ :
   {
   	*(.exit.literal .exit.text)
+	*(.exit.str1)
   	*(.exit.data)
         *(.exitcall.exit)
   }
diff -up --recursive --new-file linux-2.6.23-20071012.macro/include/asm-um/common.lds.S linux-2.6.23-20071012/include/asm-um/common.lds.S
--- linux-2.6.23-20071012.macro/include/asm-um/common.lds.S	2007-09-04 04:56:18.000000000 +0000
+++ linux-2.6.23-20071012/include/asm-um/common.lds.S	2007-10-12 13:53:22.000000000 +0000
@@ -98,6 +98,7 @@
   /* .exit.text is discard at runtime, not link time, to deal with references
      from .altinstructions and .eh_frame */
   .exit.text : { *(.exit.text) }
+  .exit.str1 : { *(.exit.str1) }
   .exit.data : { *(.exit.data) }
 
   .preinit_array : {
diff -up --recursive --new-file linux-2.6.23-20071012.macro/include/linux/init.h linux-2.6.23-20071012/include/linux/init.h
--- linux-2.6.23-20071012.macro/include/linux/init.h	2007-10-12 02:56:54.000000000 +0000
+++ linux-2.6.23-20071012/include/linux/init.h	2007-10-12 13:53:22.000000000 +0000
@@ -36,6 +36,20 @@
  * section.
  * 
  * Also note, that this data cannot be "const".
+ *
+ * For strings:
+ * Use __initstr, __exitstr like __initdata:
+ *
+ * static const char welcome[] __initstr = "Hello World!\n";
+ * static const char goodbye[] __exitstr = "Farewell then.\n";
+ *
+ * but also:
+ *
+ * pr_info(_i("%s: Thanks for selecting, will do my best\n"), dev->name);
+ * pr_info(_e("%s: Hope to be of use again soon\n"), dev->name);
+ *
+ * Note that strings have to be "const" and they are put in mergeable
+ * sections which means the linker will do nasty things to them. ;-)
  */
 
 /* These are for everybody (although not all archs will actually
@@ -45,6 +59,24 @@
 #define __exitdata	__attribute__ ((__section__(".exit.data")))
 #define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
 
+#define __initstr	__attribute__((__section__(".init.str1" __strflags)))
+#define __exitstr	__attribute__((__section__(".exit.str1" __strflags)))
+
+#define _i(str)								\
+({									\
+	static const char __istr[] __initstr = (str);			\
+	__istr;								\
+})
+#define _e(str)								\
+({									\
+	static const char __estr[] __exitstr = (str);			\
+	__istr;								\
+})
+
+/* Internal implementation detail for the above; just disregard. ;-)  */
+#define __strflags	",\"aMS\",@progbits,1\n"			\
+			"# Useless section flags supplied by GCC follow: "
+
 /* 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).
@@ -247,46 +279,74 @@ void __init parse_early_param(void);
 #ifdef CONFIG_MODULES
 #define __init_or_module
 #define __initdata_or_module
+#define __initstr_or_module
+#define _iom(str) (str)
 #else
 #define __init_or_module __init
 #define __initdata_or_module __initdata
+#define __initstr_or_module __initstr
+#define _iom(str) _i(str)
 #endif /*CONFIG_MODULES*/
 
 #ifdef CONFIG_HOTPLUG
 #define __devinit
 #define __devinitdata
+#define __devinitstr
+#define _di(str) (str)
 #define __devexit
 #define __devexitdata
+#define __devexitstr
+#define _de(str) (str)
 #else
 #define __devinit __init
 #define __devinitdata __initdata
+#define __devinitstr __initstr
+#define _di(str) _i(str)
 #define __devexit __exit
 #define __devexitdata __exitdata
+#define __devexitstr __exitstr
+#define _de(str) _e(str)
 #endif
 
 #ifdef CONFIG_HOTPLUG_CPU
 #define __cpuinit
 #define __cpuinitdata
+#define __cpuinitstr
+#define _ci(str) (str)
 #define __cpuexit
 #define __cpuexitdata
+#define __cpuexitstr
+#define _ce(str) (str)
 #else
 #define __cpuinit	__init
 #define __cpuinitdata __initdata
+#define __cpuinitstr __initstr
+#define _ci(str) _i(str)
 #define __cpuexit __exit
 #define __cpuexitdata	__exitdata
+#define __cpuexitstr __exitstr
+#define _ce(str) _e(str)
 #endif
 
 #if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \
 	|| defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)
 #define __meminit
 #define __meminitdata
+#define __meminitstr
+#define _mi(str) (str)
 #define __memexit
 #define __memexitdata
+#define __memexitstr
+#define _me(str) (str)
 #else
 #define __meminit	__init
 #define __meminitdata __initdata
+#define __meminitstr __initstr
+#define _mi(str) _i(str)
 #define __memexit __exit
 #define __memexitdata	__exitdata
+#define __memexitstr __exitstr
+#define _me(str) _e(str)
 #endif
 
 /* Functions marked as __devexit may be discarded at kernel link time, depending

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-12 16:50 [PATCH] Discardable strings for init and exit sections Maciej W. Rozycki
@ 2007-10-12 17:19 ` Adrian Bunk
  2007-10-12 17:52   ` Ralf Baechle
  2007-10-12 17:45 ` Sam Ravnborg
  1 sibling, 1 reply; 10+ messages in thread
From: Adrian Bunk @ 2007-10-12 17:19 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Franck Bui-Huu, Ralf Baechle, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Fri, Oct 12, 2007 at 05:50:01PM +0100, Maciej W. Rozycki wrote:

>  We currently have infrastructure for discardable text and data, but no 
> such thing for strings.  This is especially notable for inline strings 
> such as ones used by printk() which are left behind resident in the memory 
> throughout the life of the system even though code referring to them has 
> been removed.
> 
>  Following a short discussion at the linux-mips list, here is a proposed 
> implementation for discardable strings.  It adds __initstr and __exitstr 
> plus most of the usual variations, but most importantly it adds wrapper 
> macros that may be used for inline strings that make them be put in
> separate sections which may then be discarded, while still preserving the 
> usual merging property of sections containing strings.  The macros are 
> called _i() and _e(), with the other alternatives adding at most two 
> letters each.  This has been inspired by how the GNU gettext handles 
> localised strings in a way that does not add too much clutter and the 
> result is still reasonably well readable.  Some use examples have been 
> included in <linux/init.h>.
>...

I have an objection against this approach:

Our __*init*/__*exit* annotations are already a constant source of bugs, 
and adding more pifalls (e.g. forgotten removal of _i()/_e() when a 
function is no longer __*init*/__*exit*) doesn't sound like a good plan.

Shouldn't it be possible to automatically determine where to put the 
strings? I don't know enough gcc/ld voodoo for being able to tell 
whether it is currently possible, and if yes how, but doing it 
automatically sounds like the only solution that wouldn't result in an
unmaintainable mess.

Ideally, even the current annotations might one day no longer be 
required and replaced with some way to express things like "everything 
only required by module_init() can be __init".

cu
Adrian

BTW: Please add diffstat output when sending patches.

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-12 16:50 [PATCH] Discardable strings for init and exit sections Maciej W. Rozycki
  2007-10-12 17:19 ` Adrian Bunk
@ 2007-10-12 17:45 ` Sam Ravnborg
  2007-10-23 17:23   ` Maciej W. Rozycki
  1 sibling, 1 reply; 10+ messages in thread
From: Sam Ravnborg @ 2007-10-12 17:45 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Franck Bui-Huu, Ralf Baechle, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Fri, Oct 12, 2007 at 05:50:01PM +0100, Maciej W. Rozycki wrote:
>  We currently have infrastructure for discardable text and data, but no 
> such thing for strings.  This is especially notable for inline strings 
> such as ones used by printk() which are left behind resident in the memory 
> throughout the life of the system even though code referring to them has 
> been removed.

What is the actual benefit here expressed in real numbers?
For the __init/__exit notation that is yet only partially correct
we often see corner cases where one ask if it is really worth it.
Adding the discard functionality for strings seems like a logical extension
but there is a benefit/pain ratio to consider.

So real numbers please.

A few general notes to the patch.
1) We want to consolidate this in include/asm-generic/vmlinux*
somehow and this should be doen as a separate step.
2) If we introduce discardable strings then we shall in parallel
add build time checks so we catch strings marked as discardable
which is used outside a discardable compatible function.

	Sam

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-12 17:19 ` Adrian Bunk
@ 2007-10-12 17:52   ` Ralf Baechle
  2007-10-12 18:15     ` Adrian Bunk
  0 siblings, 1 reply; 10+ messages in thread
From: Ralf Baechle @ 2007-10-12 17:52 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Maciej W. Rozycki, Franck Bui-Huu, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Fri, Oct 12, 2007 at 07:19:38PM +0200, Adrian Bunk wrote:

> I have an objection against this approach:
> 
> Our __*init*/__*exit* annotations are already a constant source of bugs, 
> and adding more pifalls (e.g. forgotten removal of _i()/_e() when a 
> function is no longer __*init*/__*exit*) doesn't sound like a good plan.
> 
> Shouldn't it be possible to automatically determine where to put the 
> strings? I don't know enough gcc/ld voodoo for being able to tell 
> whether it is currently possible, and if yes how, but doing it 
> automatically sounds like the only solution that wouldn't result in an
> unmaintainable mess.

gcc tends to place data such as strings or jump tables generated from
switches not into a place were it would be easily discardable.  The
latter is the reason that on MIPS we can't discard __exit functions
at all - a switch table in .rodata might be referencing discarded code
in .exit.text which makes ld fail.  When I discussed this with some gcc
people a while ago nobody really had a good suggestion to solve this.

  Ralf

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-12 17:52   ` Ralf Baechle
@ 2007-10-12 18:15     ` Adrian Bunk
  2007-10-23 16:57       ` Maciej W. Rozycki
  0 siblings, 1 reply; 10+ messages in thread
From: Adrian Bunk @ 2007-10-12 18:15 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Maciej W. Rozycki, Franck Bui-Huu, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Fri, Oct 12, 2007 at 06:52:10PM +0100, Ralf Baechle wrote:
> On Fri, Oct 12, 2007 at 07:19:38PM +0200, Adrian Bunk wrote:
> 
> > I have an objection against this approach:
> > 
> > Our __*init*/__*exit* annotations are already a constant source of bugs, 
> > and adding more pifalls (e.g. forgotten removal of _i()/_e() when a 
> > function is no longer __*init*/__*exit*) doesn't sound like a good plan.
> > 
> > Shouldn't it be possible to automatically determine where to put the 
> > strings? I don't know enough gcc/ld voodoo for being able to tell 
> > whether it is currently possible, and if yes how, but doing it 
> > automatically sounds like the only solution that wouldn't result in an
> > unmaintainable mess.
> 
> gcc tends to place data such as strings or jump tables generated from
> switches not into a place were it would be easily discardable.  The
> latter is the reason that on MIPS we can't discard __exit functions
> at all - a switch table in .rodata might be referencing discarded code
> in .exit.text which makes ld fail.  When I discussed this with some gcc
> people a while ago nobody really had a good suggestion to solve this.

- Most of the string annotations are (naturally) dev{init,exit}
  annotations, and bugs there are therefore in configurations that have
  only extremely low testing coverage during -rc.
- I'm counting 22 annotations in the driver Maciej converted as an
  example. When estimating the number of possible annotations based
  on the number of C files in the kernel I'm getting a six digit
  number.

No matter how hard it would be to teach gcc about it, when thinking of 
the amount of __*init*/__*exit* bugs we already have I simply can't 
imagine the string annotations as a maintainable solution.

>   Ralf

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-12 18:15     ` Adrian Bunk
@ 2007-10-23 16:57       ` Maciej W. Rozycki
  2007-10-23 17:12         ` Adrian Bunk
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2007-10-23 16:57 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Ralf Baechle, Franck Bui-Huu, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Fri, 12 Oct 2007, Adrian Bunk wrote:

> - Most of the string annotations are (naturally) dev{init,exit}
>   annotations, and bugs there are therefore in configurations that have
>   only extremely low testing coverage during -rc.
> - I'm counting 22 annotations in the driver Maciej converted as an
>   example. When estimating the number of possible annotations based
>   on the number of C files in the kernel I'm getting a six digit
>   number.
> 
> No matter how hard it would be to teach gcc about it, when thinking of 
> the amount of __*init*/__*exit* bugs we already have I simply can't 
> imagine the string annotations as a maintainable solution.

 Well, it is up to the maintainer of code in question to get it right if 
interested.  Otherwise having no annotation and leaving the relevant 
strings resident in the memory throughout the lifespan of the system is a 
valid and perfectly working option.

 If you worry about the reverse case, where an annotation should be 
removed because the containing function is no longer __*init*/__*exit*, 
then I think `modpost' does a reasonably good job finding such places.

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-23 16:57       ` Maciej W. Rozycki
@ 2007-10-23 17:12         ` Adrian Bunk
  2007-10-23 17:25           ` Sam Ravnborg
  0 siblings, 1 reply; 10+ messages in thread
From: Adrian Bunk @ 2007-10-23 17:12 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Ralf Baechle, Franck Bui-Huu, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Tue, Oct 23, 2007 at 05:57:38PM +0100, Maciej W. Rozycki wrote:
> On Fri, 12 Oct 2007, Adrian Bunk wrote:
> 
> > - Most of the string annotations are (naturally) dev{init,exit}
> >   annotations, and bugs there are therefore in configurations that have
> >   only extremely low testing coverage during -rc.
> > - I'm counting 22 annotations in the driver Maciej converted as an
> >   example. When estimating the number of possible annotations based
> >   on the number of C files in the kernel I'm getting a six digit
> >   number.
> > 
> > No matter how hard it would be to teach gcc about it, when thinking of 
> > the amount of __*init*/__*exit* bugs we already have I simply can't 
> > imagine the string annotations as a maintainable solution.
> 
>  Well, it is up to the maintainer of code in question to get it right if 
> interested.  Otherwise having no annotation and leaving the relevant 
> strings resident in the memory throughout the lifespan of the system is a 
> valid and perfectly working option.

If we want to go this route users may want to have this for all code 
they are using. This is not a per-maintainer question, that's a global 
thing: If janitors start annotating all source files in the kernel the 
resulting patches can't be accepted or rejected only based on the 
personal preferences of the maintainers.

>  If you worry about the reverse case, where an annotation should be 
> removed because the containing function is no longer __*init*/__*exit*, 
> then I think `modpost' does a reasonably good job finding such places.

As long as the modpost warnings are just warnings they will often be 
missed at compile time.

And most of the annotations (also in the driver you converted as an 
example) will be dev{init,exit} annotations, and bugs there are in 
configurations virtually noone tests during -rc

>   Maciej

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-12 17:45 ` Sam Ravnborg
@ 2007-10-23 17:23   ` Maciej W. Rozycki
  2007-10-23 17:27     ` Sam Ravnborg
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej W. Rozycki @ 2007-10-23 17:23 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Franck Bui-Huu, Ralf Baechle, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

On Fri, 12 Oct 2007, Sam Ravnborg wrote:

> What is the actual benefit here expressed in real numbers?
> For the __init/__exit notation that is yet only partially correct
> we often see corner cases where one ask if it is really worth it.
> Adding the discard functionality for strings seems like a logical extension
> but there is a benefit/pain ratio to consider.
> 
> So real numbers please.

 I have quoted some -- if you need more (I have left out all the 
non-allocatable sections for clarity):

$ mipsel-linux-readelf -S drivers/net/defxx.o
There are 26 section headers, starting at offset 0x3484:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 1] .text             PROGBITS        00000000 000040 0022a0 00  AX  0   0 16
  [ 3] .data             PROGBITS        00000000 0022e0 0000f0 00  WA  0   0 16
  [ 5] .bss              NOBITS          00000000 0023d0 000010 00  WA  0   0 16
  [ 6] .reginfo          MIPS_REGINFO    00000000 0023d0 000018 18   A  0   0  4
  [10] .exit.text        PROGBITS        00000000 002748 0000ec 00  AX  0   0  4
  [12] .init.text        PROGBITS        00000000 002834 000460 00  AX  0   0  4
  [14] .rodata.str1.4    PROGBITS        00000000 002c94 0004a4 01 AMS  0   0  4
  [15] .rodata           PROGBITS        00000000 003140 000080 00   A  0   0 16
  [17] .exitcall.exit    PROGBITS        00000000 0031c0 000004 00  WA  0   0  4
  [19] .initcall6.init   PROGBITS        00000000 0031c4 000004 00  WA  0   0  4
  [21] .init.str1        PROGBITS        00000000 0031c8 0001e0 01 AMS  0   0  4
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

So with a quick calculation (`size' unfortunately gives confusing 
numbers): text is 10220 (init 1120, exit 236), data is 2044 and bss is 16 
bytes.  What you gain with this change is the space occupied by the 
.init.str1 section, worth 480 bytes, which would otherwise be resident.

> 1) We want to consolidate this in include/asm-generic/vmlinux*
> somehow and this should be doen as a separate step.

 Arguably all the existing linker scripts should be made more consistent I 
suppose.  Currently all the {init,exit} annotations are handled separately 
by each architecture, so this would be no exception.  If you have a 
proposal as to how to do it cleanly, people will certainly appreciate it.

> 2) If we introduce discardable strings then we shall in parallel
> add build time checks so we catch strings marked as discardable
> which is used outside a discardable compatible function.

 Well, `modpost' should already be taking care of this -- __init_begin and 
__init_end are defined for this purpose.

  Maciej

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-23 17:12         ` Adrian Bunk
@ 2007-10-23 17:25           ` Sam Ravnborg
  0 siblings, 0 replies; 10+ messages in thread
From: Sam Ravnborg @ 2007-10-23 17:25 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Maciej W. Rozycki, Ralf Baechle, Franck Bui-Huu, linux-arch,
	linux-mips, Andrew Morton, linux-kernel

> 
> As long as the modpost warnings are just warnings they will often be 
> missed at compile time.

The plans for the modpost warnings are more or less:
- Let all __init, __cpuinit, __meminit etc use dedicated sections
no matter the actual configuration.
Use ifdeffery in the .lds files to place stuff in the correct final
section.
Teach modpost about the illegal dependencies.

When we then are back to almost warning free with allmodconfig for
the most important platfroms (read: or in reality the ones I have a
tool-chain for and which care to make allmodconfig buildable in mainline)
then modpost will generate errors instead of warnings to force people
to fix all the NEW errors they introuduce.

A variable will convert the errors to warnings for use in certain situations.

But I am not familiar enough with ELF format to extend the current checking
as suggested by people a few times. Maybe someone else can assist here.

Comments?

	Sam

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Discardable strings for init and exit sections
  2007-10-23 17:23   ` Maciej W. Rozycki
@ 2007-10-23 17:27     ` Sam Ravnborg
  0 siblings, 0 replies; 10+ messages in thread
From: Sam Ravnborg @ 2007-10-23 17:27 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: Franck Bui-Huu, Ralf Baechle, linux-arch, linux-mips,
	Andrew Morton, linux-kernel

> 
>  Arguably all the existing linker scripts should be made more consistent I 
> suppose.  Currently all the {init,exit} annotations are handled separately 
> by each architecture, so this would be no exception.  If you have a 
> proposal as to how to do it cleanly, people will certainly appreciate it.

Patches appreciated. I have made many of the linekr scripts use same
format now - so it is easier to see what is equal and can be consolidated.

	Sam

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-10-23 17:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-12 16:50 [PATCH] Discardable strings for init and exit sections Maciej W. Rozycki
2007-10-12 17:19 ` Adrian Bunk
2007-10-12 17:52   ` Ralf Baechle
2007-10-12 18:15     ` Adrian Bunk
2007-10-23 16:57       ` Maciej W. Rozycki
2007-10-23 17:12         ` Adrian Bunk
2007-10-23 17:25           ` Sam Ravnborg
2007-10-12 17:45 ` Sam Ravnborg
2007-10-23 17:23   ` Maciej W. Rozycki
2007-10-23 17:27     ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).