Does executing a binary on a RAMDisk reload the executable into memory?

556 Views Asked by At

Let's say I have two copies of the same 10MB binary executable, A and B.

If I have plenty of available memory and run ./A, my understanding is that A will be loaded into memory and run from there. This will take around 10MB of RAM to accomplish.

If I have plenty of available memory, create a RAMDisk, copy B to the RAMDisk, and run ./B from the RAMDisk, my understanding is that B will be (re)loaded into memory and run from there. This will take around 10MB of RAM for the executable, plus the memory in use for the RAMDisk.

Is this correct? Is a RAMDisk smart enough to say "oh, I already have that binary executable in memory, let's just run it in place?" Even if it was, wouldn't the loader have to do its magic to run the thing?

I'm using QNX and running ELF without COFF binaries, but I would appreciate answers for any *Nix system.

1

There are 1 best solutions below

0
On

I would really expect it to be loaded, typical ELF binaries are really not an "execute in place" format.

There are things you need to do, like relocating any position-independent code and of course dynamic library loading, which the file system on the RAM disk knows nothing about.