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. :^)
This commit is contained in:
Timon Kruiper 2022-05-09 10:54:54 +02:00 committed by Linus Groh
parent a1b352fdc0
commit d449fef606
Notes: sideshowbarker 2024-07-17 11:07:33 +09:00

View File

@ -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.