diff --git a/src/main.rs b/src/main.rs index 0e1b04d..92a0547 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,22 @@ fn show_ui(boot_services: &BootServices) -> Option { Some(!settings.standalone_mode && require_inputmodules) } +/// Since Rust 1.99 (LLVM 23), loops that search for a NUL u16, like in +/// `CStr16::from_ptr`, are turned into calls to wcslen. +/// There's no libc on UEFI and compiler_builtins doesn't provide it. +/// +/// # Safety +/// `s` must point to a NUL-terminated UCS-2 string +#[no_mangle] +pub unsafe extern "C" fn wcslen(s: *const u16) -> usize { + let mut len = 0; + // Volatile read, so LLVM can't turn this loop into a call to itself + while core::ptr::read_volatile(s.add(len)) != 0 { + len += 1; + } + len +} + #[entry] fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { let event = uefi_services::init(&mut system_table).unwrap();