diff options
author | Ken Raeburn <raeburn@cygnus> | 1992-10-09 01:39:06 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@cygnus> | 1992-10-09 01:39:06 +0000 |
commit | 214f8f2392b9c23f589ca2346e30faff01d8e09f (patch) | |
tree | 3b1451d1fadee02d2a00c2d4529b10bd660783f6 /bfd/aoutf1.h | |
parent | d047d16af719a72d659c032f7b62bf7b1476c3e5 (diff) | |
download | gdb-214f8f2392b9c23f589ca2346e30faff01d8e09f.zip gdb-214f8f2392b9c23f589ca2346e30faff01d8e09f.tar.gz gdb-214f8f2392b9c23f589ca2346e30faff01d8e09f.tar.bz2 |
* aout-target.h (callback): Don't define this function if it won't be used.
* aoutx.h (some_aout_object_p): Restore old aout_data value if this type
doesn't match. Don't lose if file sections have already been created.
(set_arch_mach): Set reloc_entry_size.
(slurp_symbol_table): Use bfd_h_get_{16,8} for reaeding symbol data.
* hosts/i386bsd.h: New file.
* configure.in: Recognize i[34]86-*-bsd host.
* aout-target.h (callback, write_object_contents): Delete unused variables.
* aoutx.h (reloc_type_lookup): New function.
* aout-target.h (MY_reloc_howto_type_lookup): Use it as default.
* aoutf1.h (sunos4_reloc_type_lookup): Deleted.
(MY_reloc_howto_type_lookup): Don't define it.
* aoutx.h (adjust_sizes_and_vmas): Don't bother with padding for OMAGIC files.
(slurp_symbol_table): Use header byte order, not target byte order, for reading
symbol data.
Diffstat (limited to 'bfd/aoutf1.h')
-rw-r--r-- | bfd/aoutf1.h | 183 |
1 files changed, 97 insertions, 86 deletions
diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h index 491bc54..8f4906c 100644 --- a/bfd/aoutf1.h +++ b/bfd/aoutf1.h @@ -53,64 +53,17 @@ The name put into the target vector. void (*bfd_error_trap)(); -static bfd_target *sunos4_callback (); - /*SUPPRESS558*/ /*SUPPRESS529*/ -bfd_target * -DEFUN(NAME(sunos,object_p), (abfd), - bfd *abfd) -{ - struct external_exec exec_bytes; /* Raw exec header from file */ - struct internal_exec exec; /* Cleaned-up exec header */ - - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); - - if (N_BADMAG (exec)) return 0; - - NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); - - return NAME(aout,some_aout_object_p) (abfd, &exec, sunos4_callback); -} - - /* Determine the size of a relocation entry, based on the architecture */ -static void -DEFUN(choose_reloc_size,(abfd), -bfd *abfd) -{ - switch (bfd_get_arch(abfd)) { - case bfd_arch_sparc: - case bfd_arch_a29k: - obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; - break; - default: - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - break; - } -} - -/* Set parameters about this a.out file that are machine-dependent. - This routine is called from some_aout_object_p just before it returns. */ - -static bfd_target * -sunos4_callback (abfd) - bfd *abfd; +void +DEFUN(NAME(sunos,set_arch_mach), (abfd, machtype), + bfd *abfd AND int machtype) { - struct internal_exec *execp = exec_hdr (abfd); + /* Determine the architecture and machine type of the object file. */ enum bfd_architecture arch; long machine; - - WORK_OUT_FILE_POSITIONS(abfd, execp); - - /* Determine the architecture and machine type of the object file. */ - switch (N_MACHTYPE (*exec_hdr (abfd))) { + switch (machtype) { case M_UNKNOWN: /* Some Sun3s make magic numbers without cpu types in them, so @@ -157,18 +110,27 @@ sunos4_callback (abfd) break; } bfd_set_arch_mach(abfd, arch, machine); - choose_reloc_size(abfd); - adata(abfd)->page_size = PAGE_SIZE; -#ifdef SEGMENT_SIZE - adata(abfd)->segment_size = SEGMENT_SIZE; -#else - adata(abfd)->segment_size = PAGE_SIZE; -#endif - adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE; - - return abfd->xvec; } +#define SET_ARCH_MACH(ABFD, EXEC) \ + NAME(sunos,set_arch_mach)(ABFD, N_MACHTYPE (EXEC)); \ + choose_reloc_size(ABFD); + +/* Determine the size of a relocation entry, based on the architecture */ +static void +DEFUN(choose_reloc_size,(abfd), +bfd *abfd) +{ + switch (bfd_get_arch(abfd)) { + case bfd_arch_sparc: + case bfd_arch_a29k: + obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; + break; + default: + obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; + break; + } +} /* Write an object file in SunOS format. Section contents have already been written. We write the @@ -183,8 +145,6 @@ DEFUN(NAME(aout,sunos4_write_object_contents), struct external_exec exec_bytes; struct internal_exec *execp = exec_hdr (abfd); - execp->a_text = obj_textsec (abfd)->size; - /* Magic number, maestro, please! */ switch (bfd_get_arch(abfd)) { case bfd_arch_m68k: @@ -217,7 +177,7 @@ DEFUN(NAME(aout,sunos4_write_object_contents), N_SET_FLAGS (*execp, 0x1); WRITE_HEADERS(abfd, execp); - + return true; } @@ -338,7 +298,7 @@ DEFUN(swapcore_sun3,(abfd, ext, intcore), intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize); intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize); - bcopy (extcore->c_cmdname, intcore->c_cmdname, sizeof (intcore->c_cmdname)); + memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); intcore->fp_stuff_pos = (long) (((struct external_sun3_core *)0)->fp_stuff); /* FP stuff takes up whole rest of struct, except c_ucode. */ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - @@ -369,7 +329,7 @@ DEFUN(swapcore_sparc,(abfd, ext, intcore), intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize); intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize); intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize); - bcopy (extcore->c_cmdname, intcore->c_cmdname, sizeof (intcore->c_cmdname)); + memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname)); intcore->fp_stuff_pos = (long) (((struct external_sparc_core *)0)->fp_stuff); /* FP stuff takes up whole rest of struct, except c_ucode. */ intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - @@ -385,14 +345,14 @@ DEFUN(swapcore_sparc,(abfd, ext, intcore), } /* need this cast because ptr is really void * */ -#define core_hdr(bfd) (((struct suncoredata *) (bfd->tdata))->hdr) -#define core_datasec(bfd) (((struct suncoredata *) ((bfd)->tdata))->data_section) -#define core_stacksec(bfd) (((struct suncoredata*)((bfd)->tdata))->stack_section) -#define core_regsec(bfd) (((struct suncoredata *) ((bfd)->tdata))->reg_section) -#define core_reg2sec(bfd) (((struct suncoredata *) ((bfd)->tdata))->reg2_section) +#define core_hdr(bfd) ((bfd)->tdata.sun_core_data) +#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) +#define core_reg2sec(bfd) (core_hdr(bfd)->reg2_section) /* These are stored in the bfd's tdata */ -struct suncoredata { +struct sun_core_struct { struct internal_sunos_core *hdr; /* core file header */ asection *data_section; asection *stack_section; @@ -410,7 +370,7 @@ DEFUN(sunos4_core_file_p,(abfd), struct internal_sunos_core *core; char *extcore; struct mergem { - struct suncoredata suncoredata; + struct sun_core_struct suncoredata; struct internal_sunos_core internal_sunos_core; char external_core[1]; } *mergem; @@ -466,8 +426,8 @@ DEFUN(sunos4_core_file_p,(abfd), return 0; } - set_tdata (abfd, &mergem->suncoredata); - core_hdr (abfd) = core; + abfd->tdata.sun_core_data = &mergem->suncoredata; + abfd->tdata.sun_core_data->hdr = core; /* create the sections. This is raunchy, but bfd_close wants to reclaim them */ @@ -506,10 +466,10 @@ DEFUN(sunos4_core_file_p,(abfd), core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; core_reg2sec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; - core_stacksec (abfd)->size = core->c_ssize; - core_datasec (abfd)->size = core->c_dsize; - core_regsec (abfd)->size = core->c_regs_size; - core_reg2sec (abfd)->size = core->fp_stuff_size; + core_stacksec (abfd)->_raw_size = core->c_ssize; + core_datasec (abfd)->_raw_size = core->c_dsize; + core_regsec (abfd)->_raw_size = core->c_regs_size; + core_reg2sec (abfd)->_raw_size = core->fp_stuff_size; core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize); core_datasec (abfd)->vma = N_DATADDR(core->c_aouthdr); @@ -541,14 +501,14 @@ DEFUN(sunos4_core_file_p,(abfd), static char *sunos4_core_file_failing_command (abfd) bfd *abfd; { - return core_hdr (abfd)->c_cmdname; + return core_hdr (abfd)->hdr->c_cmdname; } static int DEFUN(sunos4_core_file_failing_signal,(abfd), bfd *abfd) { - return core_hdr (abfd)->c_signo; + return core_hdr (abfd)->hdr->c_signo; } static boolean @@ -561,10 +521,61 @@ DEFUN(sunos4_core_file_matches_executable_p, (core_bfd, exec_bfd), return false; } - return (bcmp ((char *)&core_hdr (core_bfd)->c_aouthdr, - (char *) exec_hdr (exec_bfd), - sizeof (struct internal_exec)) == 0) ? true : false; + return (memcmp ((char *)&((core_hdr (core_bfd)->hdr)->c_aouthdr), + (char *) exec_hdr (exec_bfd), + sizeof (struct internal_exec)) == 0) ? true : false; +} + +extern reloc_howto_type aout_32_ext_howto_table[]; + +static reloc_howto_type * +DEFUN (sunos4_reloc_type_lookup, (abfd, code), + bfd *abfd AND + bfd_reloc_code_real_type code) +{ + switch (bfd_get_arch (abfd)) + { + default: + return 0; + case bfd_arch_sparc: + switch (code) + { + default: + return 0; +#define IDX(i,j) case i: return &aout_32_ext_howto_table[j] + IDX (BFD_RELOC_CTOR, 2); + IDX (BFD_RELOC_32, 2); + IDX (BFD_RELOC_HI22, 8); + IDX (BFD_RELOC_LO10, 11); + IDX (BFD_RELOC_32_PCREL_S2, 6); + } + } } + +static boolean +DEFUN (sunos4_set_sizes, (abfd), + bfd *abfd) +{ + switch (bfd_get_arch (abfd)) + { + default: + return false; + case bfd_arch_sparc: + adata(abfd).page_size = 0x2000; + adata(abfd).segment_size = 0x2000; + adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE; + return true; + case bfd_arch_m68k: + adata(abfd).page_size = 0x2000; + adata(abfd).segment_size = 0x20000; + adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE; + return true; + } +} + +static CONST struct aout_backend_data sunos4_aout_backend = { + 0, 1, 0, sunos4_set_sizes, +}; #define MY_core_file_failing_command sunos4_core_file_failing_command #define MY_core_file_failing_signal sunos4_core_file_failing_signal @@ -573,9 +584,9 @@ DEFUN(sunos4_core_file_matches_executable_p, (core_bfd, exec_bfd), #define MY_bfd_debug_info_start bfd_void #define MY_bfd_debug_info_end bfd_void #define MY_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void -#define MY_object_p NAME(sunos,object_p) #define MY_core_file_p sunos4_core_file_p #define MY_write_object_contents NAME(aout,sunos4_write_object_contents) +#define MY_backend_data &sunos4_aout_backend #define TARGET_IS_BIG_ENDIAN_P |