From: Arjan van de Ven Generic prep-work for marking the .rodata section readonly: * Align the rodata section at 4Kb boundary * call the mark_rodata_ro() function when available Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Cc: Andi Kleen Signed-off-by: Andrew Morton --- include/asm-generic/vmlinux.lds.h | 4 ++++ init/main.c | 4 ++++ 2 files changed, 8 insertions(+) diff -puN include/asm-generic/vmlinux.lds.h~mark-rodata-section-read-only-generic-infrastructure include/asm-generic/vmlinux.lds.h --- devel/include/asm-generic/vmlinux.lds.h~mark-rodata-section-read-only-generic-infrastructure 2005-11-10 02:19:37.000000000 -0800 +++ devel-akpm/include/asm-generic/vmlinux.lds.h 2005-11-10 02:19:37.000000000 -0800 @@ -10,6 +10,8 @@ #define ALIGN_FUNCTION() . = ALIGN(8) #define RODATA \ + . = ALIGN(4096); \ + __start_rodata = .; \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ *(.rodata) *(.rodata.*) \ *(__vermagic) /* Kernel version magic */ \ @@ -74,6 +76,8 @@ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ *(__ksymtab_strings) \ } \ + __end_rodata = .; \ + . = ALIGN(4096); \ \ /* Built-in module parameters. */ \ __param : AT(ADDR(__param) - LOAD_OFFSET) { \ diff -puN init/main.c~mark-rodata-section-read-only-generic-infrastructure init/main.c --- devel/init/main.c~mark-rodata-section-read-only-generic-infrastructure 2005-11-10 02:19:37.000000000 -0800 +++ devel-akpm/init/main.c 2005-11-10 02:19:37.000000000 -0800 @@ -100,6 +100,9 @@ extern void acpi_early_init(void); #else static inline void acpi_early_init(void) { } #endif +#ifndef CONFIG_DEBUG_RODATA +inline void mark_rodata_ro(void) { } +#endif #ifdef CONFIG_TC extern void tc_init(void); @@ -712,6 +715,7 @@ static int init(void * unused) */ free_initmem(); unlock_kernel(); + mark_rodata_ro(); system_state = SYSTEM_RUNNING; numa_default_policy(); _