From 549dfd362b3ac3b784037315ce29641caaca9939 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 2 Apr 2018 17:23:47 +0200 Subject: [PATCH] Mark _start as extern; fix wrong entry point name --- .../second-edition/posts/02-minimal-rust-kernel/index.md | 4 ++-- blog/content/second-edition/posts/03-vga-text-buffer/index.md | 4 ++-- src/main.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md b/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md index b18b43bb..2698a2a1 100644 --- a/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md +++ b/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md @@ -210,7 +210,7 @@ pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, } #[no_mangle] // don't mangle the name of this function -pub fn _start() -> ! { +pub extern fn _start() -> ! { // this function is the entry point, since the linker looks for a function // named `_start` by default loop {} @@ -277,7 +277,7 @@ The implementation looks like this: static HELLO: &[u8] = b"Hello World!"; #[no_mangle] -pub fn _start() -> ! { +pub extern fn _start() -> ! { let vga_buffer = 0xb8000 as *const u8 as *mut u8; for (i, &byte) in HELLO.iter().enumerate() { diff --git a/blog/content/second-edition/posts/03-vga-text-buffer/index.md b/blog/content/second-edition/posts/03-vga-text-buffer/index.md index 0b3bacaa..dea6a5eb 100644 --- a/blog/content/second-edition/posts/03-vga-text-buffer/index.md +++ b/blog/content/second-edition/posts/03-vga-text-buffer/index.md @@ -507,7 +507,7 @@ Now we can delete the `print_something` function and print directly from our `_s ```rust // in src/main.rs #[no_mangle] -pub fn _start() -> ! { +pub extern fn _start() -> ! { use core::fmt::Write; vga_buffer::WRITER.lock().write_str("Hello again").unwrap(); write!(vga_buffer::WRITER.lock(), ", some numbers: {} {}", 42, 1.337).unwrap(); @@ -586,7 +586,7 @@ To use `println` in `main.rs`, we need to import the macros of the VGA buffer mo mod vga_buffer; #[no_mangle] -pub extern fn rust_main() { +pub extern fn _start() { println!("Hello World{}", "!"); loop {} diff --git a/src/main.rs b/src/main.rs index cbca9b7a..9bf6bc6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ mod vga_buffer; /// This function is the entry point, since the linker looks for a function /// named `_start_` by default. #[no_mangle] // don't mangle the name of this function -pub fn _start() -> ! { +pub extern fn _start() -> ! { println!("Hello World{}", "!"); loop {}