diff options
author | Dennis Kobert <dennis@kobert.dev> | 2019-10-25 16:11:37 +0200 |
---|---|---|
committer | Dennis Kobert <dennis@kobert.dev> | 2019-10-25 16:11:37 +0200 |
commit | 410829451bb1bc01691308acb850c7bba9075075 (patch) | |
tree | 92d186893d3d1d3af66277ba547db36c07e1315d /kernel | |
parent | 2ec377f6769df75923ce83494e198b1dd60c10e6 (diff) |
Iink rust binary
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/Cargo.toml | 3 | ||||
-rwxr-xr-x | kernel/build.sh | 10 | ||||
-rw-r--r-- | kernel/src/lib.rs | 3 | ||||
-rw-r--r-- | kernel/src/linker.ld | 2 | ||||
-rw-r--r-- | kernel/src/long_mode_init.asm | 4 |
5 files changed, 18 insertions, 4 deletions
diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 410d6d7..9dd89c3 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -7,3 +7,6 @@ edition = "2018" [lib] crate-type = ["staticlib"] + +[dependencies] +compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins" } diff --git a/kernel/build.sh b/kernel/build.sh index 4a8130b..8fa91ce 100755 --- a/kernel/build.sh +++ b/kernel/build.sh @@ -1,14 +1,18 @@ #!/usr/bin/sh ASM_PATH="src/" -TARGET_PATH="target/" +TARGET_PATH="target" TMP_PATH="$TARGET_PATH/temp/" OBJ_PATH="$TMP_PATH" LINK_SCRIPT_PATH="src/" GRUB_CFG_PATH="src/grub.cfg" +ARCH="x86_64" +TARGET="$ARCH-uff" +RUST_BIN="$TARGET_PATH/$TARGET/debug/libkernel.a" remove_target() { - rm -rf $TARGET_PATH &> /dev/null + rm -rf $TMP_PATH/* &> /dev/null + rm -f $TARGET_PATH/uff.iso &> /dev/null } create_target() { @@ -27,7 +31,7 @@ build_kernel_elf() { for f in $ASM_PATH/*.asm; do nasm -felf64 "$f" -o $OBJ_PATH/"$(basename -s .asm $f)".o done - ld -n -o $TARGET_PATH/kernel.bin -T $LINK_SCRIPT_PATH/linker.ld $OBJ_PATH/*.o + ld -n -o $TARGET_PATH/kernel.bin -gc-sections -T $LINK_SCRIPT_PATH/linker.ld $OBJ_PATH/*.o $RUST_BIN cleanup_temp } diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 066a526..05b90ef 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -1,6 +1,9 @@ +#![feature(compiler_builtins_lib)] #![no_std] #![no_main] +extern crate compiler_builtins; + #[no_mangle] pub extern "C" fn _start() -> ! { loop {} diff --git a/kernel/src/linker.ld b/kernel/src/linker.ld index cef8809..9b5355c 100644 --- a/kernel/src/linker.ld +++ b/kernel/src/linker.ld @@ -6,7 +6,7 @@ SECTIONS { .boot : { /* ensure that the multiboot heater is at the beginning */ - *(.multiboot_header) + KEEP(*(.multiboot_header)) } .text : diff --git a/kernel/src/long_mode_init.asm b/kernel/src/long_mode_init.asm index f105388..751af9b 100644 --- a/kernel/src/long_mode_init.asm +++ b/kernel/src/long_mode_init.asm @@ -14,4 +14,8 @@ long_mode_start: ; print `Uff!` to screen mov rax, 0x8521846683668255 mov qword [0xb8000], rax + + extern _start + call _start + hlt |