diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-12-13 01:38:14 +0100 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2024-04-02 23:17:31 +0200 |
| commit | 36137438446c1754a522c5b3cc3aff92c43ac1ee (patch) | |
| tree | f7358ef0aec7023321e52e116f94fba95e52611f /arch | |
X86/X86_64 debug/release WORKING
riscv64 WORKING uart
idk
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/riscv64.json | 15 | ||||
| -rw-r--r-- | arch/riscv64.ld | 25 | ||||
| -rw-r--r-- | arch/x86.json | 15 | ||||
| -rw-r--r-- | arch/x86.ld | 74 | ||||
| -rw-r--r-- | arch/x86_64.json | 15 | ||||
| -rw-r--r-- | arch/x86_64.ld | 81 |
6 files changed, 225 insertions, 0 deletions
diff --git a/arch/riscv64.json b/arch/riscv64.json new file mode 100644 index 0000000..ea84208 --- /dev/null +++ b/arch/riscv64.json @@ -0,0 +1,15 @@ +{ + "llvm-target": "riscv64-unknown-none-elf", + "data-layout": "e-m:e-p:64:64-i64:64-n32:64-S128", + "arch": "riscv64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "+m,+a,+c,+f,+d" +} diff --git a/arch/riscv64.ld b/arch/riscv64.ld new file mode 100644 index 0000000..cad0f07 --- /dev/null +++ b/arch/riscv64.ld @@ -0,0 +1,25 @@ +ENTRY(start); + +. = 0x80200000; + +SECTIONS { + .text : ALIGN(4K) { + *(.init); + *(.text); + } + .bss : ALIGN(4K) { + PROVIDE(bss_start = .); + *(.bss); + . += 4096; + PROVIDE(stack_top = .); + . += 4096; + PROVIDE(global_pointer = .); + PROVIDE(bss_end = .); + } + .rodata : ALIGN(4K) { + *(.rodata); + } + .data : ALIGN(4K) { + *(.data); + } +} diff --git a/arch/x86.json b/arch/x86.json new file mode 100644 index 0000000..9b558de --- /dev/null +++ b/arch/x86.json @@ -0,0 +1,15 @@ +{ + "llvm-target": "i686-unknown-none", + "data-layout": "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-S128", + "arch": "x86", + "target-endian": "little", + "target-pointer-width": "32", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "-mmx,-sse,+soft-float" +} diff --git a/arch/x86.ld b/arch/x86.ld new file mode 100644 index 0000000..440e513 --- /dev/null +++ b/arch/x86.ld @@ -0,0 +1,74 @@ +ENTRY (_start) + +KERNEL_PMA = 0x00100000; +KERNEL_VMA = 0xC0000000; + +SECTIONS +{ + . = KERNEL_PMA; + + + .multiboot.data : { + *(.multiboot2.header) + *(.boot32.rodata) + } + + .multiboot.text : { + *(.multiboot.text) + } + + . += KERNEL_VMA; + + .text ALIGN (4K) : AT (ADDR (.text) - KERNEL_VMA) + { + *(.text) + } + + .got ALIGN (4K) : AT (ADDR (.got) - KERNEL_VMA) + { + *(.got) + } + + .got.plt ALIGN (4K) : AT (ADDR (.got.plt) - KERNEL_VMA) + { + *(.got.plt) + } + + .rodata ALIGN(4K) : AT (ADDR (.rodata) - KERNEL_VMA) + { + *(.rodata) + } + + .data ALIGN (4K) : AT (ADDR (.data) - KERNEL_VMA) + { + *(.data) + } + + .bss ALIGN (4K) : AT (ADDR (.bss) - KERNEL_VMA) + { + *(COMMON) + *(.bss) + *(.bootstrap_stack) + } + + /DISCARD/ : + { + *(.debug_abbrev) + *(.debug_aranges) + *(.debug_frame) + *(.debug_gdb_scripts) + *(.debug_info) + *(.debug_line) + *(.debug_line_str) + *(.debug_loc) + *(.debug_pubnames) + *(.debug_pubtypes) + *(.debug_ranges) + *(.debug_str) + + *(.comment) + *(.note.*) + } + + _kernel_end = .; +} diff --git a/arch/x86_64.json b/arch/x86_64.json new file mode 100644 index 0000000..23da62b --- /dev/null +++ b/arch/x86_64.json @@ -0,0 +1,15 @@ +{ + "llvm-target": "x86_64-unknown-none", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "none", + "executables": true, + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "panic-strategy": "abort", + "disable-redzone": true, + "features": "-mmx,-sse,+soft-float" +} diff --git a/arch/x86_64.ld b/arch/x86_64.ld new file mode 100644 index 0000000..da6663e --- /dev/null +++ b/arch/x86_64.ld @@ -0,0 +1,81 @@ +ENTRY(_start) + +KERNEL_AP_PMA = 0x0000000000008000; +KERNEL_PMA = 0x0000000000100000; +KERNEL_VMA = 0xffffffff80000000; + +SECTIONS +{ + /* + . = KERNEL_AP_PMA; + + .apinit BLOCK(4K) : ALIGN(4K) + { + *(.apinit) + } + */ + + . = KERNEL_PMA; + + .boot BLOCK(4K) : ALIGN(4K) + { + KEEP(*(.multiboot2.header)) + *(.boot32.text) + *(.boot32.rodata) + *(.boot32.bss) + *(.boot64.text) + } + + . += KERNEL_VMA; + + .text ALIGN(4K) : AT (ADDR (.text) - KERNEL_VMA) + { + *(.text) + } + + .rodata ALIGN(4K) : AT (ADDR (.rodata) - KERNEL_VMA) + { + *(.rodata) + } + + .rodata. ALIGN(4K) : AT (ADDR (.rodata.) - KERNEL_VMA) + { + *(.rodata.*) + } + + .data ALIGN(4K) : AT (ADDR (.data) - KERNEL_VMA) + { + *(.data) + } + + .bss ALIGN(4K) : AT (ADDR (.bss) - KERNEL_VMA) + { + *(.bss) + } + + .bss. ALIGN(4K) : AT (ADDR (.bss.) - KERNEL_VMA) + { + *(.bss.*) + } + + /DISCARD/ : + { + *(.debug_abbrev) + *(.debug_aranges) + *(.debug_frame) + *(.debug_gdb_scripts) + *(.debug_info) + *(.debug_line) + *(.debug_line_str) + *(.debug_loc) + *(.debug_pubnames) + *(.debug_pubtypes) + *(.debug_ranges) + *(.debug_str) + + *(.comment) + *(.note.*) + } + + _kernel_end = .; +} |
