| OLD | NEW |
| 1 /* BFD back-end for OSF/1 core files. | 1 /* BFD back-end for OSF/1 core files. |
| 2 Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, | 2 Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, |
| 3 2007, 2010, 2011 Free Software Foundation, Inc. | 3 2007, 2010, 2011, 2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of BFD, the Binary File Descriptor library. | 5 This file is part of BFD, the Binary File Descriptor library. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| 11 | 11 |
| 12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 13 matching lines...) Expand all Loading... |
| 27 #include "bfd.h" | 27 #include "bfd.h" |
| 28 #include "libbfd.h" | 28 #include "libbfd.h" |
| 29 | 29 |
| 30 #include <sys/user.h> | 30 #include <sys/user.h> |
| 31 #ifdef OSF_CORE | 31 #ifdef OSF_CORE |
| 32 #include <sys/core.h> | 32 #include <sys/core.h> |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 /* forward declarations */ | 35 /* forward declarations */ |
| 36 | 36 |
| 37 static asection *make_bfd_asection | |
| 38 PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr)); | |
| 39 static const bfd_target *osf_core_core_file_p | |
| 40 PARAMS ((bfd *)); | |
| 41 static char *osf_core_core_file_failing_command | |
| 42 PARAMS ((bfd *)); | |
| 43 static int osf_core_core_file_failing_signal | |
| 44 PARAMS ((bfd *)); | |
| 45 #define osf_core_core_file_matches_executable_p generic_core_file_matches_execut
able_p | 37 #define osf_core_core_file_matches_executable_p generic_core_file_matches_execut
able_p |
| 46 #define osf_core_core_file_pid _bfd_nocore_core_file_pid | 38 #define osf_core_core_file_pid _bfd_nocore_core_file_pid |
| 47 static void swap_abort | |
| 48 PARAMS ((void)); | |
| 49 | 39 |
| 50 /* These are stored in the bfd's tdata */ | 40 /* These are stored in the bfd's tdata */ |
| 51 | 41 |
| 52 struct osf_core_struct | 42 struct osf_core_struct |
| 53 { | 43 { |
| 54 int sig; | 44 int sig; |
| 55 char cmd[MAXCOMLEN + 1]; | 45 char cmd[MAXCOMLEN + 1]; |
| 56 }; | 46 }; |
| 57 | 47 |
| 58 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data) | 48 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data) |
| 59 #define core_signal(bfd) (core_hdr(bfd)->sig) | 49 #define core_signal(bfd) (core_hdr(bfd)->sig) |
| 60 #define core_command(bfd) (core_hdr(bfd)->cmd) | 50 #define core_command(bfd) (core_hdr(bfd)->cmd) |
| 61 | 51 |
| 62 static asection * | 52 static asection * |
| 63 make_bfd_asection (abfd, name, flags, size, vma, filepos) | 53 make_bfd_asection (bfd *abfd, |
| 64 bfd *abfd; | 54 » » const char *name, |
| 65 const char *name; | 55 » » flagword flags, |
| 66 flagword flags; | 56 » » bfd_size_type size, |
| 67 bfd_size_type size; | 57 » » bfd_vma vma, |
| 68 bfd_vma vma; | 58 » » file_ptr filepos) |
| 69 file_ptr filepos; | |
| 70 { | 59 { |
| 71 asection *asect; | 60 asection *asect; |
| 72 | 61 |
| 73 asect = bfd_make_section_anyway_with_flags (abfd, name, flags); | 62 asect = bfd_make_section_anyway_with_flags (abfd, name, flags); |
| 74 if (!asect) | 63 if (!asect) |
| 75 return NULL; | 64 return NULL; |
| 76 | 65 |
| 77 asect->size = size; | 66 asect->size = size; |
| 78 asect->vma = vma; | 67 asect->vma = vma; |
| 79 asect->filepos = filepos; | 68 asect->filepos = filepos; |
| 80 asect->alignment_power = 8; | 69 asect->alignment_power = 8; |
| 81 | 70 |
| 82 return asect; | 71 return asect; |
| 83 } | 72 } |
| 84 | 73 |
| 85 static const bfd_target * | 74 static const bfd_target * |
| 86 osf_core_core_file_p (abfd) | 75 osf_core_core_file_p (bfd *abfd) |
| 87 bfd *abfd; | |
| 88 { | 76 { |
| 89 int val; | 77 int val; |
| 90 int i; | 78 int i; |
| 91 char *secname; | 79 char *secname; |
| 92 struct core_filehdr core_header; | 80 struct core_filehdr core_header; |
| 93 bfd_size_type amt; | 81 bfd_size_type amt; |
| 94 | 82 |
| 95 amt = sizeof core_header; | 83 amt = sizeof core_header; |
| 96 val = bfd_bread ((PTR) &core_header, amt, abfd); | 84 val = bfd_bread (& core_header, amt, abfd); |
| 97 if (val != sizeof core_header) | 85 if (val != sizeof core_header) |
| 98 return NULL; | 86 return NULL; |
| 99 | 87 |
| 100 if (! CONST_STRNEQ (core_header.magic, "Core")) | 88 if (! CONST_STRNEQ (core_header.magic, "Core")) |
| 101 return NULL; | 89 return NULL; |
| 102 | 90 |
| 103 core_hdr (abfd) = (struct osf_core_struct *) | 91 core_hdr (abfd) = (struct osf_core_struct *) |
| 104 bfd_zalloc (abfd, (bfd_size_type) sizeof (struct osf_core_struct)); | 92 bfd_zalloc (abfd, (bfd_size_type) sizeof (struct osf_core_struct)); |
| 105 if (!core_hdr (abfd)) | 93 if (!core_hdr (abfd)) |
| 106 return NULL; | 94 return NULL; |
| 107 | 95 |
| 108 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1); | 96 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1); |
| 109 core_signal (abfd) = core_header.signo; | 97 core_signal (abfd) = core_header.signo; |
| 110 | 98 |
| 111 for (i = 0; i < core_header.nscns; i++) | 99 for (i = 0; i < core_header.nscns; i++) |
| 112 { | 100 { |
| 113 struct core_scnhdr core_scnhdr; | 101 struct core_scnhdr core_scnhdr; |
| 114 flagword flags; | 102 flagword flags; |
| 115 | 103 |
| 116 amt = sizeof core_scnhdr; | 104 amt = sizeof core_scnhdr; |
| 117 val = bfd_bread ((PTR) &core_scnhdr, amt, abfd); | 105 val = bfd_bread (& core_scnhdr, amt, abfd); |
| 118 if (val != sizeof core_scnhdr) | 106 if (val != sizeof core_scnhdr) |
| 119 break; | 107 break; |
| 120 | 108 |
| 121 /* Skip empty sections. */ | 109 /* Skip empty sections. */ |
| 122 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0) | 110 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0) |
| 123 continue; | 111 continue; |
| 124 | 112 |
| 125 switch (core_scnhdr.scntype) | 113 switch (core_scnhdr.scntype) |
| 126 { | 114 { |
| 127 case SCNRGN: | 115 case SCNRGN: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 151 | 139 |
| 152 /* OK, we believe you. You're a core file (sure, sure). */ | 140 /* OK, we believe you. You're a core file (sure, sure). */ |
| 153 | 141 |
| 154 return abfd->xvec; | 142 return abfd->xvec; |
| 155 | 143 |
| 156 fail: | 144 fail: |
| 157 bfd_release (abfd, core_hdr (abfd)); | 145 bfd_release (abfd, core_hdr (abfd)); |
| 158 core_hdr (abfd) = NULL; | 146 core_hdr (abfd) = NULL; |
| 159 bfd_section_list_clear (abfd); | 147 bfd_section_list_clear (abfd); |
| 160 return NULL; | 148 return NULL; |
error: old chunk mismatch |
None
| OLD | NEW |