tools/android/elf_compression/compress_section.py
def _CreateLoadForCompressedSection(data):
  """Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME.

  Returns the virtual address range corresponding to created segment."""
  elf_hdr = elf_headers.ElfHeader(data)

  section_offset = None
  section_size = None
  for shdr in elf_hdr.GetSectionHeaders():
    if shdr.GetStrName() == COMPRESSED_SECTION_NAME:
      section_offset = shdr.sh_offset
      section_size = shdr.sh_size
      break
  if section_offset is None:
    raise RuntimeError(
        'Failed to locate {} section in file'.format(COMPRESSED_SECTION_NAME))

  unaligned_new_vaddr = _FindNewVaddr(elf_hdr.GetProgramHeaders())
  new_vaddr = MatchVaddrAlignment(unaligned_new_vaddr, section_offset)
  elf_hdr.AddProgramHeader(
      elf_headers.ProgramHeader.Create(
          elf_hdr.byte_order,
          p_type=elf_headers.ProgramHeader.Type.PT_LOAD,
          p_flags=elf_headers.ProgramHeader.Flags.PF_R,
          p_offset=section_offset,
          p_vaddr=new_vaddr,
          p_paddr=new_vaddr,
          p_filesz=section_size,
          p_memsz=section_size,
          p_align=ADDRESS_ALIGN,
      ))
  elf_hdr.PatchData(data)
  return new_vaddr, new_vaddr + section_size
Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME.

  Returns the virtual address range corresponding to created segment.
Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME.
Returns the virtual address range corresponding to created segment.
Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME . Returns the virtual address range corresponding to created segment .
def _CreateLoadForCompressedSection(data):
  elf_hdr = elf_headers.ElfHeader(data)
  section_offset = None
  section_size = None
  for shdr in elf_hdr.GetSectionHeaders():
    if shdr.GetStrName() == COMPRESSED_SECTION_NAME:
      section_offset = shdr.sh_offset
      section_size = shdr.sh_size
      break
  if section_offset is None:
    raise RuntimeError(
        'Failed to locate {} section in file'.format(COMPRESSED_SECTION_NAME))
  unaligned_new_vaddr = _FindNewVaddr(elf_hdr.GetProgramHeaders())
  new_vaddr = MatchVaddrAlignment(unaligned_new_vaddr, section_offset)
  elf_hdr.AddProgramHeader(
      elf_headers.ProgramHeader.Create(
          elf_hdr.byte_order,
          p_type=elf_headers.ProgramHeader.Type.PT_LOAD,
          p_flags=elf_headers.ProgramHeader.Flags.PF_R,
          p_offset=section_offset,
          p_vaddr=new_vaddr,
          p_paddr=new_vaddr,
          p_filesz=section_size,
          p_memsz=section_size,
          p_align=ADDRESS_ALIGN,
      ))
  elf_hdr.PatchData(data)
  return new_vaddr, new_vaddr + section_size
def _CreateLoadForCompressedSection ( data ) : elf_hdr = elf_headers . ElfHeader ( data ) section_offset = None section_size = None for shdr in elf_hdr . GetSectionHeaders ( ) : if shdr . GetStrName ( ) == COMPRESSED_SECTION_NAME : section_offset = shdr . sh_offset section_size = shdr . sh_size break if section_offset is None : raise RuntimeError ( 'Failed to locate {} section in file' . format ( COMPRESSED_SECTION_NAME ) ) unaligned_new_vaddr = _FindNewVaddr ( elf_hdr . GetProgramHeaders ( ) ) new_vaddr = MatchVaddrAlignment ( unaligned_new_vaddr , section_offset ) elf_hdr . AddProgramHeader ( elf_headers . ProgramHeader . Create ( elf_hdr . byte_order , p_type = elf_headers . ProgramHeader . Type . PT_LOAD , p_flags = elf_headers . ProgramHeader . Flags . PF_R , p_offset = section_offset , p_vaddr = new_vaddr , p_paddr = new_vaddr , p_filesz = section_size , p_memsz = section_size , p_align = ADDRESS_ALIGN , ) ) elf_hdr . PatchData ( data ) return new_vaddr , new_vaddr + section_size
Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME.
Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME .
"""Creates a LOAD segment to previously created COMPRESSED_SECTION_NAME.

  Returns the virtual address range corresponding to created segment."""
data