OSv can run unmodified Linux applications which are complied with `-fPIC` or `-pie`. However, position dependent executables are not support.
Currently, OSv kernel image is mapped at low address space (0x 20 0000). Many position dependent executable executables also start at a low address, such as 0x 40 0040.
OSv Linear Address Space:
--------- 0x 0000 0000 0000 0000
| |
--------- 0x 0000 0000 0020 0000 kernel_base --\
| | |- Kernel (Core ELF) - 22M
--------- 0x 0000 0000 0180 0000 lzkernel_base --/
| |
|-------- 0x 0000 1000 0000 0000 program_base --\
| | |- s_program - 8G
|-------| 0x 0000 1002 0000 0000 --\ --X
| | |- Program |
|-------| 0x 0000 1004 0000 0000 --/ |
| | |- ELF Namespaces(max: 32) - 256G
| | ...................... |
| | |
|-------| 0x 0000 1042 0000 0000 --/
| |
--------- 0x ffff 8000 0000 0000 phys_mem --\
| | |- Main Area - 16T
--------- 0x ffff 9000 0000 0000 --X
| | |- Page Area - 16T
--------- 0x ffff a000 0000 0000 --X
| | |- Mempool Area - 16T
--------- 0x ffff b000 0000 0000 --X
| | |- Debug Area - 80T
--------- 0x ffff ffff ffff ffff --/
Linux Linear Address Space:
--------- 0x 0000 0000 0000 0000 --\
| | |- Reserved (Catch Exceptions of NULL/Little Pointers)
--------- --X
| | |- Text Segment
--------- --X
| | |- Data Segment
--------- --X
| | |- [Random]
--------- --X
| | |- Heap
--------- --/ \/
| |
--------- --\
| | |- Memory Mapping Segment
--------- --/
| | |- [Random]
--------- --/
| |
--------- --\ /\
| | |- Stack
--------- --X
| | |- [Random]
--------- --X
| | |- Command-line Arguments
--------- --X
| | |- Environment Variables
| | --/
---------
| |
--------- 0x 0000 7fff ffff ffff
| |
| | -- Unused Space
| |
--------- 0x ffff 8000 0000 0000 --\
| | |
| | |- Kernel Space - 128T
| | |
--------- 0x ffff ffff ffff ffff --/
If OSv kernel image can be mapped to high address space like Linux ( 0x ffff 8000 0000 0000 ?), then low address space can be used for applications.
So, single position dependent executable can be supported like shared objects and PIE.
I have tried to do this, but it seems difficult for me. Can you give some advice?
Thank you!