Search code examples
c++windowsassemblyportable-executable

Is code seen as initialized data in the Portable Executable format, and what exactly are the difference between initialized and unitialized data?


Is code seen as initialized data in the Portable Executable (PE) format, and what exactly are the difference between initialized and unitialized data?

From previous experience, I see intialized data as something like a string or integer, but is executable code also refered to as initialized data in PE context?

Also, what exactly are the differences between initialized and unitialized data?

The documentation says:

Section Data

Initialized data for a section consists of simple blocks of bytes. However, for sections that contain all zeros, the section data need not be included.

...


Solution

  • Every process consists of basically 4 portions of address space that are accessible to the process and one of them is the .Data section which is divided into :

    1) Initialized Read Only Data : This contains the data elements that are initialized by the program and they are read only during the execution of the process.

    2) Initialized Read Write Data : This contains the data elements that are initialized by the program and will be modified in the course of process execution.

    3) Uninitalized Data : This contains the elements are not initialized by the program and are set 0 before the processes executes. These can also be modified and referred as BSS(Block Started Symbol). The adv of such elements are, system doesn't have to allocate space in the program file for this area, b'coz it is initialized to 0 by OS before the process begins to execute.

    Is code seen as initialized data in the Portable Executable (PE) format

    The code of any program can be found in .Text portion, it contains the actual instructions to be executed, On many Operating Systems this is set to read only, similar to initialized Read Only Data.

    what exactly are the differences between initialized and unitialized data?

    So the difference between them is in their value, the initialized data have an unique value set by the program before the process starts and can be Read Write or Read Only Data , in the other hand the uninitialized data value is set to 0 by the OS, you can take a look here.

    Amrane Abdelkader.