From d643978558037f6c74cb1180732283994fe83504 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sat, 26 Feb 1994 00:39:03 +0000 Subject: * som.c (som_get_symtab_upper_bound): Use "sizeof (asymbol *)" not "sizeof (som_symbol_type *)". * elfcode.h (elf_get_symtab_upper_bound): Use "sizeof (asymbol *)" not "sizeof (asymbol"). Opps. --- bfd/elfcode.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'bfd/elfcode.h') 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) -- cgit v1.1