X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=bfd%2Felfcore.h;h=c51c575606d7db86a1b456d2c3d23b2014a36e95;hp=dbf939757283a13ad3afb9588e5b63c1f5c2e8db;hb=88750007d7869f178f0ba528f41efd3b74c424cf;hpb=6df9443a374e2b81278c61b8afc0a1eef7db280b diff --git a/bfd/elfcore.h b/bfd/elfcore.h index dbf9397..c51c575 100644 --- a/bfd/elfcore.h +++ b/bfd/elfcore.h @@ -1,6 +1,6 @@ /* ELF core file support for BFD. - Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007 - Free Software Foundation, Inc. + Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007, + 2008 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -159,6 +159,8 @@ elf_core_file_p (bfd *abfd) 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 && i_ehdrp->e_machine == back->elf_machine_alt1) @@ -188,7 +190,7 @@ elf_core_file_p (bfd *abfd) /* Allocate space for the program headers. */ amt = sizeof (*i_phdrp) * i_ehdrp->e_phnum; - i_phdrp = bfd_alloc (abfd, amt); + i_phdrp = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt); if (!i_phdrp) goto fail; @@ -227,6 +229,32 @@ elf_core_file_p (bfd *abfd) if (! bfd_section_from_phdr (abfd, i_phdrp + phindex, (int) phindex)) goto fail; + /* Check for core truncation. */ + { + bfd_size_type high = 0; + struct stat statbuf; + for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex) + { + Elf_Internal_Phdr *p = i_phdrp + phindex; + if (p->p_filesz) + { + bfd_size_type current = p->p_offset + p->p_filesz; + if (high < current) + high = current; + } + } + if (bfd_stat (abfd, &statbuf) == 0) + { + if ((bfd_size_type) statbuf.st_size < high) + { + (*_bfd_error_handler) + (_("Warning: %B is truncated: expected core file " + "size >= %lu, found: %lu."), + abfd, (unsigned long) high, (unsigned long) statbuf.st_size); + } + } + } + /* Save the entry point from the ELF header. */ bfd_get_start_address (abfd) = i_ehdrp->e_entry;