From d449fef606d67b0a8f4d997ac58f8b0039fa384c Mon Sep 17 00:00:00 2001 From: Timon Kruiper Date: Mon, 9 May 2022 10:54:54 +0200 Subject: [PATCH] Kernel: Reorder sections in aarch64 linker script to save space By putting the NOLOAD sections (.bss and .super_pages) at the end of the ELF file, objcopy does not have to insert a lot of zeros to make sure that the .ksyms section is at the right place in memory. Now the .ksyms section comes before the two NOLOAD sections. This shrinks the kernel8.img with 6MB, from 8.3M to 2.3M. :^) --- Kernel/Arch/aarch64/linker.ld | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Kernel/Arch/aarch64/linker.ld b/Kernel/Arch/aarch64/linker.ld index 2fc3a52885..9dd1e8d401 100644 --- a/Kernel/Arch/aarch64/linker.ld +++ b/Kernel/Arch/aarch64/linker.ld @@ -5,9 +5,9 @@ PHDRS { text PT_LOAD ; data PT_LOAD ; + ksyms PT_LOAD ; bss PT_LOAD ; super_pages PT_LOAD ; - ksyms PT_LOAD ; } SECTIONS @@ -34,6 +34,13 @@ SECTIONS *(.data*) } :data + .ksyms ALIGN(4K) : AT (ADDR(.ksyms)) + { + start_of_kernel_ksyms = .; + *(.kernel_symbols) + end_of_kernel_ksyms = .; + } :ksyms + .bss ALIGN(4K) (NOLOAD) : AT (ADDR(.bss)) { start_of_bss = .; @@ -49,13 +56,6 @@ SECTIONS *(.super_pages) } :super_pages - .ksyms ALIGN(4K) : AT (ADDR(.ksyms)) - { - start_of_kernel_ksyms = .; - *(.kernel_symbols) - end_of_kernel_ksyms = .; - } :ksyms - /* FIXME: 8MB is enough space for all of the tables required to identity map physical memory. 8M is wasteful, so this should be properly calculated.