The no_mangle attribute is unsafe since Rust 2024

This commit is contained in:
Philipp Oppermann
2025-03-27 15:39:15 +01:00
parent 9345886d44
commit 9753695744
47 changed files with 149 additions and 149 deletions

View File

@@ -108,7 +108,7 @@ fn test_runner(tests: &[&dyn Fn()]) {
#![reexport_test_harness_main = "test_main"]
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
@@ -671,7 +671,7 @@ Rust에서는 [통합 테스트][integration tests]들을 프로젝트 루트에
use core::panic::PanicInfo;
#[no_mangle] // don't mangle the name of this function
#[unsafe(no_mangle)] // don't mangle the name of this function
pub extern "C" fn _start() -> ! {
test_main();
@@ -754,7 +754,7 @@ pub fn test_panic_handler(info: &PanicInfo) -> ! {
/// Entry point for `cargo test`
#[cfg(test)]
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
test_main();
loop {}
@@ -820,7 +820,7 @@ pub mod vga_buffer;
use core::panic::PanicInfo;
use blog_os::println;
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
@@ -936,7 +936,7 @@ fn panic(_info: &PanicInfo) -> ! {
#![test_runner(test_runner)]
#![reexport_test_harness_main = "test_main"]
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
test_main();
@@ -1005,7 +1005,7 @@ harness = false
use core::panic::PanicInfo;
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
should_fail();
serial_println!("[test did not panic]");
@@ -1042,4 +1042,4 @@ fn panic(_info: &PanicInfo) -> ! {
## 다음 단계는 무엇일까요?
다음 글에서는 _CPU exception (예외)_ 에 대해 알아볼 것입니다. 분모가 0인 나누기 연산 혹은 매핑되지 않은 메모리 페이지에 대한 접근 (페이지 폴트) 등 허가되지 않은 작업이 일어났을 때 CPU가 예외를 발생시킵니다. 이러한 예외 발생을 포착하고 분석할 수 있어야 앞으로 커널에 발생할 수많은 오류를 디버깅할 수 있을 것입니다. 예외를 처리하는 과정은 하드웨어 인터럽트를 처리하는 과정(예: 컴퓨터의 키보드 입력을 지원할 때)과 매우 유사합니다.
다음 글에서는 _CPU exception (예외)_ 에 대해 알아볼 것입니다. 분모가 0인 나누기 연산 혹은 매핑되지 않은 메모리 페이지에 대한 접근 (페이지 폴트) 등 허가되지 않은 작업이 일어났을 때 CPU가 예외를 발생시킵니다. 이러한 예외 발생을 포착하고 분석할 수 있어야 앞으로 커널에 발생할 수많은 오류를 디버깅할 수 있을 것입니다. 예외를 처리하는 과정은 하드웨어 인터럽트를 처리하는 과정(예: 컴퓨터의 키보드 입력을 지원할 때)과 매우 유사합니다.