1 /* BFD back-end for OSF/1 core files.
2 Copyright (C) 1993-2016 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
22 /* This file can only be compiled on systems which use OSF/1 style
34 /* forward declarations */
36 #define osf_core_core_file_matches_executable_p generic_core_file_matches_executable_p
37 #define osf_core_core_file_pid _bfd_nocore_core_file_pid
39 /* These are stored in the bfd's tdata */
41 struct osf_core_struct
44 char cmd[MAXCOMLEN + 1];
47 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
48 #define core_signal(bfd) (core_hdr(bfd)->sig)
49 #define core_command(bfd) (core_hdr(bfd)->cmd)
52 make_bfd_asection (bfd *abfd,
61 asect = bfd_make_section_anyway_with_flags (abfd, name, flags);
67 asect->filepos = filepos;
68 asect->alignment_power = 8;
73 static const bfd_target *
74 osf_core_core_file_p (bfd *abfd)
79 struct core_filehdr core_header;
82 amt = sizeof core_header;
83 val = bfd_bread (& core_header, amt, abfd);
84 if (val != sizeof core_header)
87 if (! CONST_STRNEQ (core_header.magic, "Core"))
90 core_hdr (abfd) = (struct osf_core_struct *)
91 bfd_zalloc (abfd, (bfd_size_type) sizeof (struct osf_core_struct));
95 strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
96 core_signal (abfd) = core_header.signo;
98 for (i = 0; i < core_header.nscns; i++)
100 struct core_scnhdr core_scnhdr;
103 amt = sizeof core_scnhdr;
104 val = bfd_bread (& core_scnhdr, amt, abfd);
105 if (val != sizeof core_scnhdr)
108 /* Skip empty sections. */
109 if (core_scnhdr.size == 0 || core_scnhdr.scnptr == 0)
112 switch (core_scnhdr.scntype)
116 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
120 flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
124 flags = SEC_HAS_CONTENTS;
127 (*_bfd_error_handler) (_("Unhandled OSF/1 core file section type %d\n"),
128 core_scnhdr.scntype);
132 if (!make_bfd_asection (abfd, secname, flags,
133 (bfd_size_type) core_scnhdr.size,
134 (bfd_vma) core_scnhdr.vaddr,
135 (file_ptr) core_scnhdr.scnptr))
139 /* OK, we believe you. You're a core file (sure, sure). */
144 bfd_release (abfd, core_hdr (abfd));
145 core_hdr (abfd) = NULL;
146 bfd_section_list_clear (abfd);
151 osf_core_core_file_failing_command (bfd *abfd)
153 return core_command (abfd);
157 osf_core_core_file_failing_signal (bfd *abfd)
159 return core_signal (abfd);
162 /* If somebody calls any byte-swapping routines, shoot them. */
166 abort (); /* This way doesn't require any declaration for ANSI to fuck up */
169 #define NO_GET ((bfd_vma (*) (const void *)) swap_abort)
170 #define NO_PUT ((void (*) (bfd_vma, void *)) swap_abort)
171 #define NO_GETS ((bfd_signed_vma (*) (const void *)) swap_abort)
172 #define NO_GET64 ((bfd_uint64_t (*) (const void *)) swap_abort)
173 #define NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort)
174 #define NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort)
176 const bfd_target core_osf_vec =
179 bfd_target_unknown_flavour,
180 BFD_ENDIAN_LITTLE, /* target byte order */
181 BFD_ENDIAN_LITTLE, /* target headers byte order */
182 (HAS_RELOC | EXEC_P | /* object flags */
183 HAS_LINENO | HAS_DEBUG |
184 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
185 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
186 0, /* symbol prefix */
187 ' ', /* ar_pad_char */
188 16, /* ar_max_namelen */
189 0, /* match priority. */
190 NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit data */
191 NO_GET, NO_GETS, NO_PUT, /* 32 bit data */
192 NO_GET, NO_GETS, NO_PUT, /* 16 bit data */
193 NO_GET64, NO_GETS64, NO_PUT64, /* 64 bit hdrs */
194 NO_GET, NO_GETS, NO_PUT, /* 32 bit hdrs */
195 NO_GET, NO_GETS, NO_PUT, /* 16 bit hdrs */
197 { /* bfd_check_format */
198 _bfd_dummy_target, /* unknown format */
199 _bfd_dummy_target, /* object file */
200 _bfd_dummy_target, /* archive */
201 osf_core_core_file_p /* a core file */
203 { /* bfd_set_format */
204 bfd_false, bfd_false,
207 { /* bfd_write_contents */
208 bfd_false, bfd_false,
212 BFD_JUMP_TABLE_GENERIC (_bfd_generic),
213 BFD_JUMP_TABLE_COPY (_bfd_generic),
214 BFD_JUMP_TABLE_CORE (osf_core),
215 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
216 BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols),
217 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
218 BFD_JUMP_TABLE_WRITE (_bfd_generic),
219 BFD_JUMP_TABLE_LINK (_bfd_nolink),
220 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
224 NULL /* backend_data */