diff options
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r-- | bfd/elfcode.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h index b515853..b298763 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -2742,7 +2742,7 @@ DEFUN (elf_get_symtab_upper_bound, (abfd), bfd * abfd) Elf_Internal_Shdr *hdr = &elf_tdata(abfd)->symtab_hdr; symcount = hdr->sh_size / sizeof (Elf_External_Sym); - symtab_size = (symcount - 1 + 1) * (sizeof (asymbol)); + symtab_size = (symcount - 1 + 1) * (sizeof (asymbol *)); return symtab_size; } @@ -3549,6 +3549,7 @@ DEFUN (elf_core_file_p, (abfd), bfd * abfd) Elf_External_Phdr x_phdr; /* Program header table entry, external form */ Elf_Internal_Phdr *i_phdrp; /* Program header table, internal form */ unsigned int phindex; + struct elf_backend_data *ebd; /* Read in the ELF header in external format. */ @@ -3621,6 +3622,35 @@ DEFUN (elf_core_file_p, (abfd), bfd * abfd) elf_debug_file (i_ehdrp); #endif + ebd = get_elf_backend_data (abfd); + + /* Check that the ELF e_machine field matches what this particular + BFD format expects. */ + if (ebd->elf_machine_code != i_ehdrp->e_machine) + { + bfd_target **target_ptr; + + if (ebd->elf_machine_code != EM_NONE) + goto wrong; + + /* 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++) + { + struct elf_backend_data *back; + + if ((*target_ptr)->flavour != bfd_target_elf_flavour) + continue; + back = (struct elf_backend_data *) (*target_ptr)->backend_data; + if (back->elf_machine_code == i_ehdrp->e_machine) + { + /* target_ptr is an ELF backend which matches this + object file, so reject the generic ELF target. */ + goto wrong; + } + } + } + /* If there is no program header, or the type is not a core file, then we are hosed. */ if (i_ehdrp->e_phoff == 0 || i_ehdrp->e_type != ET_CORE) |