#[cfg(feature = "set-msplim")] global_asm!( ".section .text._pre_init", ".global __pre_init", ".type __pre_init, %function", ".thumb_func", "__pre_init:", " ldr r0, =_stack_end", " msr MSPLIM, r0", " bx lr", ".size __pre_init, . - __pre_init" ); ...
global_asm!{".extern {0}","{0}:","mov eax, edi","add eax, esi","ret", sym my_asm_add, } 这样在编译 x86_64-unknown-linux-gnu 目标时生成的汇编代码中的标签是登录后复制my_asm_add,而对于登录后复制x86_64-apple-darwin目标,生成的标签则是登录后复制_my_asm_add。
Linux 内核和 Rust on Linux 的主要开发者 Miguel Ojeda 向 Linux Kernel 邮件列表提交了一个新补丁 (v5),继续推进在 Linux 内核中增加对 Rust 作为第二语言支持。一些 Rust for Linux v5 的更改包括:工具链和 alloc 已经升级到了 Rust 1.59.0。这个版本稳定了 feature(global_asm) 以及 Csymbol-mangling-...
[feature(allocator_api, global_asm)]use kernel::*;module! { type: HelloWorld, name: b“hello_world”, author: b“d0u9”, description: b“Asimple hello world example”, license: b“GPL v2”,}struct HelloWorld;impl KernelModule for HelloWorld { fn init() -》 Result《Self》 { pr_info...
[feature(allocator_api,global_asm)] usekernel::prelude::*; module!{ type:HelloWorld, name:b"hello_world", author:b"d0u9", description:b"A simple hello world example", license:b"GPL v2", } structHelloWorld; implKernelModuleforHelloWorld{...
Linux 内核和 Rust on Linux 的主要开发者 Miguel Ojeda 向 Linux Kernel 邮件列表提交了一个新补丁 (v5),继续推进在 Linux 内核中增加对 Rust 作为第二语言支持。 一些Rust for Linux v5 的更改包括: 工具链和 alloc 已经升级到了 Rust 1.59.0。这个版本稳定了 feature(global_asm) 以及 Csymbol-mangling-...
[feature(allocator_api,global_asm)]use kernel::prelude::*;module!{type:HelloWorld,name:b"hello_world",author:b"d0u9",description:b"A simple hello world example",license:b"GPL v2",}struct HelloWorld;impl KernelModuleforHelloWorld{fninit()->Result<Self>{pr_info!("Hello world from rust!\n...
auto-reduced (treereduce-rust): //@compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Clink-dead-code=true fn foo<const N: usize>() {} core::arch::global_asm!("/* {} */", sym foo::<{ || {}; 0 }>); fn main() {} original: //@ build-pa...
Code //@compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Clink-dead-code=true` fn foo<const N: usize>() {} core::arch::global_asm!("/* {} */", sym foo::<{ || {}; 0 }>); fn main() {} Meta rustc --version --verbose: rustc 1.87.0-nig...
Location https://doc.rust-lang.org/stable/core/arch/macro.global_asm.html Summary Ran into a surprising bug today - global_asm! stuck some executable code into .rodata under release mode. The fix was simple - just needed to add a .sectio...