Line 497... |
Line 497... |
const struct elf_backend_data *ebd;
|
const struct elf_backend_data *ebd;
|
struct bfd_preserve preserve;
|
struct bfd_preserve preserve;
|
asection *s;
|
asection *s;
|
bfd_size_type amt;
|
bfd_size_type amt;
|
const bfd_target *target;
|
const bfd_target *target;
|
const bfd_target * const *target_ptr;
|
|
|
|
preserve.marker = NULL;
|
preserve.marker = NULL;
|
|
|
/* Read in the ELF header in external format. */
|
/* Read in the ELF header in external format. */
|
|
|
Line 586... |
Line 585... |
BFD format expects. */
|
BFD format expects. */
|
if (ebd->elf_machine_code != i_ehdrp->e_machine
|
if (ebd->elf_machine_code != i_ehdrp->e_machine
|
&& (ebd->elf_machine_alt1 == 0
|
&& (ebd->elf_machine_alt1 == 0
|
|| i_ehdrp->e_machine != ebd->elf_machine_alt1)
|
|| i_ehdrp->e_machine != ebd->elf_machine_alt1)
|
&& (ebd->elf_machine_alt2 == 0
|
&& (ebd->elf_machine_alt2 == 0
|
|| i_ehdrp->e_machine != ebd->elf_machine_alt2))
|
|| i_ehdrp->e_machine != ebd->elf_machine_alt2)
|
{
|
&& ebd->elf_machine_code != EM_NONE)
|
if (ebd->elf_machine_code != EM_NONE)
|
|
goto got_wrong_format_error;
|
|
|
|
/* This is the generic ELF target. Let it match any ELF target
|
|
for which we do not have a specific backend. */
|
|
for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
|
|
{
|
|
const struct elf_backend_data *back;
|
|
|
|
if ((*target_ptr)->flavour != bfd_target_elf_flavour)
|
|
continue;
|
|
back = xvec_get_elf_backend_data (*target_ptr);
|
|
if (back->s->arch_size != ARCH_SIZE)
|
|
continue;
|
|
if (back->elf_machine_code == i_ehdrp->e_machine
|
|
|| (back->elf_machine_alt1 != 0
|
|
&& back->elf_machine_alt1 == i_ehdrp->e_machine)
|
|
|| (back->elf_machine_alt2 != 0
|
|
&& back->elf_machine_alt2 == i_ehdrp->e_machine))
|
|
{
|
|
/* target_ptr is an ELF backend which matches this
|
|
object file, so reject the generic ELF target. */
|
|
goto got_wrong_format_error;
|
goto got_wrong_format_error;
|
}
|
|
}
|
|
}
|
|
|
|
if (i_ehdrp->e_type == ET_EXEC)
|
if (i_ehdrp->e_type == ET_EXEC)
|
abfd->flags |= EXEC_P;
|
abfd->flags |= EXEC_P;
|
else if (i_ehdrp->e_type == ET_DYN)
|
else if (i_ehdrp->e_type == ET_DYN)
|
abfd->flags |= DYNAMIC;
|
abfd->flags |= DYNAMIC;
|
Line 631... |
Line 605... |
if (ebd->elf_machine_code != EM_NONE)
|
if (ebd->elf_machine_code != EM_NONE)
|
goto got_no_match;
|
goto got_no_match;
|
}
|
}
|
|
|
if (ebd->elf_machine_code != EM_NONE
|
if (ebd->elf_machine_code != EM_NONE
|
&& i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi)
|
&& i_ehdrp->e_ident[EI_OSABI] != ebd->elf_osabi
|
{
|
&& ebd->elf_osabi != ELFOSABI_NONE)
|
if (ebd->elf_osabi != ELFOSABI_NONE)
|
|
goto got_wrong_format_error;
|
goto got_wrong_format_error;
|
|
|
/* This is an ELFOSABI_NONE ELF target. Let it match any ELF
|
|
target of the compatible machine for which we do not have a
|
|
backend with matching ELFOSABI. */
|
|
for (target_ptr = bfd_target_vector;
|
|
*target_ptr != NULL;
|
|
target_ptr++)
|
|
{
|
|
const struct elf_backend_data *back;
|
|
|
|
/* Skip this target and targets with incompatible byte
|
|
order. */
|
|
if (*target_ptr == target
|
|
|| (*target_ptr)->flavour != bfd_target_elf_flavour
|
|
|| (*target_ptr)->byteorder != target->byteorder
|
|
|| ((*target_ptr)->header_byteorder
|
|
!= target->header_byteorder))
|
|
continue;
|
|
|
|
back = xvec_get_elf_backend_data (*target_ptr);
|
|
if (back->elf_osabi == i_ehdrp->e_ident[EI_OSABI]
|
|
&& (back->elf_machine_code == i_ehdrp->e_machine
|
|
|| (back->elf_machine_alt1 != 0
|
|
&& back->elf_machine_alt1 == i_ehdrp->e_machine)
|
|
|| (back->elf_machine_alt2 != 0
|
|
&& back->elf_machine_alt2 == i_ehdrp->e_machine)))
|
|
{
|
|
/* target_ptr is an ELF backend which matches this
|
|
object file, so reject the ELFOSABI_NONE ELF target. */
|
|
goto got_wrong_format_error;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (i_ehdrp->e_shoff != 0)
|
if (i_ehdrp->e_shoff != 0)
|
{
|
{
|
bfd_signed_vma where = i_ehdrp->e_shoff;
|
bfd_signed_vma where = i_ehdrp->e_shoff;
|
|
|
if (where != (file_ptr) where)
|
if (where != (file_ptr) where)
|