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
First, in the source code of proot-rs, runing a executable without INTERP segment is not allowed currently. We need to remove some code snippet
Now, we are able to execute a statically linked elf file. But in some case, we will got a SIGSEGV in loader.c:
RUST_LOG=trace cargo run -- --rootfs=./rootfs -- /bin/test_execve_static
It was caused by a mmap() syscall, when the loader are mapping a PT_LOAD segment. In this case. the memory area being mapped was 0x401000 -- (0x401000+0x81000) , which is the second PT_LOAD segment of the executing elf file:
By analysis the dumped core file, I found that the address of the current instruction (the value of rip register) is 0x401219, which is precisely within the mapping memory area.
Then, I have a look at the program headers of our loader, and found that the PT_LOAD segment is conflict with the one in the executing elf file. That is why the issue occured.
Therefore, to fix this, we can use the -Wl,-Ttext=0xaddress option to set the address of the .text section when we compile the loader. This involves a change to build_loader.rs.
A minimal test case:
output:
The text was updated successfully, but these errors were encountered: