I know the relationship between them:
virtual address mod page alignment == file alignment mod page alignment
But can anyone tell me in which direction these two numbers are calculated?
Is the virtual address computed from the file offset according to the relation above, or vice versa?
Update
Here are some more details: when the linker writes the header of the ELF file, it sets the virtual address and offset of the program header file. (segments)
For example, the output readelf -l someELFfile:
Elf file type is EXEC (Executable file)
Entry point 0x8048094
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x08048000 0x08048000 0x00154 0x00154 R E 0x1000
LOAD 0x000154 0x08049154 0x08049154 0x00004 0x00004 RW 0x1000
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
We see 2 segments of LOAD.
The virtual address of the first LOAD ends with 0x8048154, and the second LOAD starts with 0x8049154.
ELF LOAD LOAD 0x00154, , ELF , 0x1000 LOAD.
? , LOAD 0x80489000? 0x1000 LOAD?
, LOAD :
mod == mod
, .