bool target_patch_phdr(Target* t)
{
  Elf32_Phdr* entry;
  size_t delta; /* distance between code and data segment (in memory) */
  unsigned end_of_cs;
  unsigned nr;

  TRACE(stderr, "target_patch_phdr\n");
  
  entry = t->phdr;
  delta = entry[3].p_vaddr - entry[2].p_vaddr - entry[2].p_memsz;
  CHECK_LT(TEVWH_PAGESIZE, delta);

  entry[2].p_filesz += TEVWH_PAGESIZE;
  entry[2].p_memsz += TEVWH_PAGESIZE;

  end_of_cs = t->end_of_cs;
  for(nr = t->p.ehdr->e_phnum; nr > 0; nr--, entry++)
  {
    /* ">=" instead of ">" is necessary at least on sparc-suse7.3 */
    if (entry->p_offset >= end_of_cs)
      entry->p_offset += TEVWH_PAGESIZE;
  }
  return true;
}
