Search code examples
operating-systemstructureexecutableconcept

Can I assume an executable file as a snapshot image of an execution state?


I read some unix manual (http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html), and there was a mention about execution.

The new process image shall be constructed from a regular executable file called the new process image file.

The expression process image caught my eyes.

I have been thought executable file is just a kind of sequence of command. Just as the word program means. But actually, I don't know the concept and structure of the executable file. And I felt executable file could be looks like an execution state image from the mention.

Could you explain me something about this? About the concept and structure of regular executable files in nowadays. In any OS.


Solution

  • Usually the executable file does not contain only instructions but also global data, readonly data and many more. I suggest you briefly look e.g. on the ELF format widely used in UNIX-like operating systems or PE format used in Windows.

    The OS may also need for example to replace some addresses of functions (jump targets) with the real addresses of these functions in the memory, although this technique is probably not used anymore in common OSes. Anyway, there can be more work to do than just copy the file into memory and start executing from the first byte.