tools/android/elf_compression/elf_headers.py
def AddProgramHeader(self, phdr):
    """Adds a new ProgramHeader entry correcting the e_phnum variable.

    This method will increase the size of LOAD segment containing the program
    headers without correcting the other offsets. It is up to the caller to
    deal with the results. One way to avoid any problems would be to move
    program headers to the end of the file.

    Args:
      phdr: ProgramHeader. Instance of ProgramHeader to add.
    """
    self.phdrs.append(phdr)

    phdrs_size = self.e_phnum * self.e_phentsize
    # We need to locate the LOAD segment containing program headers and
    # increase its size.
    phdr_found = False
    for phdr in self.GetProgramHeadersByType(ProgramHeader.Type.PT_LOAD):
      if phdr.p_offset > self.e_phoff:
        continue
      if phdr.FilePositionEnd() < self.e_phoff + phdrs_size:
        continue
      phdr.p_filesz += self.e_phentsize
      phdr.p_memsz += self.e_phentsize
      phdr_found = True
      break
    if not phdr_found:
      raise RuntimeError('Failed to increase program headers LOAD segment')

    # If PHDR segment exists it needs to be corrected as well.
    for phdr in self.GetProgramHeadersByType(ProgramHeader.Type.PT_PHDR):
      phdr.p_filesz += self.e_phentsize
      phdr.p_memsz += self.e_phentsize
    self.e_phnum += 1
Adds a new ProgramHeader entry correcting the e_phnum variable.

    This method will increase the size of LOAD segment containing the program
    headers without correcting the other offsets. It is up to the caller to
    deal with the results. One way to avoid any problems would be to move
    program headers to the end of the file.

    Args:
      phdr: ProgramHeader. Instance of ProgramHeader to add.
    
Adds a new ProgramHeader entry correcting the e_phnum variable.
This method will increase the size of LOAD segment containing the program
headers without correcting the other offsets. It is up to the caller to
deal with the results. One way to avoid any problems would be to move
program headers to the end of the file.
Adds a new ProgramHeader entry correcting the e_phnum variable . This method will increase the size of LOAD segment containing the program headers without correcting the other offsets . It is up to the caller to deal with the results . One way to avoid any problems would be to move program headers to the end of the file .
def AddProgramHeader(self, phdr):
    self.phdrs.append(phdr)
    phdrs_size = self.e_phnum * self.e_phentsize
    phdr_found = False
    for phdr in self.GetProgramHeadersByType(ProgramHeader.Type.PT_LOAD):
      if phdr.p_offset > self.e_phoff:
        continue
      if phdr.FilePositionEnd() < self.e_phoff + phdrs_size:
        continue
      phdr.p_filesz += self.e_phentsize
      phdr.p_memsz += self.e_phentsize
      phdr_found = True
      break
    if not phdr_found:
      raise RuntimeError('Failed to increase program headers LOAD segment')
    for phdr in self.GetProgramHeadersByType(ProgramHeader.Type.PT_PHDR):
      phdr.p_filesz += self.e_phentsize
      phdr.p_memsz += self.e_phentsize
    self.e_phnum += 1
def AddProgramHeader ( self , phdr ) : self . phdrs . append ( phdr ) phdrs_size = self . e_phnum * self . e_phentsize phdr_found = False for phdr in self . GetProgramHeadersByType ( ProgramHeader . Type . PT_LOAD ) : if phdr . p_offset > self . e_phoff : continue if phdr . FilePositionEnd ( ) < self . e_phoff + phdrs_size : continue phdr . p_filesz += self . e_phentsize phdr . p_memsz += self . e_phentsize phdr_found = True break if not phdr_found : raise RuntimeError ( 'Failed to increase program headers LOAD segment' ) for phdr in self . GetProgramHeadersByType ( ProgramHeader . Type . PT_PHDR ) : phdr . p_filesz += self . e_phentsize phdr . p_memsz += self . e_phentsize self . e_phnum += 1
Adds a new ProgramHeader entry correcting the e_phnum variable.
Adds a new ProgramHeader entry correcting the e_phnum variable .
"""Adds a new ProgramHeader entry correcting the e_phnum variable.

    This method will increase the size of LOAD segment containing the program
    headers without correcting the other offsets. It is up to the caller to
    deal with the results. One way to avoid any problems would be to move
    program headers to the end of the file.

    Args:
      phdr: ProgramHeader. Instance of ProgramHeader to add.
    """ # We need to locate the LOAD segment containing program headers and # increase its size. # If PHDR segment exists it needs to be corrected as well.
self
phdr
ProgramHeader. Instance of ProgramHeader to add.
ProgramHeader . Instance of ProgramHeader to add .