Executable formats
Virtual address to file offset
Map an address through normalized file-backed segments.
Your inputs
Start with an exampleYour result
Example resultAa — A small example of your colors.
How it works
Find the containing half-open memory range. Add the address delta to fileOffset only when it is below fileSize.
Address 4194336 is 32 bytes into the sample segment, so its file offset is 512 + 32 = 544 (0x220).
Limits
Normalize ELF segments or PE sections yourself. For PE, use an RVA consistently and account for raw padding. Ambiguous overlapping mappings are rejected.