Skip to content

Commit 0452abf

Browse files
committed
Kernel: Assert that MAXPAGESIZE == 4K in all linker scripts
All of these linker scripts assume 4K pages. If these linker scripts would be used with MAXPAGESIZE > 4K, the sections would not be aligned correctly.
1 parent 4efb4e2 commit 0452abf

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

Kernel/Arch/aarch64/linker.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
ENTRY(init)
22

3+
ASSERT(CONSTANT(MAXPAGESIZE) == 4K, "The aarch64 Kernel linker script assumes a max page size of 4K");
4+
35
#define PF_X 0x1
46
#define PF_W 0x2
57
#define PF_R 0x4

Kernel/Arch/riscv64/linker.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
ENTRY(init)
88

9+
ASSERT(CONSTANT(MAXPAGESIZE) == 4K, "The riscv64 Kernel linker script assumes a max page size of 4K");
10+
911
#define PF_X 0x1
1012
#define PF_W 0x2
1113
#define PF_R 0x4

Kernel/Arch/x86_64/linker.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
ENTRY(init)
22

3+
ASSERT(CONSTANT(MAXPAGESIZE) == 4K, "The x86_64 Kernel linker script assumes a max page size of 4K");
4+
35
#define PF_X 0x1
46
#define PF_W 0x2
57
#define PF_R 0x4

Kernel/EFIPrekernel/linker.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
ENTRY(init)
22

3+
ASSERT(CONSTANT(MAXPAGESIZE) == 4K, "The EFIPrekernel linker script only supports a max page size of 4K, as the UEFI spec requires 4K pages.");
4+
35
SECTIONS
46
{
57
/* This is symbol is used to tell the PrekernelPEImageGenerator that the PE base address is 0 */

Kernel/Prekernel/linker.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
ENTRY(start)
22

3+
ASSERT(CONSTANT(MAXPAGESIZE) == 4K, "The Prekernel linker script assumes a max page size of 4K");
4+
35
PHDRS
46
{
57
boot_text PT_LOAD ;

0 commit comments

Comments
 (0)