tools/android/elf_compression/compress_section.py
def _FileRangeToVirtualAddressRange(data, l, r):
  """Returns virtual address range corresponding to given file range.

  Since we have to resolve them by their virtual address, parsing of LOAD
  segments is required here.
  """
  elf = elf_headers.ElfHeader(data)
  for phdr in elf.GetProgramHeadersByType(
      elf_headers.ProgramHeader.Type.PT_LOAD):
    # Current version of the prototype only supports ranges which are fully
    # contained inside one LOAD segment. It should cover most of the common
    # cases.
    if not SegmentsIntersect(phdr.p_offset, phdr.FilePositionEnd(), l, r):
      continue
    if not SegmentContains(phdr.p_offset, phdr.FilePositionEnd(), l, r):
      raise RuntimeError('Range is not contained within one LOAD segment')
    l_virt = phdr.p_vaddr + (l - phdr.p_offset)
    r_virt = phdr.p_vaddr + (r - phdr.p_offset)
    return l_virt, r_virt
  raise RuntimeError('Specified range is outside of all LOAD segments.')
Returns virtual address range corresponding to given file range.

  Since we have to resolve them by their virtual address, parsing of LOAD
  segments is required here.
  
Returns virtual address range corresponding to given file range.
Since we have to resolve them by their virtual address, parsing of LOAD
segments is required here.
Returns virtual address range corresponding to given file range . Since we have to resolve them by their virtual address parsing of LOAD segments is required here .
def _FileRangeToVirtualAddressRange(data, l, r):
  elf = elf_headers.ElfHeader(data)
  for phdr in elf.GetProgramHeadersByType(
      elf_headers.ProgramHeader.Type.PT_LOAD):
    if not SegmentsIntersect(phdr.p_offset, phdr.FilePositionEnd(), l, r):
      continue
    if not SegmentContains(phdr.p_offset, phdr.FilePositionEnd(), l, r):
      raise RuntimeError('Range is not contained within one LOAD segment')
    l_virt = phdr.p_vaddr + (l - phdr.p_offset)
    r_virt = phdr.p_vaddr + (r - phdr.p_offset)
    return l_virt, r_virt
  raise RuntimeError('Specified range is outside of all LOAD segments.')
def _FileRangeToVirtualAddressRange ( data , l , r ) : elf = elf_headers . ElfHeader ( data ) for phdr in elf . GetProgramHeadersByType ( elf_headers . ProgramHeader . Type . PT_LOAD ) : if not SegmentsIntersect ( phdr . p_offset , phdr . FilePositionEnd ( ) , l , r ) : continue if not SegmentContains ( phdr . p_offset , phdr . FilePositionEnd ( ) , l , r ) : raise RuntimeError ( 'Range is not contained within one LOAD segment' ) l_virt = phdr . p_vaddr + ( l - phdr . p_offset ) r_virt = phdr . p_vaddr + ( r - phdr . p_offset ) return l_virt , r_virt raise RuntimeError ( 'Specified range is outside of all LOAD segments.' )
Returns virtual address range corresponding to given file range.
Returns virtual address range corresponding to given file range .
"""Returns virtual address range corresponding to given file range.

  Since we have to resolve them by their virtual address, parsing of LOAD
  segments is required here.
  """ # Current version of the prototype only supports ranges which are fully # contained inside one LOAD segment. It should cover most of the common # cases.
data
l
r