1 /* BFD back end for Lynx core files
2 Copyright 1993 Free Software Foundation, Inc.
3 Written by Stu Grossman of Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
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
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #ifdef HOST_LYNX /* Core files only work locally for now */
27 /* These are stored in the bfd's tdata */
29 struct lynx_core_struct
35 #define core_hdr(bfd) ((bfd)->tdata.lynx_core_data)
36 #define core_signal(bfd) (core_hdr(bfd)->sig)
37 #define core_command(bfd) (core_hdr(bfd)->cmd)
39 /* Handle Lynx core dump file. */
42 make_bfd_asection (abfd
, name
, flags
, _raw_size
, vma
, filepos
)
46 bfd_size_type _raw_size
;
53 newname
= bfd_alloc (abfd
, strlen (name
) + 1);
57 strcpy (newname
, name
);
59 asect
= bfd_make_section (abfd
, newname
);
64 asect
->_raw_size
= _raw_size
;
66 asect
->filepos
= filepos
;
67 asect
->alignment_power
= 2;
74 lynx_core_file_p (abfd
)
85 pagesize
= getpagesize (); /* Serious cross-target issue here... This
86 really needs to come from a system-specific
89 /* Get the pss entry from the core file */
91 bfd_seek (abfd
, 0, SEEK_SET
);
93 val
= bfd_read ((void *)&pss
, 1, sizeof pss
, abfd
);
94 if (val
!= sizeof pss
)
96 /* Too small to be a core file */
97 bfd_error
= wrong_format
;
101 core_hdr (abfd
) = (struct lynx_core_struct
*)
102 bfd_zalloc (abfd
, sizeof (struct lynx_core_struct
));
104 if (!core_hdr (abfd
))
106 bfd_error
= no_memory
;
110 strncpy (core_command (abfd
), pss
.pname
, PNMLEN
+ 1);
112 /* Compute the size of the thread contexts */
114 tcontext_size
= pss
.threadcnt
* sizeof (core_st_t
);
116 /* Allocate space for the thread contexts */
118 threadp
= (core_st_t
*)bfd_zalloc (abfd
, tcontext_size
);
121 bfd_error
= no_memory
;
125 /* Save thread contexts */
127 bfd_seek (abfd
, pagesize
, SEEK_SET
);
129 val
= bfd_read ((void *)threadp
, pss
.threadcnt
, sizeof (core_st_t
), abfd
);
131 if (val
!= tcontext_size
)
133 /* Probably too small to be a core file */
134 bfd_error
= wrong_format
;
138 core_signal (abfd
) = threadp
->currsig
;
140 newsect
= make_bfd_asection (abfd
, ".stack",
141 SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
,
144 pagesize
+ tcontext_size
);
147 bfd_error
= no_memory
;
151 newsect
= make_bfd_asection (abfd
, ".data",
152 SEC_ALLOC
+ SEC_LOAD
+ SEC_HAS_CONTENTS
,
153 pss
.data_len
+ pss
.bss_len
,
155 pagesize
+ tcontext_size
+ pss
.ssize
);
158 bfd_error
= no_memory
;
162 for (secnum
= 0; secnum
< pss
.threadcnt
; secnum
++)
166 sprintf (secname
, ".reg%d", threadp
[secnum
].tid
);
167 newsect
= make_bfd_asection (abfd
, secname
,
168 SEC_ALLOC
+ SEC_HAS_CONTENTS
,
171 pagesize
+ secnum
* sizeof (core_st_t
));
174 bfd_error
= no_memory
;
183 lynx_core_file_failing_command (abfd
)
186 return core_command (abfd
);
191 lynx_core_file_failing_signal (abfd
)
194 return core_signal (abfd
);
199 lynx_core_file_matches_executable_p (core_bfd
, exec_bfd
)
200 bfd
*core_bfd
, *exec_bfd
;
202 return true; /* FIXME, We have no way of telling at this point */
205 #endif /* HOST_LYNX */