A file that is given as input to the linker is called Object File. The linker produces an Image file, which in turn is used as input by the loader.
A blurb from "Microsoft Portable Executable and Common Object File Format Specification"
RVA (relative virtual address). In an image file, the address of an item after it is loaded into memory, with the base address of the image file subtracted from it. The RVA of an item almost always differs from its position within the file on disk (file pointer).
In an object file, an RVA is less meaningful because memory locations are not assigned. In this case, an RVA would be an address within a section (described later in this table), to which a relocation is later applied during linking. For simplicity, a compiler should just set the first RVA in each section to zero.
VA (virtual address). Same as RVA, except that the base address of the image file is not subtracted. The address is called a “VA” because Windows creates a distinct VA space for each process, independent of physical memory. For almost all purposes, a VA should be considered just an address. A VA is not as predictable as an RVA because the loader might not load the image at its preferred location.
Even after reading this, I still don't get it. I've lot of questions. Can any one explain it in a practical way. Please stick to terminology of Object File & Image File as stated.
All I know about addresses, is that
- Neither in the Object File nor in the Image File, we don't know the exact memory locations so,
- Assembler while generating Object File computes addresses relative to sections
.data&.text(for function names). - Linker t