aboutsummaryrefslogtreecommitdiff
path: root/defs
diff options
context:
space:
mode:
authorTianhao Wang <shrik3@mailbox.org>2024-06-06 23:08:02 +0200
committerTianhao Wang <shrik3@mailbox.org>2024-06-11 15:17:14 +0200
commit8aaad696463004a9e51d35e4c466c131b3402822 (patch)
tree6d1e84f83e308eca4907d7986b32121b3c92d284 /defs
parent1e890f4e5693d141d62660de5e9481fdf16483ad (diff)
chore: cleanups
Signed-off-by: Tianhao Wang <shrik3@mailbox.org>
Diffstat (limited to 'defs')
-rw-r--r--defs/x86_64-hm-linker.ld14
-rw-r--r--defs/x86_64-linker.ld99
2 files changed, 8 insertions, 105 deletions
diff --git a/defs/x86_64-hm-linker.ld b/defs/x86_64-hm-linker.ld
index fab0699..2055ce4 100644
--- a/defs/x86_64-hm-linker.ld
+++ b/defs/x86_64-hm-linker.ld
@@ -1,11 +1,11 @@
/* defs for Multiboot headers */
/* https://www.gnu.org/software/grub/manual/multiboot/multiboot.txt */
-MB_MAGIC = 0x1badb002;
-/* bit 0
- * all boot modules loaded along with the operating system must be
- * aligned on page (4KB) bit 1 must include mem_* structures
+/* bit 0: all boot modules loaded along with the operating system must
+ * be aligned on page (4KB)
+ * bit 1: must include mem_* structures
*/
+MB_MAGIC = 0x1badb002;
MB_FLAGS = 0x3;
MB_CHKSUM = 0x100000000 - (MB_MAGIC + MB_FLAGS);
@@ -50,7 +50,6 @@ SECTIONS
*(".reserved_0.*")
}
-
/* global page table for 64-bit long mode */
.global_pagetable ALIGN(4096) (NOLOAD) :
{
@@ -76,6 +75,9 @@ SECTIONS
}
. = . + KERNEL_OFFSET;
+
+ /* .ltext, .ldata, .lbss, .rodata etc are generated by rust compiler */
+ /* because of "code-model=large setting" */
.text : AT(ADDR(.text) - KERNEL_OFFSET)
{
*(".text")
@@ -100,8 +102,8 @@ SECTIONS
{
PROVIDE (___BSS_START__ = .);
*(".bss")
- *(".lbss")
*(".bss.*")
+ *(".lbss")
*(".lbss.*")
*(".lbss$")
PROVIDE (___BSS_END__ = .);
diff --git a/defs/x86_64-linker.ld b/defs/x86_64-linker.ld
deleted file mode 100644
index f22f5ad..0000000
--- a/defs/x86_64-linker.ld
+++ /dev/null
@@ -1,99 +0,0 @@
-/* defs for Multiboot headers */
-/* https://www.gnu.org/software/grub/manual/multiboot/multiboot.txt */
-MB_MAGIC = 0x1badb002;
-/* bit 0
- * all boot modules loaded along with the operating system must be
- * aligned on page (4KB) bit 1 must include mem_* structures
- */
-MB_FLAGS = 0x3;
-MB_CHKSUM = 0x100000000 - (MB_MAGIC + MB_FLAGS);
-
-SECTIONS
-{
- . = 0x100000; /* system's start address */
-
- .boot :
- {
- header_start = .;
- LONG(MB_MAGIC)
- LONG(MB_FLAGS)
- LONG(MB_CHKSUM)
- LONG(0)
- LONG(0)
- LONG(0)
- LONG(0)
- LONG(0)
- LONG(0)
- LONG(0)
- LONG(0)
- LONG(0)
- header_end = .;
- }
-
- PROVIDE (___KERNEL_PM_START__ = .);
- .text :
- {
- *(".text")
- *(".text.*")
- *(".text$")
- }
-
- .data :
- {
- *(".data")
- *(".data.*")
- *(".data$")
- }
-
- .reserved :
- {
- *(".reserved")
- *(".reserved.*")
- }
-
- /*
- * basically the same as BSS, but I want some flexibility and I don't care
- * for zeroing because it's explicitly overwritten anyways. I KNOW WHAT I'M
- * DOING! An example is the idt.
- */
- .reserved_0 (NOLOAD) :
- {
- *(".reserved_0")
- *(".reserved_0.*")
- }
-
- .rodata :
- {
- *(".rodata")
- *(".rodata$")
- *(".rodata.*")
- }
-
- .bss :
- {
- PROVIDE (___BSS_START__ = .);
- *(".bss")
- *(".bss.*")
- PROVIDE (___BSS_END__ = .);
- }
-
- /* global page table for 64-bit long mode */
- .global_pagetable ALIGN(4096) (NOLOAD) :
- {
- *(".global_pagetable")
- }
-
- . = ALIGN(4096);
- /* reserve space for a premitive stack based physical frame allocator */
- /* each frame is 4KiB in size and has a 64bit (physical) address. e.g. */
- /* for every 1 GiB physical memory we need 2 MiB space reserved for the */
- /* free stack. For a easier bootstraping we are using a fix-sized stack */
- /* array. Currently using 4GiB, therefore reserve 8MiB. */
- PROVIDE (___FREE_PAGE_STACK__ = .);
- .global_free_page_stack ALIGN(4096) (NOLOAD) :
- {
- *("..global_free_page_stack")
- }
- . = ALIGN(4096);
- PROVIDE (___KERNEL_PM_END__ = .);
-}