From 2695dcf2b0cd22407a92103a4e89653c5883fee8 Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Fri, 22 Sep 2023 21:37:13 -0400 Subject: [PATCH] Reorganize the kernel binary to support loading a non-stripped kernel. --- sys/amd64/kernel.lds | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/sys/amd64/kernel.lds b/sys/amd64/kernel.lds index 717030b..5a71f5f 100644 --- a/sys/amd64/kernel.lds +++ b/sys/amd64/kernel.lds @@ -10,6 +10,30 @@ SECTIONS PROVIDE (__executable_start = SEGMENT_START("text-segment", 0xFFFF800000400000)); . = SEGMENT_START("text-segment", 0xFFFF800000400000) + SIZEOF_HEADERS; + .text : + { + *(.text .stub .text.* .gnu.linkonce.t.*) + *(.text.unlikely .text.*_unlikely .text.unlikely.*) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } + .plt : { *(.plt) *(.iplt) } + .init : + { + KEEP (*(.init)) + } + .fini : + { + KEEP (*(.fini)) + } + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } .interp : { *(.interp) } .note.gnu.build-id : { *(.note.gnu.build-id) } .hash : { *(.hash) } @@ -42,30 +66,6 @@ SECTIONS *(.rela.iplt) PROVIDE_HIDDEN (__rela_iplt_end = .); } - .init : - { - KEEP (*(.init)) - } - .plt : { *(.plt) *(.iplt) } - .text : - { - *(.text .stub .text.* .gnu.linkonce.t.*) - *(.text.unlikely .text.*_unlikely .text.unlikely.*) - *(.text.exit .text.exit.*) - *(.text.startup .text.startup.*) - *(.text.hot .text.hot.*) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - } - .fini : - { - KEEP (*(.fini)) - } - PROVIDE (__etext = .); - PROVIDE (_etext = .); - PROVIDE (etext = .); - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } - .rodata1 : { *(.rodata1) } .eh_frame_hdr : { *(.eh_frame_hdr) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table