mirror of
https://github.com/opnsense/src.git
synced 2026-06-12 02:00:31 -04:00
When building a 4k page kernel we use 2M blocks to map the kernel contents. As the .text section may not end on a 2M aligned address we need to split one block into level 3 pages and pad the end of the section to an appropriate boundary. With both these changes we can then mapjust the code as executable. While here also map it as read-only as none ofthis shouldbe written to directly. Reviewed by: alc Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45064
167 lines
4.4 KiB
Text
167 lines
4.4 KiB
Text
OUTPUT_ARCH(aarch64)
|
|
ENTRY(_start)
|
|
|
|
SEARCH_DIR(/usr/lib);
|
|
SECTIONS
|
|
{
|
|
/* Read-only sections, merged into text segment: */
|
|
. = text_start; /* This is set using --defsym= on the command line. */
|
|
.vmm_vectors : { *(.vmm_vectors) }
|
|
.text :
|
|
{
|
|
*(.text)
|
|
*(.stub)
|
|
/* .gnu.warning sections are handled specially by elf32.em. */
|
|
*(.gnu.warning)
|
|
*(.gnu.linkonce.t*)
|
|
} =0x9090
|
|
/*
|
|
* Align to the the largest page size the kernel could be built for.
|
|
* If we don't then building page tables in locore.S could fail as it
|
|
* assumes the .text section is on a different page to later sections.
|
|
*/
|
|
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
|
_etext = .;
|
|
PROVIDE (etext = .);
|
|
|
|
.fini : { *(.fini) } =0x9090
|
|
.rodata : { *(.rodata*) *(.gnu.linkonce.r*) }
|
|
.rodata1 : { *(.rodata1) }
|
|
.interp : { *(.interp) }
|
|
.hash : { *(.hash) }
|
|
.dynsym : { *(.dynsym) }
|
|
.dynstr : { *(.dynstr) }
|
|
.gnu.version : { *(.gnu.version) }
|
|
.gnu.version_d : { *(.gnu.version_d) }
|
|
.gnu.version_r : { *(.gnu.version_r) }
|
|
.note.gnu.build-id : {
|
|
PROVIDE (__build_id_start = .);
|
|
*(.note.gnu.build-id)
|
|
PROVIDE (__build_id_end = .);
|
|
}
|
|
.rel.text :
|
|
{ *(.rel.text) *(.rel.gnu.linkonce.t*) }
|
|
.rela.text :
|
|
{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
|
|
.rel.data :
|
|
{ *(.rel.data) *(.rel.gnu.linkonce.d*) }
|
|
.rela.data :
|
|
{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
|
|
.rel.rodata :
|
|
{ *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
|
|
.rela.rodata :
|
|
{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
|
|
.rel.got : { *(.rel.got) }
|
|
.rela.got : { *(.rela.got) }
|
|
.rel.ctors : { *(.rel.ctors) }
|
|
.rela.ctors : { *(.rela.ctors) }
|
|
.rel.dtors : { *(.rel.dtors) }
|
|
.rela.dtors : { *(.rela.dtors) }
|
|
.rel.init : { *(.rel.init) }
|
|
.rela.init : { *(.rela.init) }
|
|
.rel.fini : { *(.rel.fini) }
|
|
.rela.fini : { *(.rela.fini) }
|
|
.rel.bss : { *(.rel.bss) }
|
|
.rela.bss : { *(.rela.bss) }
|
|
.rel.plt : { *(.rel.plt) }
|
|
.rela.plt : { *(.rela.plt) }
|
|
.init : { *(.init) } =0x9090
|
|
.plt : { *(.plt) }
|
|
|
|
. = ALIGN(4);
|
|
_extab_start = .;
|
|
PROVIDE(extab_start = .);
|
|
.ARM.extab : { *(.ARM.extab) }
|
|
_extab.end = .;
|
|
PROVIDE(extab_end = .);
|
|
|
|
_exidx_start = .;
|
|
PROVIDE(exidx_start = .);
|
|
.ARM.exidx : { *(.ARM.exidx) }
|
|
_exidx_end = .;
|
|
PROVIDE(exidx_end = .);
|
|
|
|
/* Adjust the address for the data segment. We want to adjust up to
|
|
the same address within the page on the next page up. */
|
|
. = ALIGN(0x1000) + (. & (0x1000 - 1)) ;
|
|
.data :
|
|
{
|
|
*(.data)
|
|
*(.gnu.linkonce.d*)
|
|
}
|
|
. = ALIGN(128);
|
|
.data.read_frequently :
|
|
{
|
|
*(SORT_BY_ALIGNMENT(.data.read_frequently))
|
|
}
|
|
.data.read_mostly :
|
|
{
|
|
*(.data.read_mostly)
|
|
}
|
|
. = ALIGN(128);
|
|
.data.exclusive_cache_line :
|
|
{
|
|
*(.data.exclusive_cache_line)
|
|
}
|
|
. = ALIGN(128);
|
|
.data1 : { *(.data1) }
|
|
. = ALIGN(32 / 8);
|
|
.init_array :
|
|
{
|
|
PROVIDE_HIDDEN (__init_array_start = .);
|
|
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
|
|
KEEP (*(.init_array))
|
|
PROVIDE_HIDDEN (__init_array_end = .);
|
|
}
|
|
.fini_array :
|
|
{
|
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
|
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
|
|
KEEP (*(.fini_array))
|
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
|
}
|
|
_start_ctors = .;
|
|
PROVIDE (start_ctors = .);
|
|
.ctors :
|
|
{
|
|
*(.ctors)
|
|
}
|
|
_stop_ctors = .;
|
|
PROVIDE (stop_ctors = .);
|
|
.dtors :
|
|
{
|
|
*(.dtors)
|
|
}
|
|
.got : { *(.got.plt) *(.got) }
|
|
.dynamic : { *(.dynamic) }
|
|
/* We want the small data sections together, so single-instruction offsets
|
|
can access them all, and initialized data all before uninitialized, so
|
|
we can shorten the on-disk segment size. */
|
|
. = ALIGN(8);
|
|
.sdata : { *(.sdata) }
|
|
_edata = .;
|
|
PROVIDE (edata = .);
|
|
. = ALIGN(16);
|
|
__bss_start = .;
|
|
.sbss : { *(.sbss) *(.scommon) }
|
|
.bss :
|
|
{
|
|
*(.dynbss)
|
|
*(.bss)
|
|
*(COMMON)
|
|
. = ALIGN(16);
|
|
__bss_end = .;
|
|
/* A section for the initial page table, it doesn't need to be in the
|
|
kernel file, however unlike normal .bss entries should not be zeroed
|
|
out as we use it before the .bss section is cleared. */
|
|
*(.init_pagetable)
|
|
}
|
|
_end = . ;
|
|
PROVIDE (end = .);
|
|
|
|
/* Debug */
|
|
INCLUDE debuginfo.ldscript
|
|
|
|
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
|
|
/DISCARD/ : { *(.note.GNU-stack) }
|
|
}
|