- /* Allocate space for the program headers. */
- i_phdrp = (Elf_Internal_Phdr *)
- bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
+ /* Move to the start of the program headers. */
+ if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0)
+ goto wrong;
+
+ /* Allocate space for the program headers. */
+ amt = sizeof (*i_phdrp) * i_ehdrp->e_phnum;
+ i_phdrp = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt);