Patch generated: on Sat May 10 21:58:47 EDT 1997 by tytso@rsts-11 against binutils 2.8 =================================================================== RCS file: opcodes/RCS/m68k-opc.c,v retrieving revision 1.1 diff -u -r1.1 opcodes/m68k-opc.c --- opcodes/m68k-opc.c 1997/05/07 12:08:06 1.1 +++ opcodes/m68k-opc.c 1997/05/08 17:41:21 @@ -1827,10 +1827,8 @@ {"tstb", one(0045000), one(0177700), ";b", m68020up | mcf5200 }, {"tstb", one(0045000), one(0177700), "@b", m68000up }, -{"tstw", one(0045100), one(0177700), "*w", m68020up | mcf5200 }, -{"tstw", one(0045100), one(0177700), "@w", m68000up }, -{"tstl", one(0045200), one(0177700), "*l", m68020up | mcf5200 }, -{"tstl", one(0045200), one(0177700), "@l", m68000up }, +{"tstw", one(0045100), one(0177700), "*w", m68000up | mcf5200 }, +{"tstl", one(0045200), one(0177700), "*l", m68000up | mcf5200 }, {"unlk", one(0047130), one(0177770), "As", m68000up | mcf5200 }, =================================================================== RCS file: bfd/RCS/Makefile.in,v retrieving revision 1.1 diff -u -r1.1 bfd/Makefile.in --- bfd/Makefile.in 1997/05/06 15:29:07 1.1 +++ bfd/Makefile.in 1997/05/06 15:30:31 @@ -253,6 +253,7 @@ pe-ppc.o \ pei-ppc.o \ ppcboot.o \ + prc.o \ reloc16.o \ riscix.o \ sparclinux.o \ @@ -350,6 +351,7 @@ pe-ppc.c \ pei-ppc.c \ ppcboot.c \ + prc.c \ reloc16.c \ riscix.c \ sparclinux.c \ =================================================================== RCS file: bfd/RCS/configure.in,v retrieving revision 1.1 diff -u -r1.1 bfd/configure.in --- bfd/configure.in 1997/05/06 15:28:21 1.1 +++ bfd/configure.in 1997/05/06 15:28:48 @@ -525,6 +525,7 @@ bfd_powerpc_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;; bfd_powerpcle_pei_vec) tb="$tb pei-ppc.o cofflink.o" ;; ppcboot_vec) tb="$tb ppcboot.o" ;; + prc_vec) tb="$tb prc.o" ;; shcoff_vec) tb="$tb coff-sh.o cofflink.o" ;; shlcoff_vec) tb="$tb coff-sh.o cofflink.o" ;; som_vec) tb="$tb som.o" ;; =================================================================== RCS file: bfd/RCS/config.bfd,v retrieving revision 1.1 diff -u -r1.1 bfd/config.bfd --- bfd/config.bfd 1997/05/06 15:26:03 1.1 +++ bfd/config.bfd 1997/05/06 15:28:59 @@ -266,7 +266,7 @@ ;; m68*-*-coff* | m68*-*-sysv* | m68*-*-rtems*) targ_defvec=m68kcoff_vec - targ_selvecs="m68kcoff_vec versados_vec ieee_vec" + targ_selvecs="m68kcoff_vec versados_vec ieee_vec prc_vec" ;; m68*-*-hpux*) targ_defvec=hp300hpux_vec =================================================================== RCS file: bfd/RCS/targets.c,v retrieving revision 1.1 diff -u -r1.1 bfd/targets.c --- bfd/targets.c 1997/05/06 15:31:36 1.1 +++ bfd/targets.c 1997/05/06 15:31:50 @@ -562,6 +562,7 @@ extern const bfd_target oasys_vec; extern const bfd_target pc532machaout_vec; extern const bfd_target ppcboot_vec; +extern const bfd_target prc_vec; extern const bfd_target riscix_vec; extern const bfd_target pmac_xcoff_vec; extern const bfd_target rs6000coff_vec; --- /dev/null Mon Dec 31 23:00:00 1979 +++ bfd/prc.c Sat May 10 21:47:25 1997 @@ -0,0 +1,360 @@ +/* + * prc.c --- pilot resource BFD backend + * + * by Theodore Ts'o + */ + +#include + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + +/* PRC File header */ + +typedef struct prc_header { + bfd_byte prc_name[32]; + bfd_byte prc_flags[2]; + bfd_byte prc_version[2]; + bfd_byte prc_create_time[4]; + bfd_byte prc_mod_time[4]; + bfd_byte prc_backup_time[4]; + bfd_byte prc_mod_num[4]; + bfd_byte prc_app_info[4]; + bfd_byte prc_sort_info[4]; + bfd_byte prc_type[4]; /* type */ + bfd_byte prc_id[4]; /* creator */ + bfd_byte prc_unique_id_seed[4]; + bfd_byte prc_next_record_list[4]; + bfd_byte prc_num_records[2]; +} prc_header_t; + +/* Section header */ + +typedef struct prc_sect { + bfd_byte sect_name[4]; + bfd_byte sect_id[2]; + bfd_byte sect_offset[4]; +} prc_sect_t; + +struct section_attribute { + const char *name; + flagword flags; + unsigned int alignment_power; +}; + +/* + * The PRC tdata structure definition + */ +typedef struct prc_tdata { + bfd_byte pt_name[32]; + bfd_byte pt_flags[2]; + bfd_byte pt_version[2]; + bfd_vma pt_create_time; + bfd_vma pt_mod_time; + bfd_vma pt_backup_time; + bfd_vma pt_mod_num; + bfd_vma pt_app_info; + bfd_vma pt_sort_info; + bfd_byte pt_type[4]; /* type */ + bfd_byte pt_id[4]; /* creator */ + bfd_vma pt_unique_id_seed; + bfd_vma pt_next_record_list; + bfd_vma pt_num_sections; +} prc_tdata_t; + +/* + * This defines the attributes for the various PRC sections + */ +static struct section_attribute prc_sects[] = { + "code", SEC_CODE | SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC, 2, + 0, SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC, 1 +}; + +static char prc_std_flags[2] = { 0, 1 }; +static char prc_std_version[2] = { 0, 1 }; +static char prc_std_type[4] = { 'a', 'p', 'p', 'l' }; + +/* Create a binary object. Invoked via bfd_set_format. */ + +static boolean +prc_mkobject (abfd) + bfd *abfd; +{ + prc_tdata_t *tdata; + + if (abfd->tdata.any == NULL) { + tdata = bfd_alloc (abfd, sizeof (prc_tdata_t)); + if (!tdata) + return false; + abfd->tdata.any = tdata; + memset(tdata, 0, sizeof(prc_tdata_t)); + memcpy(tdata->pt_type, prc_std_type, 4); + memcpy(tdata->pt_flags, prc_std_flags, 2); + memcpy(tdata->pt_version, prc_std_version, 2); + tdata->pt_create_time = 2942715600; + tdata->pt_mod_time = 2942715600; + } + return true; +} + +/* Check whether an existing file is PRC file. */ + +static const bfd_target * +prc_object_p (abfd) + bfd *abfd; +{ + prc_header_t prc_header; + prc_sect_t prc_section; + char *cp; + int i; + bfd_vma flags, nsect, id, offset; + asection *sec = NULL, *osec = NULL; + char *secname; + file_ptr pos; + struct stat statbuf; + struct section_attribute *sec_attr; + prc_tdata_t *tdata = NULL; + + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 + || (bfd_read (&prc_header, 1, sizeof(prc_header), abfd) != + sizeof(prc_header))) + return NULL; + + /* + * Check to see if we have a PRC file + */ + i = strlen(prc_header.prc_name); + flags = bfd_get_16(abfd, prc_header.prc_flags); + if ((i > 31) || + ((flags & 1) == 0) || + memcmp(prc_header.prc_version, prc_std_version, 2) || + memcmp(prc_header.prc_type, prc_std_type, 4)) { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } +#if 0 + /* Pila stuffs its name in the last 4 bytes of the 32 byte field */ + /* Not all PRC's have this field zero padded! */ + for (; i < 28; i++) { + if (prc_header.prc_name[i]) { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } + } +#endif + + if (!prc_mkobject(abfd)) + return NULL; + + /* + * Read in the section information + */ + nsect = bfd_get_16(abfd, prc_header.prc_num_records); + for (i=0; i < nsect; i++) { + if (bfd_read(&prc_section, 1, sizeof(prc_section), abfd) != + sizeof(prc_section)) + return NULL; + + id = bfd_get_16(abfd, prc_section.sect_id); + offset = bfd_get_32(abfd, prc_section.sect_offset); + + secname = malloc(10); + if (!secname) + return NULL; + memset(secname, 0, 10); + strncpy(secname, prc_section.sect_name, 4); + cp = secname + strlen(secname); + sprintf(cp, "%04x", id); + + for (sec_attr = prc_sects; sec_attr->name; sec_attr++) { + if (!strncmp(sec_attr->name, prc_section.sect_name, 4)) + break; + } + + sec = bfd_make_section (abfd, secname); + if (sec == NULL) + return NULL; + sec->vma = 0; + sec->lma = 0; + sec->filepos = offset; + sec->flags = sec_attr->flags; + sec->alignment_power = sec_attr->alignment_power; + if (osec) + osec->_raw_size = offset - osec->filepos; + osec = sec; + } + if (osec) { + if (bfd_stat (abfd, &statbuf) < 0) { + bfd_set_error (bfd_error_system_call); + return NULL; + } + osec->_raw_size = statbuf.st_size - osec->filepos; + } + bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); + return abfd->xvec; +} + +/* + * Here's the symbol table support + * + * PRC's don't have symbol tables, but bfd_make_section requires that + * you need symbol table support + */ + +static asymbol * +prc_make_empty_symbol (abfd) + bfd *abfd; +{ + asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol)); + if (new) + new->the_bfd = abfd; + return new; +} + +/* Return the amount of memory needed to read the symbol table. */ + +static long +prc_get_symtab_upper_bound (abfd) + bfd *abfd; +{ + return (bfd_get_symcount (abfd) + 1) * sizeof (asymbol *); +} + +/* Return the symbol table. */ + +static long +prc_get_symtab (abfd, alocation) + bfd *abfd; + asymbol **alocation; +{ + return 0; +} + +/*ARGSUSED*/ +static void +prc_get_symbol_info (ignore_abfd, symbol, ret) + bfd *ignore_abfd; + asymbol *symbol; + symbol_info *ret; +{ + bfd_symbol_info (symbol, ret); +} + +/*ARGSUSED*/ +static void +prc_print_symbol (ignore_abfd, afile, symbol, how) + bfd *ignore_abfd; + PTR afile; + asymbol *symbol; + bfd_print_symbol_type how; +{ + FILE *file = (FILE *) afile; + switch (how) + { + case bfd_print_symbol_name: + fprintf (file, "%s", symbol->name); + break; + default: + bfd_print_symbol_vandf ((PTR) file, symbol); + fprintf (file, " %-5s %s", + symbol->section->name, + symbol->name); + + } +} + +/* + * Write section support + */ + +static boolean +prc_emit_header(abfd) + bfd *abfd; +{ + /* + * XXX Still need to do! + */ + return true; +} + + +static boolean +prc_set_section_contents (abfd, section, location, offset, count) + bfd *abfd; + sec_ptr section; + PTR location; + file_ptr offset; + bfd_size_type count; +{ + if (abfd->output_has_begun == false) { + if (!prc_emit_header(abfd)) + return false; + } + + return _bfd_generic_set_section_contents(abfd, section, + location, + offset, count); +} + +#define prc_set_arch_mach bfd_generic_set_arch_mach +#define prc_bfd_is_local_label_name bfd_generic_is_local_label_name +#define prc_get_lineno _bfd_nosymbols_get_lineno +#define prc_find_nearest_line _bfd_nosymbols_find_nearest_line +#define prc_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol +#define prc_read_minisymbols _bfd_generic_read_minisymbols +#define prc_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol + + +/* + * + */ +const bfd_target prc_vec = +{ + "prc", /* name */ + bfd_target_unknown_flavour, /* flavour */ + BFD_ENDIAN_BIG, /* byteorder */ + BFD_ENDIAN_BIG, /* header_byteorder */ + (EXEC_P | HAS_RELOC), /* object_flags */ + (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_READONLY | SEC_CODE | SEC_DATA + | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */ + 0, /* symbol_leading_char */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ + bfd_getb64, bfd_getb_signed_64, bfd_putb64, + bfd_getb32, bfd_getb_signed_32, bfd_putb32, + bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ + { /* bfd_check_format */ + _bfd_dummy_target, + prc_object_p, /* object format */ + _bfd_dummy_target, /* archive format */ + _bfd_dummy_target, /* core format */ + }, + { /* bfd_set_format */ + bfd_false, + prc_mkobject, /* object format */ + bfd_false, /* archive format */ + bfd_false, /* core format */ + }, + { /* bfd_write_contents */ + bfd_false, + bfd_true, + bfd_false, + bfd_false, + }, + + BFD_JUMP_TABLE_GENERIC (_bfd_generic), + BFD_JUMP_TABLE_COPY (_bfd_generic), + BFD_JUMP_TABLE_CORE (_bfd_nocore), + BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive), + BFD_JUMP_TABLE_SYMBOLS (prc), + BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), + BFD_JUMP_TABLE_WRITE (_bfd_generic), + BFD_JUMP_TABLE_LINK (_bfd_nolink), + BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), + + NULL +};