From fe468b476d567b6aa0695a030c408ccf46278c7d Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 2 Apr 2021 19:04:34 +0200 Subject: Mapped .text and .rodata readonly --- kernel/link.ld | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'kernel/link.ld') diff --git a/kernel/link.ld b/kernel/link.ld index fbe8a8c..c3b59b3 100644 --- a/kernel/link.ld +++ b/kernel/link.ld @@ -5,27 +5,31 @@ phys = 0x00009000; SECTIONS { - .text phys : AT(phys) { - kernel_start = .; - code = .; + . = phys; + + kernel_ro_start = .; + .text BLOCK(4K) : ALIGN(4K) + { *(.text) + } + + .rodata BLOCK(4K) : ALIGN(4K) + { *(.rodata) - . = ALIGN(4096); } + kernel_ro_end = .; + - .data : AT(phys + (data - code)) + kernel_rw_start = .; + .data BLOCK(4K) : ALIGN(4K) { - data = .; *(.data) - . = ALIGN(4096); } - .bss : AT(phys + (bss - code)) + .bss BLOCK(4K) : ALIGN(4K) { - bss = .; + *(COMMON) *(.bss) - . = ALIGN(4096); } - - kernel_end = .; + kernel_rw_end = .; } -- cgit v1.2.3