ELF file offset from virtual address
===

I am currently working with implementing Harvard's OS/161 operating system. I am trying to develop on-demand paging, meaning that a page is only loaded into physical memory only once it is needed. So, for example, when a user program just starts, a TLB Miss will occur (because there is nothing in the TLB or in memory yet), which after checking the memory, will cause a page fault to occur. 

Now I have to use the programs ELF file to load in the correct page into memory, add it to the TLB and continue execution. My question is, how do I determine the correct page to load from the ELF file, based on the virtual address of the TLB miss? 

In other words, the TLB miss occurs on a virtual address (lets call it the faultaddress). I then must allocate a page of physical memory, and then load correct the page into physical memory using information from the programs ELF file to do so. In the implementation of OS/161, we have methods of reading from files and all of that, my issue is that I'm not entirely sure how to determine the offset (in the ELF file) based on the faultaddress in order to load the correct page.

Any hints or tips? Thanks guys.