diff options
author | Stu Grossman <grossman@cygnus> | 1992-12-22 01:53:06 +0000 |
---|---|---|
committer | Stu Grossman <grossman@cygnus> | 1992-12-22 01:53:06 +0000 |
commit | 205d660d5953fe51087757e8e89804cfbb13ae2b (patch) | |
tree | 56c47c8e3dd2fd865e3bf0abe87ee55f88590492 | |
parent | 60ac749cab2e4a1033080b4ac27124fbcd136fa5 (diff) | |
download | gdb-205d660d5953fe51087757e8e89804cfbb13ae2b.zip gdb-205d660d5953fe51087757e8e89804cfbb13ae2b.tar.gz gdb-205d660d5953fe51087757e8e89804cfbb13ae2b.tar.bz2 |
* hppa.c: Conditionalize on HOST_HPPAHPUX instead of hp9000s800.
Get rid of HPPA/BSD specific code. That will go somewhere else
someday.
* (fill_spaces): Don't spin forever and die if you don't find
$MILLICODE$ subspace.
* (hppa_object_p): Make sure that we have a real honest-to-cthulu
exec file!
* (hppa_core_file_failing_signal, hppa_core_file_failing_command):
Make these work for HPUX.
* (make_bfd_asection): New routine to make section creation a
little easier.
* (hppa_core_file_p): Completely rewrite, leave out bugs.
* libhppa.h: #include the right system files. Redefine all of
the structs/macros for hacking core files to use more sensible
HPUX core file structures.
* targets.c (target_vector): Conditionalize hppa_vec on
HOST_HPPAHPUX, not hp9000s800.
* hosts/hppahpux.h: #include stdlib.h to get correct decls for
malloc and realloc. #define HOST_HPPAHPUX.
-rw-r--r-- | bfd/ChangeLog | 22 | ||||
-rw-r--r-- | bfd/hppa.c | 270 | ||||
-rw-r--r-- | bfd/libhppa.h | 33 |
3 files changed, 171 insertions, 154 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dc98ac4..30ec21c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,25 @@ +Mon Dec 21 17:24:13 1992 Stu Grossman (grossman at cygnus.com) + + * hppa.c: Conditionalize on HOST_HPPAHPUX instead of hp9000s800. + Get rid of HPPA/BSD specific code. That will go somewhere else + someday. + * (fill_spaces): Don't spin forever and die if you don't find + $MILLICODE$ subspace. + * (hppa_object_p): Make sure that we have a real honest-to-cthulu + exec file! + * (hppa_core_file_failing_signal, hppa_core_file_failing_command): + Make these work for HPUX. + * (make_bfd_asection): New routine to make section creation a + little easier. + * (hppa_core_file_p): Completely rewrite, leave out bugs. + * libhppa.h: #include the right system files. Redefine all of + the structs/macros for hacking core files to use more sensible + HPUX core file structures. + * targets.c (target_vector): Conditionalize hppa_vec on + HOST_HPPAHPUX, not hp9000s800. + * hosts/hppahpux.h: #include stdlib.h to get correct decls for + malloc and realloc. #define HOST_HPPAHPUX. + Mon Dec 21 12:40:10 1992 Ian Lance Taylor (ian@cygnus.com) * Patches from Minh Tran-le <mtranle@paris.intellicorp.com>. @@ -20,30 +20,21 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef hp9000s800 - #include "bfd.h" #include "sysdep.h" + +#ifdef HOST_HPPAHPUX + #include "libbfd.h" #include "libhppa.h" -/* #include "aout/hppa.h" */ - #include <stdio.h> #include <sys/types.h> #include <sys/param.h> #include <sys/dir.h> #include <signal.h> #include <machine/reg.h> -#ifndef hpux -#include <aout/hppa.h> -#include <machine/pcb.h> -#include <sys/time.h> -#include <hpux/hpux.h> -#define USRSTACK 0x68FF3000 -#else #include <sys/user.h> /* After a.out.h */ -#endif #include <sys/file.h> #include <errno.h> @@ -95,15 +86,29 @@ fill_spaces(abfd, file_hdr, dbx_subspace, dbx_strings_subspace) } /* search out the beginning and end if millicode */ bfd_seek (abfd, text_index, SEEK_SET); - for (;;) + for (i = 0; i < file_hdr->subspace_total; i++) { bfd_read ((PTR) &subspace, 1, sizeof(subspace), abfd); if (!strcmp (space_strings + subspace.name.n_strx, "$MILLICODE$")) { millicode_start = subspace.subspace_start; millicode_end = (millicode_start + subspace.subspace_length); - break; } + else if (!strncmp (space_strings + subspace.name.n_strx, "$UNWIND", 7)) + { + int *foo; + long s; + +#if 0 + s = bfd_tell(abfd); + printf("Found %s\n", space_strings + subspace.name.n_strx); + foo = malloc (subspace.initialization_length); + bfd_seek (abfd, subspace.file_loc_init_value, SEEK_SET); + bfd_read (foo, 1, subspace.initialization_length, abfd); + bfd_seek (abfd, s, SEEK_SET); + free (foo); +#endif + } } /* read symbols subspace and strings subspace in possibly arbitrary order. */ @@ -234,6 +239,23 @@ DEFUN(hppa_object_p,(abfd), bfd_error = wrong_format; return 0; } + + if (!_PA_RISC_ID (file_hdr.system_id)) + return 0; + + switch (file_hdr.a_magic) + { + case RELOC_MAGIC: /* I'm not really sure about all of these types... */ + case EXEC_MAGIC: + case SHARE_MAGIC: + case DEMAND_MAGIC: + case DL_MAGIC: + case SHL_MAGIC: + break; + default: + return 0; + } + if (bfd_read ((PTR) &aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE) { bfd_error = wrong_format; @@ -432,141 +454,127 @@ DEFUN (hppa_sizeof_headers, (abfd, reloc), return (0); } -#ifdef hpux -#define hppa_core_file_p _bfd_dummy_target -#else -bfd_target * -hppa_core_file_p (abfd) +static asection * +make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power) bfd *abfd; + const char *name; + flagword flags; + bfd_size_type _raw_size; + bfd_vma vma; + unsigned int alignment_power; { - int val; - struct hpuxuser u; - unsigned int reg_offset, fp_reg_offset; - /* 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 hppa_core_struct coredata; - struct hpuxuser u; - } *rawptr; - - val = bfd_read ((void *)&u, 1, sizeof u, abfd); - if (val != sizeof u) - return 0; /* Too small to be a core file */ - - /* Sanity check perhaps??? */ - if (u.u_dsize > 0x1000000) /* Remember, it's in pages... */ - return 0; - if (u.u_ssize > 0x1000000) - return 0; - /* Check that the size claimed is no greater than the file size. FIXME. */ + asection *asect; - /* OK, we believe you. You're a core file (sure, sure). */ + asect = bfd_zalloc (abfd, sizeof (asection)); + if (!asect) + { + bfd_error = no_memory; + return NULL; + } - /* Allocate both the upage and the struct core_data at once, so - a single free() will free them both. */ - rawptr = (struct core_user *)bfd_zalloc (abfd, sizeof (struct core_user)); - if (rawptr == NULL) { - bfd_error = no_memory; - return 0; - } + asect->name = name; + asect->flags = flags; + asect->_raw_size = _raw_size; + asect->vma = vma; + asect->filepos = bfd_tell (abfd); + asect->alignment_power = alignment_power; - abfd->tdata.hppa_core_data = &rawptr->coredata; - core_upage (abfd) = &rawptr->u; - *core_upage (abfd) = u; /* Save that upage! */ + asect->next = abfd->sections; + abfd->sections = asect; + abfd->section_count++; - /* 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: - bfd_error = no_memory; - free ((void *)rawptr); - return 0; - } - core_datasec (abfd) = (asection *) zalloc (sizeof (asection)); - if (core_datasec (abfd) == NULL) { -loser1: - free ((void *)core_stacksec (abfd)); - goto loser; - } - core_regsec (abfd) = (asection *) zalloc (sizeof (asection)); - if (core_regsec (abfd) == NULL) { -loser2: - free ((void *)core_datasec (abfd)); - goto loser1; - } + return asect; +} + +bfd_target * +hppa_core_file_p (abfd) + bfd *abfd; +{ + core_hdr (abfd) = bfd_zalloc (abfd, sizeof (struct hppa_core_struct)); + if (!core_hdr (abfd)) + return NULL; + while (1) + { + int val; + struct corehead core_header; + + val = bfd_read ((void *)&core_header, 1, sizeof core_header, abfd); + if (val <= 0) + break; + switch (core_header.type) + { + case CORE_KERNEL: + case CORE_FORMAT: + bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */ + break; + case CORE_EXEC: + { + struct proc_exec proc_exec; + bfd_read ((void *)&proc_exec, 1, core_header.len, abfd); + strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1); + } + break; + case CORE_PROC: + { + struct proc_info proc_info; + core_regsec (abfd) = make_bfd_asection (abfd, ".reg", + SEC_ALLOC+SEC_HAS_CONTENTS, + core_header.len, + (int)&proc_info - (int)&proc_info.hw_regs, + 2); + bfd_read (&proc_info, 1, core_header.len, abfd); + core_signal (abfd) = proc_info.sig; + } + if (!core_regsec (abfd)) + return NULL; + break; + case CORE_DATA: + core_datasec (abfd) = make_bfd_asection (abfd, ".data", + SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS, + core_header.len, + core_header.addr, + 2); + if (!core_datasec (abfd)) + return NULL; + bfd_seek (abfd, core_header.len, SEEK_CUR); + break; + case CORE_STACK: + core_stacksec (abfd) = make_bfd_asection (abfd, ".data", + SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS, + core_header.len, + core_header.addr, + 2); + if (!core_stacksec (abfd)) + return NULL; + bfd_seek (abfd, core_header.len, SEEK_CUR); + break; + default: + fprintf (stderr, "Unknown HPPA/HPUX core file section type %d\n", + core_header.type); + bfd_seek (abfd, core_header.len, SEEK_CUR); + break; + } + } - core_stacksec (abfd)->name = ".stack"; - core_datasec (abfd)->name = ".data"; - core_regsec (abfd)->name = ".reg"; - - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; - - core_datasec (abfd)->_raw_size = NBPG * u.u_dsize; - core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize; - core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */ - - core_datasec (abfd)->vma = u.hpuxu_exdata.somexec.a_Dmem; - core_stacksec (abfd)->vma = USRSTACK; /* from sys/param */ - /* 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 - NBPG * USIZE; /* -u_ar0 */ - - core_datasec (abfd)->filepos = NBPG * UPAGES; - core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize; - core_regsec (abfd)->filepos = 0; /* Register segment is the upage */ - - /* Align to word at least */ - core_stacksec (abfd)->alignment_power = 2; - core_datasec (abfd)->alignment_power = 2; - core_regsec (abfd)->alignment_power = 2; - - abfd->sections = core_stacksec (abfd); - core_stacksec (abfd)->next = core_datasec (abfd); - core_datasec (abfd)->next = core_regsec (abfd); - abfd->section_count = 3; + /* OK, we believe you. You're a core file (sure, sure). */ return abfd->xvec; } -#endif -#ifdef hpux -#define hppa_core_file_failing_command (char *(*)())(bfd_nullvoidptr) -#else char * hppa_core_file_failing_command (abfd) bfd *abfd; { -#ifndef NO_CORE_COMMAND - if (*core_upage (abfd)->u_comm) - return core_upage (abfd)->u_comm; - else -#endif - return 0; + return core_command (abfd); } -#endif /* ARGSUSED */ int -hppa_core_file_failing_signal (ignore_abfd) - bfd *ignore_abfd; +hppa_core_file_failing_signal (abfd) + bfd *abfd; { - return -1; /* FIXME, where is it? */ + return core_signal (abfd); } /* ARGSUSED */ @@ -598,7 +606,6 @@ hppa_core_file_matches_executable_p (core_bfd, exec_bfd) bfd_generic_get_relocated_section_contents #define hppa_bfd_relax_section bfd_generic_relax_section -/*SUPPRESS 460 */ bfd_target hppa_vec = { "hppa", /* name */ @@ -643,7 +650,4 @@ _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs JUMP_TABLE(hppa) }; -#else /* notdef hp9000s800 */ -/* Prevent "empty translation unit" warnings from the idiots at X3J11. */ -static char ansi_c_idiots = 69; -#endif /* hp9000s800 */ +#endif /* HOST_HPPAHPUX */ diff --git a/bfd/libhppa.h b/bfd/libhppa.h index 8fedc2b..9158d22 100644 --- a/bfd/libhppa.h +++ b/bfd/libhppa.h @@ -20,31 +20,20 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <sys/core.h> +#include <sys/utsname.h> + #define BYTES_IN_WORD 4 struct header; struct som_exec_auxhdr; struct subspace_dictionary; - - #define FILE_HDR_SIZE sizeof(struct header) #define AUX_HDR_SIZE sizeof(struct som_exec_auxhdr) unsigned int millicode_start, millicode_end; -struct nlist { - union { - char *n_name; - struct nlist *n_next; - long n_strx; - } n_un; - unsigned char n_type; - char n_other; - short n_desc; - unsigned long n_value; -}; - typedef struct hppa_symbol { asymbol symbol; @@ -87,7 +76,6 @@ struct hppa_data_struct { struct hppadata a; }; - #define padata(bfd) ((bfd)->tdata.hppa_data->a) #define obj_file_hdr(bfd) (padata(bfd).file_hdr) #define obj_aux_hdr(bfd) (padata(bfd).aux_hdr) @@ -112,16 +100,19 @@ struct hppa_data_struct { /* These are stored in the bfd's tdata */ + struct hppa_core_struct { - struct hpuxuser *upage; + int sig; + char cmd[MAXCOMLEN + 1]; asection *data_section; asection *stack_section; asection *reg_section; }; - -#define core_upage(bfd) ((bfd)->tdata.hppa_core_data->upage) -#define core_datasec(bfd) ((bfd)->tdata.hppa_core_data->data_section) -#define core_stacksec(bfd) ((bfd)->tdata.hppa_core_data->stack_section) -#define core_regsec(bfd) ((bfd)->tdata.hppa_core_data->reg_section) +#define core_hdr(bfd) ((bfd)->tdata.hppa_core_data) +#define core_signal(bfd) (core_hdr(bfd)->sig) +#define core_command(bfd) (core_hdr(bfd)->cmd) +#define core_datasec(bfd) (core_hdr(bfd)->data_section) +#define core_stacksec(bfd) (core_hdr(bfd)->stack_section) +#define core_regsec(bfd) (core_hdr(bfd)->reg_section) |