diff options
author | John Gilmore <gnu@cygnus> | 1991-10-16 18:56:07 +0000 |
---|---|---|
committer | John Gilmore <gnu@cygnus> | 1991-10-16 18:56:07 +0000 |
commit | 637942e4dbd4b110d30e045b75d07f75fa6ee132 (patch) | |
tree | 2b0148c445abab2e2924c83940998bc77ae7b80c /bfd/trad-core.c | |
parent | 492e5572360c57f4568bf50fee686a7a4dfecd9c (diff) | |
download | fsf-binutils-gdb-637942e4dbd4b110d30e045b75d07f75fa6ee132.zip fsf-binutils-gdb-637942e4dbd4b110d30e045b75d07f75fa6ee132.tar.gz fsf-binutils-gdb-637942e4dbd4b110d30e045b75d07f75fa6ee132.tar.bz2 |
* trad-core.c: Pass the u.u_ar0 value as the negative of the
virtual-memory-address of the .reg section. We can't just make a
section for "all the regs and nothing else" because only GDB knows
exactly where the regs are (scattered around the upage and stack).
Clean up memory allocation. Remove big- and little-endian
vectors, replace with single vector; this only runs on the host,
in host byte order. Replace byteswap routines with aborts in case
anyone calls them.
* targets.c: There's only one trad_core_vec now.
* aoutf1.h (sunos_core_file_p): VMA of .reg* now needs to be 0.
Diffstat (limited to 'bfd/trad-core.c')
-rw-r--r-- | bfd/trad-core.c | 103 |
1 files changed, 50 insertions, 53 deletions
diff --git a/bfd/trad-core.c b/bfd/trad-core.c index 7442666..cd64383 100644 --- a/bfd/trad-core.c +++ b/bfd/trad-core.c @@ -21,17 +21,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* 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> @@ -57,20 +57,22 @@ struct core_data { #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) @@ -87,18 +89,18 @@ trad_unix_core_file_p (abfd) /* 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: @@ -139,7 +141,21 @@ loser2: 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; @@ -156,7 +172,6 @@ loser2: abfd->section_count = 3; return abfd->xvec; -#endif } char * @@ -231,10 +246,18 @@ trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd) #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 */ @@ -245,41 +268,15 @@ bfd_target trad_core_big_vec = ' ', /* 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) -}; |