/* To use this file on a particular host, configure the host with these
parameters in the config/h-HOST file:
- HDEFINES=-DHOST_SYS=WHATEVER_SYS -DTRAD_CORE
+ HDEFINES=-DTRAD_CORE
HDEPFILES=trad-core.o
*/
-#include <sysdep.h>
#include "bfd.h"
-#include <stdio.h>
+#include "sysdep.h"
#include "libbfd.h"
#include "libaout.h" /* BFD a.out internal data structures */
+#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/dir.h>
#define core_stacksec(bfd) (((struct core_data*)((bfd)->tdata))->stack_section)
#define core_regsec(bfd) (((struct core_data *) ((bfd)->tdata))->reg_section)
+/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
+
/* ARGSUSED */
bfd_target *
trad_unix_core_file_p (abfd)
bfd *abfd;
{
-#if HOST_SYS == SUN4_SYS
- return 0;
-#else
int val;
- char *rawptr;
struct user u;
unsigned int reg_offset, fp_reg_offset;
-
- /* 4.2-style (and perhaps also sysV-style) core dump file. */
+ /* This struct is just for allocating two things with one zalloc, so
+ they will be freed together, without violating alignment constraints. */
+ struct core_user {
+ struct core_data coredata;
+ struct user u;
+ } *rawptr;
val = bfd_read ((void *)&u, 1, sizeof u, abfd);
if (val != sizeof u)
/* Allocate both the upage and the struct core_data at once, so
a single free() will free them both. */
- rawptr = (char *)zalloc (sizeof (u) + sizeof (struct core_data));
+ rawptr = (struct core_user *)bfd_zalloc (abfd, sizeof (struct core_user));
if (rawptr == NULL) {
bfd_error = no_memory;
return 0;
}
- set_tdata (abfd, (struct core_data *)rawptr);
- core_upage (abfd) = (struct user *)(rawptr + sizeof (struct core_data));
+ set_tdata (abfd, &rawptr->coredata);
+ core_upage (abfd) = &rawptr->u;
*core_upage (abfd) = u; /* Save that upage! */
- /* create the sections. This is raunchy, but bfd_close wants to reclaim
- them */
+ /* Create the sections. This is raunchy, but bfd_close wants to free
+ them separately. */
core_stacksec (abfd) = (asection *) zalloc (sizeof (asection));
if (core_stacksec (abfd) == NULL) {
loser:
core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize);
#endif
core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);
- core_regsec (abfd)->vma = -1;
+ /* This is tricky. As the "register section", we give them the entire
+ upage and stack. u.u_ar0 points to where "register 0" is stored.
+ There are two tricks with this, though. One is that the rest of the
+ registers might be at positive or negative (or both) displacements
+ from *u_ar0. The other is that u_ar0 is sometimes an absolute address
+ in kernel memory, and on other systems it is an offset from the beginning
+ of the `struct user'.
+
+ As a practical matter, we don't know where the registers actually are,
+ so we have to pass the whole area to GDB. We encode the value of u_ar0
+ by setting the .regs section up so that its virtual memory address
+ 0 is at the place pointed to by u_ar0 (by setting the vma of the start
+ of the section to -u_ar0). GDB uses this info to locate the regs,
+ using minor trickery to get around the offset-or-absolute-addr problem. */
+ core_regsec (abfd)->vma = 0 - (int) u.u_ar0;
core_datasec (abfd)->filepos = NBPG * UPAGES;
core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize;
abfd->section_count = 3;
return abfd->xvec;
-#endif
}
char *
#define trad_unix_bfd_debug_info_accumulate (PROTO (void, (*), \
(bfd *, struct sec *))) bfd_void
+/* If somebody calls any byte-swapping routines, shoot them. */
+void
+swap_abort()
+{
+ abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+}
+#define NO_GET ((PROTO(bfd_vma, (*), ( bfd_byte *))) swap_abort )
+#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
-bfd_target trad_core_big_vec =
+bfd_target trad_core_vec =
{
- "trad-core-big",
+ "trad-core",
bfd_target_unknown_flavour,
true, /* target byte order */
true, /* target headers byte order */
' ', /* ar_pad_char */
16, /* ar_max_namelen */
3, /* minimum alignment power */
- _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
- _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
-
- {_bfd_dummy_target, _bfd_dummy_target,
- _bfd_dummy_target, trad_unix_core_file_p},
- {bfd_false, bfd_false, /* bfd_create_object */
- bfd_false, bfd_false},
- {bfd_false, bfd_false, /* bfd_write_contents */
- bfd_false, bfd_false},
+ NO_GET, NO_PUT, NO_GET, NO_PUT, NO_GET, NO_PUT, /* data */
+ NO_GET, NO_PUT, NO_GET, NO_PUT, NO_GET, NO_PUT, /* hdrs */
+
+ {_bfd_dummy_target, _bfd_dummy_target,
+ _bfd_dummy_target, trad_unix_core_file_p},
+ {bfd_false, bfd_false, /* bfd_create_object */
+ bfd_false, bfd_false},
+ {bfd_false, bfd_false, /* bfd_write_contents */
+ bfd_false, bfd_false},
JUMP_TABLE(trad_unix)
};
-
-bfd_target trad_core_little_vec =
-{
- "trad-core-little",
- bfd_target_unknown_flavour,
- false, /* target byte order */
- false, /* target headers byte order */
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- ' ', /* ar_pad_char */
- 16, /* ar_max_namelen */
- 3, /* minimum alignment power */
- _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putb16,
- _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
-
- {_bfd_dummy_target, _bfd_dummy_target,
- _bfd_dummy_target, trad_unix_core_file_p},
- {bfd_false, bfd_false, /* bfd_create_object */
- bfd_false, bfd_false},
- {bfd_false, bfd_false, /* bfd_write_contents */
- bfd_false, bfd_false},
-
- JUMP_TABLE(trad_unix)
-};