You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unsafe{// And finally start the application.#[cfg(all(not(test), not(feature = "syscall")))]runtime_entry(argc, argv, environ);#[cfg(all(not(test), feature = "syscall"))]main();}
When compiled with syscall feature, initd makes a call to main.
Here, main is assumed to be a non-return function. In my case, this main seems to be the one auto-generated by rustc in create_entry_fn in compiler/rustc_codegen_ssa/src/base.rs as the following(I'm not very familiar with rustc, correct me if i'm wrong). This is produced by radare2
What I've observed on my machine is: main returns and some code compiler has put after it is called.
However, it is not the assembly in task_start
Above, the flow goes back somewhere to the start of initd(for example, str x0, [var_90h] ; lib.rs:280 info!("Hermit is running on common system!");), then some sub-systems would be initialized again and panic.
This does not happen to runtime_entry if compiled without syscall since runtime_entry just calls abi::exit at the end.
Is this a toolchain issue or has anyone also came across this?
I guess this is probably because the compiler thinks main is non-return, so it's free to put anything it likes in the binary after it?
The text was updated successfully, but these errors were encountered:
bl main ; lib.rs:311 main(); ; int main(int argc, char **argv)
ldp x29, x30, [var_190h] ; lib.rs:315 }
add sp, arg_1a0h
ret
this is not quite correct, but
by simply changing the extern declaration of main, initd do get a ret which allows it to go back to the assembly in task_start
Currently, it isn't working and will get in the future a useful feature. Later the feature will enable a "common monolithic kernel". However, I renamed the feature (see #1026).
In initd
When compiled with syscall feature, initd makes a call to main.
Here, main is assumed to be a non-return function. In my case, this main seems to be the one auto-generated by rustc in create_entry_fn in compiler/rustc_codegen_ssa/src/base.rs as the following(I'm not very familiar with rustc, correct me if i'm wrong). This is produced by radare2
I understand by this
exit is supposed to be called after blr to main(blr suggests you assume it to return?), however,
initd is actually (near the end where main is called)
What I've observed on my machine is: main returns and some code compiler has put after it is called.
However, it is not the assembly in task_start
Above, the flow goes back somewhere to the start of initd(for example, str x0, [var_90h] ; lib.rs:280 info!("Hermit is running on common system!");), then some sub-systems would be initialized again and panic.
This does not happen to runtime_entry if compiled without syscall since runtime_entry just calls abi::exit at the end.
Is this a toolchain issue or has anyone also came across this?
I guess this is probably because the compiler thinks main is non-return, so it's free to put anything it likes in the binary after it?
The text was updated successfully, but these errors were encountered: