From c099831b429af669dcb016555e9ee9e195f3d7df Mon Sep 17 00:00:00 2001 From: shehreenr Date: Fri, 2 May 2025 17:50:31 -0500 Subject: [PATCH 1/2] replace binary name with weak symbol --- src/syscalls/interfaces/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/syscalls/interfaces/mod.rs b/src/syscalls/interfaces/mod.rs index d5ce66a6e0..bbb3771fda 100644 --- a/src/syscalls/interfaces/mod.rs +++ b/src/syscalls/interfaces/mod.rs @@ -1,10 +1,16 @@ use alloc::boxed::Box; use alloc::vec::Vec; +use core::ptr; pub use self::generic::*; pub use self::uhyve::*; use crate::{arch, env}; +#[linkage = "weak"] +#[no_mangle] + +static __hermit_app_name: *const u8 = ptr::null(); + mod generic; pub(crate) mod uhyve; @@ -16,7 +22,14 @@ pub trait SyscallInterface: Send + Sync { fn get_application_parameters(&self) -> (i32, *const *const u8, *const *const u8) { let mut argv = Vec::new(); - let name = Box::leak(Box::new("bin\0")).as_ptr(); + let name = unsafe { + if !__hermit_app_name.is_null() { + __hermit_app_name + } else { + Box::leak(Box::new("hermit-app\0")).as_ptr() // default binary name + } + }; + argv.push(name); let args = env::args(); From 7942d40651fbb76b53d6e66d1748d963d42c749a Mon Sep 17 00:00:00 2001 From: shehreenr Date: Sat, 3 May 2025 22:34:27 -0500 Subject: [PATCH 2/2] supply correct image filename --- src/syscalls/interfaces/mod.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/syscalls/interfaces/mod.rs b/src/syscalls/interfaces/mod.rs index bbb3771fda..3353821218 100644 --- a/src/syscalls/interfaces/mod.rs +++ b/src/syscalls/interfaces/mod.rs @@ -1,16 +1,10 @@ use alloc::boxed::Box; use alloc::vec::Vec; -use core::ptr; pub use self::generic::*; pub use self::uhyve::*; use crate::{arch, env}; -#[linkage = "weak"] -#[no_mangle] - -static __hermit_app_name: *const u8 = ptr::null(); - mod generic; pub(crate) mod uhyve; @@ -22,14 +16,7 @@ pub trait SyscallInterface: Send + Sync { fn get_application_parameters(&self) -> (i32, *const *const u8, *const *const u8) { let mut argv = Vec::new(); - let name = unsafe { - if !__hermit_app_name.is_null() { - __hermit_app_name - } else { - Box::leak(Box::new("hermit-app\0")).as_ptr() // default binary name - } - }; - + let name = Box::leak(Box::new("hermit-app\0")).as_ptr(); argv.push(name); let args = env::args(); @@ -67,4 +54,4 @@ pub trait SyscallInterface: Send + Sync { arch::processor::shutdown(error_code) } -} +} \ No newline at end of file