X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felfcore.h;h=b1cf42d79fabe233863d6466d3820e4cb717d156;hb=0bf60745767d2465c81ee57ae7705a62d6d8fafe;hp=cd218066dc494172be11ac319b1d9a9b2e553b4a;hpb=0c83546ac6ce48331e66584c9119fe258d0d1bfc;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elfcore.h b/bfd/elfcore.h index cd218066dc..b1cf42d79f 100644 --- a/bfd/elfcore.h +++ b/bfd/elfcore.h @@ -1,5 +1,5 @@ /* ELF core file support for BFD. - Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003 + Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -16,26 +16,22 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ char* -elf_core_file_failing_command (abfd) - bfd *abfd; +elf_core_file_failing_command (bfd *abfd) { return elf_tdata (abfd)->core_command; } int -elf_core_file_failing_signal (abfd) - bfd *abfd; +elf_core_file_failing_signal (bfd *abfd) { return elf_tdata (abfd)->core_signal; } bfd_boolean -elf_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd; - bfd *exec_bfd; +elf_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd) { char* corename; @@ -55,7 +51,7 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd) execname = execname ? execname + 1 : exec_bfd->filename; - if (strcmp(execname, corename) != 0) + if (strcmp (execname, corename) != 0) return FALSE; } @@ -74,22 +70,20 @@ elf_core_file_matches_executable_p (core_bfd, exec_bfd) floating point registers (.reg2). */ const bfd_target * -elf_core_file_p (abfd) - bfd *abfd; +elf_core_file_p (bfd *abfd) { Elf_External_Ehdr x_ehdr; /* Elf file header, external form. */ Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form. */ Elf_Internal_Phdr *i_phdrp; /* Elf program header, internal form. */ unsigned int phindex; - struct elf_backend_data *ebd; + const struct elf_backend_data *ebd; struct bfd_preserve preserve; bfd_size_type amt; preserve.marker = NULL; /* Read in the ELF header in external format. */ - if (bfd_bread ((PTR) &x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd) - != sizeof (x_ehdr)) + if (bfd_bread (&x_ehdr, sizeof (x_ehdr), abfd) != sizeof (x_ehdr)) { if (bfd_get_error () != bfd_error_system_call) goto wrong; @@ -159,11 +153,11 @@ elf_core_file_p (abfd) for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++) { - struct elf_backend_data *back; + const struct elf_backend_data *back; if ((*target_ptr)->flavour != bfd_target_elf_flavour) continue; - back = (struct elf_backend_data *) (*target_ptr)->backend_data; + back = (const struct elf_backend_data *) (*target_ptr)->backend_data; if (back->elf_machine_code == i_ehdrp->e_machine || (back->elf_machine_alt1 != 0 && i_ehdrp->e_machine == back->elf_machine_alt1) @@ -193,7 +187,7 @@ elf_core_file_p (abfd) /* Allocate space for the program headers. */ amt = sizeof (*i_phdrp) * i_ehdrp->e_phnum; - i_phdrp = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt); + i_phdrp = bfd_alloc (abfd, amt); if (!i_phdrp) goto fail; @@ -204,8 +198,7 @@ elf_core_file_p (abfd) { Elf_External_Phdr x_phdr; - if (bfd_bread ((PTR) &x_phdr, (bfd_size_type) sizeof (x_phdr), abfd) - != sizeof (x_phdr)) + if (bfd_bread (&x_phdr, sizeof (x_phdr), abfd) != sizeof (x_phdr)) goto fail; elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex); @@ -214,12 +207,19 @@ elf_core_file_p (abfd) /* Set the machine architecture. Do this before processing the program headers since we need to know the architecture type when processing the notes of some systems' core files. */ - if (! bfd_default_set_arch_mach (abfd, ebd->arch, 0)) - { + if (! bfd_default_set_arch_mach (abfd, ebd->arch, 0) /* It's OK if this fails for the generic target. */ - if (ebd->elf_machine_code != EM_NONE) - goto fail; - } + && ebd->elf_machine_code != EM_NONE) + goto fail; + + /* Let the backend double check the format and override global + information. We do this before processing the program headers + to allow the correct machine (as opposed to just the default + machine) to be set, making it possible for grok_prstatus and + grok_psinfo to rely on the mach setting. */ + if (ebd->elf_backend_object_p != NULL + && ! ebd->elf_backend_object_p (abfd)) + goto wrong; /* Process each program header. */ for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex) @@ -229,12 +229,6 @@ elf_core_file_p (abfd) /* Save the entry point from the ELF header. */ bfd_get_start_address (abfd) = i_ehdrp->e_entry; - /* Let the backend double check the format and override global - information. */ - if (ebd->elf_backend_object_p - && (! (*ebd->elf_backend_object_p) (abfd))) - goto wrong; - bfd_preserve_finish (abfd, &preserve); return abfd->xvec;