'offset_to_vaddr(offset) -> int
Translates the specified offset to a virtual address.
Arguments:
offset(int): Offset to translate
Returns:
`int`: Virtual address which corresponds to the file offset, or
:const:`None`.
Examples:
This example shows that regardless of changes to the virtual
address layout by modifying :attr:`.ELF.address`, the offset
for any given address doesn\'t change.
>>> bash = ELF(\'/bin/bash\')
>>> bash.address == bash.offset_to_vaddr(0)
True
>>> bash.address += 0x123456
>>> bash.address == bash.offset_to_vaddr(0)
True'

def offset_to_vaddr(self, offset):

    load_address_fixup = (self.address - self.load_addr)
    for segment in self.segments:
        begin = segment.header.p_offset
        size = segment.header.p_filesz
        end = (begin + size)
        if ((begin <= offset) and (offset <= end)):
            delta = (offset - begin)
            return ((segment.header.p_vaddr + delta) + load_address_fixup)
    return None
