home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gdb-4.12.tar.gz / gdb-4.12.tar / gdb-4.12 / bfd / oasys.c < prev    next >
C/C++ Source or Header  |  1994-02-03  |  36KB  |  1,360 lines

  1. /* BFD back-end for oasys objects.
  2.    Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  3.    Written by Steve Chamberlain of Cygnus Support, <sac@cygnus.com>.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #define UNDERSCORE_HACK 1
  22. #include "bfd.h"
  23. #include "sysdep.h"
  24. #include "libbfd.h"
  25. #include "oasys.h"
  26. #include "liboasys.h"
  27.  
  28. /* XXX - FIXME.  offsetof belongs in the system-specific files in
  29.    ../include/sys. */
  30. /* Define offsetof for those systems which lack it */
  31.  
  32. #ifndef offsetof
  33. #define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier) 
  34. #endif
  35.  
  36. static boolean oasys_write_sections PARAMS ((bfd *));
  37.  
  38. /* Read in all the section data and relocation stuff too */
  39. PROTO(static boolean,oasys_slurp_section_data,(bfd *CONST abfd));
  40.  
  41. static void 
  42. DEFUN(oasys_read_record,(abfd, record),
  43.       bfd *CONST abfd AND 
  44.       oasys_record_union_type *record)
  45. {
  46.  
  47.   bfd_read((PTR)record, 1, sizeof(record->header), abfd);
  48.  
  49.   if ((size_t) record->header.length <= (size_t) sizeof (record->header))
  50.     return;
  51.   bfd_read((PTR)(((char *)record )+ sizeof(record->header)),
  52.        1, record->header.length - sizeof(record->header),
  53.        abfd);
  54. }
  55. static size_t
  56. DEFUN(oasys_string_length,(record),
  57.       oasys_record_union_type *record)
  58. {
  59. return  record->header.length
  60.     - ((char *)record->symbol.name - (char *)record);
  61. }
  62.  
  63. /*****************************************************************************/
  64.  
  65. /*
  66.  
  67. Slurp the symbol table by reading in all the records at the start file
  68. till we get to the first section record.
  69.  
  70. We'll sort the symbolss into  two lists, defined and undefined. The
  71. undefined symbols will be placed into the table according to their
  72. refno. 
  73.  
  74. We do this by placing all undefined symbols at the front of the table
  75. moving in, and the defined symbols at the end of the table moving back.
  76.  
  77. */
  78.  
  79. static boolean
  80. DEFUN(oasys_slurp_symbol_table,(abfd),
  81.     bfd * CONST abfd)
  82. {
  83.   oasys_record_union_type record;
  84.   oasys_data_type *data = OASYS_DATA(abfd);
  85.   boolean loop = true;
  86.   asymbol *dest_defined;
  87.   asymbol *dest;
  88.   char *string_ptr;
  89.  
  90.  
  91.   if (data->symbols != (asymbol *)NULL) {
  92.     return true;
  93.   }
  94.   /* Buy enough memory for all the symbols and all the names */
  95.   data->symbols = 
  96.     (asymbol *)bfd_alloc(abfd, sizeof(asymbol) * abfd->symcount);
  97. #ifdef UNDERSCORE_HACK
  98.   /* buy 1 more char for each symbol to keep the underscore in*/
  99.   data->strings = bfd_alloc(abfd, data->symbol_string_length +
  100.                 abfd->symcount);
  101. #else
  102.   data->strings = bfd_alloc(abfd, data->symbol_string_length);
  103. #endif
  104.  
  105.  
  106.   dest_defined = data->symbols + abfd->symcount -1;
  107.  
  108.   string_ptr = data->strings;
  109.   bfd_seek(abfd, (file_ptr)0, SEEK_SET);
  110.   while (loop) {
  111.  
  112.     oasys_read_record(abfd, &record);
  113.     switch (record.header.type) {
  114.     case oasys_record_is_header_enum:
  115.       break;
  116.     case oasys_record_is_local_enum:
  117.     case oasys_record_is_symbol_enum:
  118.     {
  119.       int       flag = record.header.type == (int)oasys_record_is_local_enum ?
  120.         (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT);
  121.  
  122.  
  123.       size_t length = oasys_string_length(&record);
  124.       switch (record.symbol.relb & RELOCATION_TYPE_BITS) {
  125.       case RELOCATION_TYPE_ABS:
  126.         dest = dest_defined--;
  127.         dest->section = &bfd_abs_section;
  128.         dest->flags =  0;
  129.         
  130.         break;
  131.       case RELOCATION_TYPE_REL:
  132.         dest = dest_defined--;
  133.         dest->section =
  134.           OASYS_DATA(abfd)->sections[record.symbol.relb &
  135.                      RELOCATION_SECT_BITS];
  136.         if (record.header.type == (int)oasys_record_is_local_enum) 
  137.         {
  138.           dest->flags = BSF_LOCAL;
  139.           if (dest->section ==(asection *)(~0)) {
  140.             /* It seems that sometimes internal symbols are tied up, but
  141.                still get output, even though there is no
  142.                section */
  143.             dest->section = 0;
  144.           }
  145.         }
  146.         else {
  147.  
  148.           dest->flags = flag;
  149.         }
  150.         break;
  151.       case RELOCATION_TYPE_UND:
  152.         dest = data->symbols + bfd_h_get_16(abfd, record.symbol.refno);
  153.         dest->section = &bfd_und_section;
  154.         break;
  155.       case RELOCATION_TYPE_COM:
  156.         dest = dest_defined--;
  157.         dest->name = string_ptr;
  158.         dest->the_bfd = abfd;
  159.  
  160.         dest->section = &bfd_com_section;
  161.  
  162.         break;
  163.       default:
  164.         dest = dest_defined--;
  165.         BFD_ASSERT(0);
  166.         break;
  167.       }
  168.       dest->name = string_ptr;
  169.       dest->the_bfd = abfd;
  170.       dest->udata = (PTR)NULL;
  171.       dest->value = bfd_h_get_32(abfd, record.symbol.value);
  172.  
  173. #ifdef UNDERSCORE_HACK
  174.       if (record.symbol.name[0] != '_') {
  175.         string_ptr[0] = '_';
  176.         string_ptr++;
  177.       }
  178. #endif
  179.       memcpy(string_ptr, record.symbol.name, length);
  180.  
  181.  
  182.       string_ptr[length] =0;
  183.       string_ptr += length +1;
  184.     }
  185.       break;
  186.     default:
  187.       loop = false;
  188.     }
  189.   }
  190.   return true;
  191. }
  192.  
  193. static unsigned int
  194. DEFUN(oasys_get_symtab_upper_bound,(abfd),
  195.      bfd *CONST abfd)
  196. {
  197.   oasys_slurp_symbol_table (abfd);
  198.  
  199.   return    (abfd->symcount+1) * (sizeof (oasys_symbol_type *));
  200. }
  201.  
  202. /* 
  203. */
  204.  
  205. extern bfd_target oasys_vec;
  206.  
  207. unsigned int
  208. DEFUN(oasys_get_symtab,(abfd, location),
  209.       bfd *abfd AND
  210.       asymbol **location)
  211. {
  212.   asymbol *symbase ;
  213.   unsigned int counter ;
  214.   if (oasys_slurp_symbol_table(abfd) == false) {
  215.     return 0;
  216.   }
  217.   symbase = OASYS_DATA(abfd)->symbols;
  218.   for (counter = 0; counter < abfd->symcount; counter++) {
  219.     *(location++) = symbase++;
  220.   }
  221.   *location = 0;
  222.   return abfd->symcount;
  223. }
  224.  
  225. /***********************************************************************
  226. *  archive stuff 
  227. */
  228.  
  229. static bfd_target *
  230. DEFUN(oasys_archive_p,(abfd),
  231.       bfd *abfd)
  232. {
  233.   oasys_archive_header_type header;
  234.   oasys_extarchive_header_type header_ext;
  235.   unsigned int i;
  236.   file_ptr filepos;  
  237.  
  238.   bfd_seek(abfd, (file_ptr) 0, false);
  239.   bfd_read((PTR)&header_ext, 1, sizeof(header_ext), abfd);
  240.  
  241.   header.version = bfd_h_get_32(abfd, header_ext.version);
  242.   header.mod_count = bfd_h_get_32(abfd, header_ext.mod_count);
  243.   header.mod_tbl_offset = bfd_h_get_32(abfd, header_ext.mod_tbl_offset);
  244.   header.sym_tbl_size = bfd_h_get_32(abfd, header_ext.sym_tbl_size);
  245.   header.sym_count = bfd_h_get_32(abfd, header_ext.sym_count);
  246.   header.sym_tbl_offset = bfd_h_get_32(abfd, header_ext.sym_tbl_offset);
  247.   header.xref_count = bfd_h_get_32(abfd, header_ext.xref_count);
  248.   header.xref_lst_offset = bfd_h_get_32(abfd, header_ext.xref_lst_offset);
  249.  
  250.   /*
  251.     There isn't a magic number in an Oasys archive, so the best we
  252.     can do to verify reasnableness is to make sure that the values in
  253.     the header are too weird
  254.     */
  255.  
  256.   if (header.version>10000 ||
  257.       header.mod_count>10000 ||
  258.       header.sym_count>100000 ||
  259.       header.xref_count > 100000) return (bfd_target *)NULL;
  260.  
  261.   /*
  262.     That all worked, let's buy the space for the header and read in
  263.     the headers.
  264.     */
  265.     {
  266.       oasys_ar_data_type *ar =
  267.     (oasys_ar_data_type*) bfd_alloc(abfd, sizeof(oasys_ar_data_type));
  268.  
  269.       oasys_module_info_type *module = 
  270.     (oasys_module_info_type*)
  271.       bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
  272.  
  273.       oasys_module_table_type record;
  274.  
  275.       abfd->tdata.oasys_ar_data = ar;
  276.       ar->module = module;
  277.       ar->module_count = header.mod_count;
  278.  
  279.       filepos = header.mod_tbl_offset;
  280.       for (i = 0; i < header.mod_count; i++) {
  281.         bfd_seek(abfd, filepos, SEEK_SET);
  282.  
  283.     /* There are two ways of specifying the archive header */
  284.  
  285.     if (0) {
  286.       oasys_extmodule_table_type_a_type record_ext;
  287.       bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd);
  288.     
  289.       record.mod_size = bfd_h_get_32(abfd, record_ext.mod_size);
  290.       record.file_offset = bfd_h_get_32(abfd, record_ext.file_offset);
  291.  
  292.       record.dep_count = bfd_h_get_32(abfd, record_ext.dep_count);
  293.       record.depee_count = bfd_h_get_32(abfd, record_ext.depee_count);
  294.       record.sect_count = bfd_h_get_32(abfd, record_ext.sect_count);
  295.  
  296.       module[i].name = bfd_alloc(abfd,33);
  297.  
  298.       memcpy(module[i].name, record_ext.mod_name, 33);
  299.       filepos +=
  300.         sizeof(record_ext) + 
  301.           record.dep_count * 4 +
  302.         record.depee_count * 4 +
  303.           record.sect_count * 8 + 187;
  304.     }
  305.     else {
  306.       oasys_extmodule_table_type_b_type record_ext;
  307.       bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd);
  308.     
  309.       record.mod_size = bfd_h_get_32(abfd, record_ext.mod_size);
  310.       record.file_offset = bfd_h_get_32(abfd, record_ext.file_offset);
  311.  
  312.       record.dep_count = bfd_h_get_32(abfd, record_ext.dep_count);
  313.       record.depee_count = bfd_h_get_32(abfd, record_ext.depee_count);
  314.       record.sect_count = bfd_h_get_32(abfd, record_ext.sect_count);
  315.       record.module_name_size = bfd_h_get_32(abfd, record_ext.mod_name_length);
  316.  
  317.       module[i].name = bfd_alloc(abfd,record.module_name_size + 1);
  318.       bfd_read((PTR)module[i].name, 1, record.module_name_size, abfd);
  319.       module[i].name[record.module_name_size] = 0;
  320.       filepos +=
  321.         sizeof(record_ext) + 
  322.           record.dep_count * 4 +
  323.         record.module_name_size + 1;
  324.  
  325.     }
  326.  
  327.  
  328.     module[i].size = record.mod_size;
  329.     module[i].pos = record.file_offset;
  330.     module[i].abfd = 0;
  331.       }
  332.       
  333.     }
  334.   return abfd->xvec;
  335. }
  336.  
  337. static boolean
  338. DEFUN(oasys_mkobject,(abfd),
  339.       bfd *abfd)
  340. {
  341.  
  342.   abfd->tdata.oasys_obj_data =    (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type));
  343.   return true;
  344. }
  345.  
  346. #define MAX_SECS 16
  347. static bfd_target *
  348. DEFUN(oasys_object_p,(abfd),
  349.       bfd *abfd)
  350. {
  351.   oasys_data_type *oasys;
  352.   oasys_data_type *save = OASYS_DATA(abfd);
  353.   boolean loop = true;
  354.   boolean had_usefull = false;
  355.  
  356.   abfd->tdata.oasys_obj_data = 0;
  357.   oasys_mkobject(abfd);
  358.   oasys = OASYS_DATA(abfd);
  359.   memset((PTR)oasys->sections, 0xff, sizeof(oasys->sections));
  360.     
  361.   /* Point to the start of the file */
  362.   bfd_seek(abfd, (file_ptr)0, SEEK_SET);
  363.   oasys->symbol_string_length = 0;
  364.   /* Inspect the records, but only keep the section info -
  365.      remember the size of the symbols
  366.      */
  367.   oasys->first_data_record = 0;
  368.   while (loop) {
  369.     oasys_record_union_type record;
  370.     oasys_read_record(abfd, &record);
  371.     if ((size_t)record.header.length < (size_t)sizeof(record.header))
  372.       goto fail;
  373.  
  374.  
  375.     switch ((oasys_record_enum_type)(record.header.type)) {
  376.     case oasys_record_is_header_enum:
  377.       had_usefull = true;
  378.       break;
  379.     case oasys_record_is_symbol_enum:
  380.     case oasys_record_is_local_enum:
  381.       /* Count symbols and remember their size for a future malloc   */
  382.       abfd->symcount++;
  383.       oasys->symbol_string_length += 1 + oasys_string_length(&record);
  384.       had_usefull = true;
  385.       break;
  386.     case oasys_record_is_section_enum:
  387.     {
  388.       asection *s;
  389.       char *buffer;
  390.       unsigned int section_number;
  391.       if (record.section.header.length != sizeof(record.section))
  392.           {
  393.         goto fail;
  394.           }
  395.       buffer = bfd_alloc(abfd, 3);
  396.       section_number= record.section.relb & RELOCATION_SECT_BITS;
  397.       sprintf(buffer,"%u", section_number);
  398.       s = bfd_make_section(abfd,buffer);
  399.       oasys->sections[section_number] = s;
  400.       switch (record.section.relb & RELOCATION_TYPE_BITS) {
  401.       case RELOCATION_TYPE_ABS:
  402.       case RELOCATION_TYPE_REL:
  403.         break;
  404.       case RELOCATION_TYPE_UND:
  405.       case RELOCATION_TYPE_COM:
  406.         BFD_FAIL();
  407.       }
  408.  
  409.       s->_raw_size  = bfd_h_get_32(abfd, record.section.value);
  410.       s->vma = bfd_h_get_32(abfd, record.section.vma);
  411.       s->flags= 0;
  412.       had_usefull = true;
  413.     }
  414.       break;
  415.     case oasys_record_is_data_enum:
  416.       oasys->first_data_record = bfd_tell(abfd) - record.header.length;
  417.     case oasys_record_is_debug_enum:
  418.     case oasys_record_is_module_enum:
  419.     case oasys_record_is_named_section_enum:
  420.     case oasys_record_is_end_enum:
  421.       if (had_usefull == false) goto fail;
  422.       loop = false;
  423.       break;
  424.     default:
  425.       goto fail;
  426.     }
  427.   }
  428.   oasys->symbols = (asymbol *)NULL;
  429.   /* 
  430.     Oasys support several architectures, but I can't see a simple way
  431.     to discover which one is in a particular file - we'll guess 
  432.     */
  433.   bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0);
  434.   if (abfd->symcount != 0) {
  435.     abfd->flags |= HAS_SYMS;
  436.   }
  437.  
  438.   /* 
  439.     We don't know if a section has data until we've read it..
  440.     */
  441.  
  442.   oasys_slurp_section_data(abfd);
  443.  
  444.  
  445.   return abfd->xvec;
  446.  
  447.  fail:
  448.   (void)  bfd_release(abfd, oasys);
  449.   abfd->tdata.oasys_obj_data = save;
  450.   return (bfd_target *)NULL;
  451. }
  452.  
  453.  
  454. static void 
  455. DEFUN(oasys_get_symbol_info,(ignore_abfd, symbol, ret),
  456.       bfd *ignore_abfd AND
  457.       asymbol *symbol AND
  458.       symbol_info *ret)
  459. {
  460.   bfd_symbol_info (symbol, ret);
  461.   if (!symbol->section)
  462.     ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
  463. }
  464.  
  465. static void 
  466. DEFUN(oasys_print_symbol,(ignore_abfd, afile, symbol, how),
  467.       bfd *ignore_abfd AND
  468.       PTR afile AND
  469.       asymbol *symbol AND
  470.       bfd_print_symbol_type how)
  471. {
  472.   FILE *file = (FILE *)afile;
  473.  
  474.   switch (how) {
  475.   case bfd_print_symbol_name:
  476.   case bfd_print_symbol_more:
  477.     fprintf(file,"%s", symbol->name);
  478.     break;
  479.   case bfd_print_symbol_all:
  480.     {
  481.       CONST char *section_name = symbol->section == (asection *)NULL ?
  482.     (CONST char *) "*abs" : symbol->section->name;
  483.  
  484.       bfd_print_symbol_vandf((PTR)file,symbol);
  485.  
  486.       fprintf(file," %-5s %s",
  487.           section_name,
  488.           symbol->name);
  489.     }
  490.     break;
  491.   }
  492. }
  493. /*
  494.  The howto table is build using the top two bits of a reloc byte to
  495.  index into it. The bits are PCREL,WORD/LONG
  496. */
  497. static reloc_howto_type howto_table[]= 
  498. {
  499.  
  500. HOWTO(  0, 0,  1,   16, false,0,complain_overflow_bitfield,0,"abs16",true,0x0000ffff, 0x0000ffff,false),
  501. HOWTO(  0, 0,  2,   32, false,0,complain_overflow_bitfield,0,"abs32",true,0xffffffff, 0xffffffff,false),
  502. HOWTO(  0, 0,  1,   16, true,0,complain_overflow_signed,0,"pcrel16",true,0x0000ffff, 0x0000ffff,false),
  503. HOWTO(  0, 0,  2,   32, true,0,complain_overflow_signed,0,"pcrel32",true,0xffffffff, 0xffffffff,false)
  504. };
  505.  
  506. /* Read in all the section data and relocation stuff too */
  507. static boolean 
  508. DEFUN(oasys_slurp_section_data,(abfd),
  509.   bfd *CONST abfd)
  510. {
  511.   oasys_record_union_type record;
  512.   oasys_data_type *data = OASYS_DATA(abfd);
  513.   boolean loop = true;
  514.  
  515.   oasys_per_section_type *per ;
  516.  
  517.   asection *s;
  518.  
  519.   /* See if the data has been slurped already .. */
  520.   for (s = abfd->sections; s != (asection *)NULL; s= s->next) {
  521.     per =  oasys_per_section(s);
  522.     if (per->initialized == true) 
  523.       return true;
  524.   }
  525.  
  526.   if (data->first_data_record == 0)  return true;
  527.  
  528.   bfd_seek(abfd, data->first_data_record, SEEK_SET);
  529.   while (loop) {
  530.     oasys_read_record(abfd, &record);
  531.     switch (record.header.type) 
  532.     {
  533.     case oasys_record_is_header_enum:
  534.       break;
  535.     case oasys_record_is_data_enum:
  536.         {
  537.  
  538.           bfd_byte *src = record.data.data;
  539.           bfd_byte *end_src = ((bfd_byte *)&record) + record.header.length;
  540.           bfd_byte *dst_ptr;
  541.           bfd_byte *dst_base_ptr;
  542.           unsigned int relbit;
  543.           unsigned int count;
  544.           asection *  section =
  545.         data->sections[record.data.relb & RELOCATION_SECT_BITS];
  546.           bfd_vma dst_offset ;
  547.  
  548.           per =  oasys_per_section(section);
  549.  
  550.           if (per->initialized == false) 
  551.           {
  552.             per->data = (bfd_byte *) bfd_zalloc(abfd, section->_raw_size);
  553.             per->reloc_tail_ptr = (oasys_reloc_type **)&(section->relocation);
  554.             per->had_vma = false;
  555.             per->initialized = true;
  556.             section->reloc_count = 0;
  557.             section->flags = SEC_ALLOC;
  558.           }
  559.  
  560.           dst_offset = bfd_h_get_32(abfd, record.data.addr) ;
  561.           if (per->had_vma == false) {
  562.         /* Take the first vma we see as the base */
  563.         section->vma = dst_offset;
  564.         per->had_vma = true;
  565.           }
  566.  
  567.           dst_offset -=   section->vma;
  568.  
  569.           dst_base_ptr = oasys_per_section(section)->data;
  570.           dst_ptr = oasys_per_section(section)->data +
  571.         dst_offset;
  572.  
  573.           if (src < end_src) {
  574.         section->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
  575.           }
  576.           while (src < end_src) {
  577.         unsigned char mod_byte = *src++;
  578.         size_t gap = end_src - src;
  579.         
  580.         count = 8;
  581.         if (mod_byte == 0 && gap >= 8) {
  582.           dst_ptr[0] = src[0];
  583.           dst_ptr[1] = src[1];
  584.           dst_ptr[2] = src[2];
  585.           dst_ptr[3] = src[3];
  586.           dst_ptr[4] = src[4];
  587.           dst_ptr[5] = src[5];
  588.           dst_ptr[6] = src[6];
  589.           dst_ptr[7] = src[7];
  590.           dst_ptr+= 8;
  591.           src += 8;
  592.         }
  593.         else {
  594.           for (relbit = 1; count-- != 0 && src < end_src; relbit <<=1) 
  595.               {
  596.             if (relbit & mod_byte) 
  597.                 {
  598.                   unsigned char reloc = *src;
  599.                   /* This item needs to be relocated */
  600.                   switch (reloc & RELOCATION_TYPE_BITS) {
  601.                   case RELOCATION_TYPE_ABS:
  602.  
  603.                 break;
  604.  
  605.                   case RELOCATION_TYPE_REL: 
  606.                   {
  607.                     /* Relocate the item relative to the section */
  608.                     oasys_reloc_type *r =
  609.                       (oasys_reloc_type *)
  610.                     bfd_alloc(abfd,
  611.                           sizeof(oasys_reloc_type));
  612.                     *(per->reloc_tail_ptr) = r;
  613.                     per->reloc_tail_ptr = &r->next;
  614.                     r->next= (oasys_reloc_type *)NULL;
  615.                     /* Reference to undefined symbol */
  616.                     src++;
  617.                     /* There is no symbol */
  618.                     r->symbol = 0;
  619.                     /* Work out the howto */
  620.                     abort();
  621. #if 0
  622.                     r->relent.section =
  623.                       data->sections[reloc &
  624.                              RELOCATION_SECT_BITS];
  625.  
  626.                     r->relent.addend = -
  627.                       r->relent.section->vma;
  628. #endif
  629.                     r->relent.address = dst_ptr - dst_base_ptr;
  630.                     r->relent.howto = &howto_table[reloc>>6];
  631.                     r->relent.sym_ptr_ptr = (asymbol **)NULL;
  632.                     section->reloc_count++;
  633.  
  634.                     /* Fake up the data to look like it's got the -ve pc in it, this makes
  635.                        it much easier to convert into other formats. This is done by
  636.                        hitting the addend.
  637.                        */
  638.                     if (r->relent.howto->pc_relative == true) {
  639.                       r->relent.addend -= dst_ptr - dst_base_ptr;
  640.                     }
  641.  
  642.  
  643.                   }
  644.                 break;
  645.  
  646.  
  647.                   case RELOCATION_TYPE_UND:
  648.                   { 
  649.                     oasys_reloc_type *r =
  650.                       (oasys_reloc_type *)
  651.                     bfd_alloc(abfd,
  652.                           sizeof(oasys_reloc_type));
  653.                     *(per->reloc_tail_ptr) = r;
  654.                     per->reloc_tail_ptr = &r->next;
  655.                     r->next= (oasys_reloc_type *)NULL;
  656.                     /* Reference to undefined symbol */
  657.                     src++;
  658.                     /* Get symbol number */
  659.                     r->symbol = (src[0]<<8) | src[1];
  660.                     /* Work out the howto */
  661.                     abort();
  662.                     
  663. #if 0
  664.                     r->relent.section = (asection
  665.                              *)NULL;
  666. #endif
  667.                     r->relent.addend = 0;
  668.                     r->relent.address = dst_ptr - dst_base_ptr;
  669.                     r->relent.howto = &howto_table[reloc>>6];
  670.                     r->relent.sym_ptr_ptr = (asymbol **)NULL;
  671.                     section->reloc_count++;
  672.  
  673.                     src+=2;
  674.                     /* Fake up the data to look like it's got the -ve pc in it, this makes
  675.                        it much easier to convert into other formats. This is done by
  676.                        hitting the addend.
  677.                        */
  678.                     if (r->relent.howto->pc_relative == true) {
  679.                       r->relent.addend -= dst_ptr - dst_base_ptr;
  680.                     }
  681.  
  682.                 
  683.  
  684.                   }
  685.                 break;
  686.                   case RELOCATION_TYPE_COM:
  687.                 BFD_FAIL();
  688.                   }
  689.                 }
  690.             *dst_ptr++ = *src++;
  691.               }
  692.         }
  693.           }      
  694.         }
  695.       break;
  696.     case oasys_record_is_local_enum:
  697.     case oasys_record_is_symbol_enum:
  698.     case oasys_record_is_section_enum:
  699.       break;
  700.     default:
  701.       loop = false;
  702.     }
  703.   }
  704.  
  705.   return true;
  706.  
  707. }
  708.  
  709. static boolean
  710. DEFUN(oasys_new_section_hook,(abfd, newsect),
  711.       bfd *abfd AND
  712.       asection *newsect)
  713. {
  714.   newsect->used_by_bfd = (PTR)
  715.     bfd_alloc(abfd, sizeof(oasys_per_section_type));
  716.   oasys_per_section( newsect)->data = (bfd_byte *)NULL;
  717.   oasys_per_section(newsect)->section = newsect;
  718.   oasys_per_section(newsect)->offset  = 0;
  719.   oasys_per_section(newsect)->initialized = false;
  720.   newsect->alignment_power = 1;
  721.   /* Turn the section string into an index */
  722.  
  723.   sscanf(newsect->name,"%u", &newsect->target_index);
  724.  
  725.   return true;
  726. }
  727.  
  728.  
  729. static unsigned int
  730. DEFUN(oasys_get_reloc_upper_bound, (abfd, asect),
  731.       bfd *abfd AND
  732.       sec_ptr asect)
  733. {
  734.   oasys_slurp_section_data(abfd);
  735.   return (asect->reloc_count+1) * sizeof(arelent *);
  736. }
  737.  
  738. static boolean
  739. DEFUN(oasys_get_section_contents,(abfd, section, location, offset, count),
  740.       bfd *abfd AND
  741.       sec_ptr section AND
  742.       PTR location AND
  743.       file_ptr offset AND
  744.       bfd_size_type count)
  745. {
  746.   oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd;
  747.   oasys_slurp_section_data(abfd);
  748.   if (p->initialized == false) 
  749.       {
  750.     (void) memset(location, 0, (int)count);
  751.       }
  752.   else 
  753.       {
  754.     (void) memcpy(location,(PTR)( p->data + offset), (int)count);
  755.       }
  756.   return true;
  757. }
  758.  
  759.  
  760. unsigned int
  761. DEFUN(oasys_canonicalize_reloc,(ignore_abfd, section, relptr, symbols),
  762.       bfd *ignore_abfd AND
  763.       sec_ptr section AND
  764.       arelent **relptr AND
  765.       asymbol **symbols)
  766. {
  767.   unsigned int reloc_count = 0;
  768.   oasys_reloc_type *src = (oasys_reloc_type *)(section->relocation);
  769.   while (src != (oasys_reloc_type *)NULL) {
  770.       abort();
  771.       
  772. #if 0
  773.     if (src->relent.section == (asection *)NULL) 
  774.     {
  775.       src->relent.sym_ptr_ptr = symbols + src->symbol;
  776.     }
  777. #endif
  778.  
  779.     *relptr ++ = &src->relent;
  780.     src = src->next;
  781.     reloc_count++;
  782.   }
  783.   *relptr = (arelent *)NULL;
  784.   return section->reloc_count = reloc_count;
  785. }
  786.  
  787.  
  788.  
  789.  
  790. /* Writing */
  791.  
  792.  
  793. /* Calculate the checksum and write one record */
  794. static void 
  795. DEFUN(oasys_write_record,(abfd, type, record, size),
  796.       bfd *CONST abfd AND
  797.       CONST oasys_record_enum_type type AND
  798.       oasys_record_union_type *record AND
  799.       CONST size_t size)
  800. {
  801.   int checksum;
  802.   size_t i;
  803.   unsigned char *ptr;
  804.  
  805.   record->header.length = size;
  806.   record->header.type = (int)type;
  807.   record->header.check_sum = 0;
  808.   record->header.fill = 0;
  809.   ptr = (unsigned char *)&record->pad[0];
  810.   checksum = 0;
  811.   for (i = 0; i < size; i++) {
  812.     checksum += *ptr++;
  813.   }
  814.   record->header.check_sum = 0xff & (- checksum);
  815.   bfd_write((PTR)record, 1, size, abfd);
  816. }
  817.  
  818.  
  819. /* Write out all the symbols */
  820. static void 
  821. DEFUN(oasys_write_syms, (abfd),
  822.       bfd * CONST abfd)
  823. {
  824.   unsigned int count;
  825.   asymbol **generic = bfd_get_outsymbols(abfd);
  826.   unsigned int index = 0;
  827.   for (count = 0; count < bfd_get_symcount(abfd); count++) {
  828.  
  829.     oasys_symbol_record_type symbol;
  830.     asymbol * CONST g = generic[count];
  831.  
  832.     CONST    char *src = g->name;
  833.     char *dst = symbol.name;
  834.     unsigned int l = 0;
  835.  
  836.     if (bfd_is_com_section (g->section)) {
  837.       symbol.relb = RELOCATION_TYPE_COM;
  838.       bfd_h_put_16(abfd, index, symbol.refno);
  839.       index++;
  840.     }
  841.     else if (g->section == & bfd_abs_section) {
  842.       symbol.relb = RELOCATION_TYPE_ABS;
  843.       bfd_h_put_16(abfd, 0, symbol.refno);
  844.  
  845.     }
  846.     else if (g->section == &bfd_und_section) {
  847.       symbol.relb = RELOCATION_TYPE_UND ;
  848.       bfd_h_put_16(abfd, index, symbol.refno);
  849.       /* Overload the value field with the output index number */
  850.       index++;
  851.     }
  852.     else if (g->flags & BSF_DEBUGGING) {
  853.       /* throw it away */
  854.       continue;
  855.     }
  856.     else {
  857.       if (g->section == (asection *)NULL) {
  858.     /* Sometime, the oasys tools give out a symbol with illegal
  859.        bits in it, we'll output it in the same broken way */
  860.     
  861.     symbol.relb = RELOCATION_TYPE_REL | 0;
  862.       }
  863.       else {
  864.     symbol.relb = RELOCATION_TYPE_REL |g->section->output_section->target_index;
  865.       }
  866.       bfd_h_put_16(abfd, 0, symbol.refno);
  867.     }
  868. #ifdef UNDERSCORE_HACK
  869.     if (src[l] == '_')
  870.       dst[l++] = '.';
  871. #endif
  872.     while (src[l]) {
  873.       dst[l] = src[l];
  874.       l++;
  875.     }
  876.  
  877.     bfd_h_put_32(abfd, g->value, symbol.value);
  878.  
  879.       
  880.     if (g->flags & BSF_LOCAL) {
  881.       oasys_write_record(abfd,     
  882.              oasys_record_is_local_enum,
  883.              (oasys_record_union_type *) &symbol,
  884.              offsetof(oasys_symbol_record_type, name[0]) + l);
  885.     }
  886.     else {
  887.       oasys_write_record(abfd,     
  888.              oasys_record_is_symbol_enum,
  889.              (oasys_record_union_type *) &symbol,
  890.              offsetof(oasys_symbol_record_type, name[0]) + l);
  891.     }
  892.     g->value = index-1;
  893.   }
  894. }
  895.  
  896.  
  897.   /* Write a section header for each section */
  898. static boolean
  899. oasys_write_sections (abfd)
  900.      bfd *abfd;
  901. {
  902.   asection *s;
  903.   static oasys_section_record_type out;
  904.  
  905.   for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
  906.     if (!isdigit(s->name[0])) 
  907.     {
  908.       bfd_error = bfd_error_nonrepresentable_section;
  909.       return false;
  910.     }
  911.     out.relb = RELOCATION_TYPE_REL | s->target_index;
  912.     bfd_h_put_32(abfd, s->_cooked_size, out.value);
  913.     bfd_h_put_32(abfd, s->vma, out.vma);
  914.  
  915.     oasys_write_record(abfd,
  916.                oasys_record_is_section_enum,
  917.                (oasys_record_union_type *) &out,
  918.                sizeof(out));
  919.   }
  920.   return true;
  921. }
  922.  
  923. static void
  924. DEFUN(oasys_write_header, (abfd),
  925.       bfd *CONST abfd)
  926. {
  927.   /* Create and write the header */
  928.   oasys_header_record_type r;
  929.   size_t length = strlen(abfd->filename);
  930.   if (length > (size_t)sizeof(r.module_name)) {
  931.     length = sizeof(r.module_name);
  932.   }
  933.  
  934.   (void)memcpy(r.module_name,
  935.            abfd->filename,
  936.            length);
  937.   (void)memset(r.module_name + length,
  938.            ' ',
  939.            sizeof(r.module_name) - length);
  940.  
  941.   r.version_number = OASYS_VERSION_NUMBER;
  942.   r.rev_number = OASYS_REV_NUMBER;
  943.   oasys_write_record(abfd,
  944.              oasys_record_is_header_enum,
  945.              (oasys_record_union_type *)&r,
  946.              offsetof(oasys_header_record_type, description[0]));
  947.  
  948.  
  949.  
  950. }
  951.  
  952. static void
  953. DEFUN(oasys_write_end,(abfd),
  954.       bfd *CONST abfd)
  955. {
  956.   oasys_end_record_type end;
  957.   unsigned char null = 0;
  958.   end.relb = RELOCATION_TYPE_ABS;
  959.   bfd_h_put_32(abfd, abfd->start_address, end.entry); 
  960.   bfd_h_put_16(abfd, 0, end.fill);
  961.   end.zero = 0;
  962.   oasys_write_record(abfd,
  963.              oasys_record_is_end_enum,
  964.              (oasys_record_union_type *)&end,
  965.              sizeof(end));
  966.   bfd_write((PTR)&null, 1, 1, abfd);
  967. }
  968.  
  969. static int 
  970. DEFUN(comp,(ap, bp),
  971.    CONST PTR ap AND
  972.    CONST PTR bp)
  973. {
  974.   arelent *a = *((arelent **)ap);
  975.   arelent *b = *((arelent **)bp);
  976.   return a->address - b->address;
  977. }
  978.  
  979. /*
  980.  Writing data..
  981.  
  982. */
  983. static void
  984. DEFUN(oasys_write_data, (abfd),
  985.       bfd *CONST abfd)
  986. {
  987.   asection *s;
  988.   for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
  989.     if (s->flags & SEC_LOAD) {
  990.       bfd_byte *raw_data = oasys_per_section(s)->data;
  991.       oasys_data_record_type processed_data;
  992.       bfd_size_type current_byte_index = 0;
  993.       unsigned int relocs_to_go = s->reloc_count;
  994.       arelent **p = s->orelocation;
  995.       if (s->reloc_count != 0) {
  996. /* Sort the reloc records so it's easy to insert the relocs into the
  997.        data */
  998.     
  999.     qsort(s->orelocation,
  1000.           s->reloc_count,
  1001.           sizeof(arelent **),
  1002.           comp);
  1003.       }
  1004.       current_byte_index = 0;
  1005.       processed_data.relb = s->target_index | RELOCATION_TYPE_REL;
  1006.  
  1007.       while (current_byte_index < s->_cooked_size) 
  1008.       {
  1009.         /* Scan forwards by eight bytes or however much is left and see if
  1010.            there are any relocations going on */
  1011.         bfd_byte *mod = &processed_data.data[0];
  1012.         bfd_byte *dst = &processed_data.data[1];
  1013.  
  1014.         unsigned int i = 0;
  1015.         *mod = 0;
  1016.  
  1017.  
  1018.         bfd_h_put_32(abfd, s->vma + current_byte_index,
  1019.              processed_data.addr);
  1020.  
  1021.          /* Don't start a relocation unless you're sure you can finish it
  1022.             within the same data record.  The worst case relocation is a
  1023.             4-byte relocatable value which is split across two modification
  1024.             bytes (1 relocation byte + 2 symbol reference bytes + 2 data +
  1025.             1 modification byte + 2 data = 8 bytes total).  That's where
  1026.             the magic number 8 comes from.
  1027.          */
  1028.          while (current_byte_index < s->_raw_size && dst <=
  1029.          &processed_data.data[sizeof(processed_data.data)-8]) {
  1030.          
  1031.  
  1032.         if (relocs_to_go != 0) {    
  1033.           arelent *r = *p;
  1034.           const reloc_howto_type * const how=r->howto;
  1035.           /* There is a relocation, is it for this byte ? */
  1036.           if (r->address == current_byte_index) {
  1037.             unsigned char rel_byte;
  1038.  
  1039.             p++;
  1040.             relocs_to_go--;
  1041.  
  1042.             *mod |= (1<<i);
  1043.             if(how->pc_relative) {
  1044.               rel_byte = RELOCATION_PCREL_BIT;
  1045.  
  1046.               /* Also patch the raw data so that it doesn't have
  1047.              the -ve stuff any more */
  1048.               if (how->size != 2) {
  1049.             bfd_put_16(abfd, 
  1050.                    bfd_get_16(abfd,raw_data) +
  1051.                    current_byte_index, raw_data);
  1052.               }
  1053.  
  1054.               else {
  1055.             bfd_put_32(abfd, 
  1056.                    bfd_get_32(abfd,raw_data) +
  1057.                    current_byte_index, raw_data);
  1058.               }
  1059.             }
  1060.             else {
  1061.               rel_byte = 0;
  1062.             }
  1063.             if (how->size ==2) {
  1064.               rel_byte |= RELOCATION_32BIT_BIT;
  1065.             }
  1066.           
  1067.             /* Is this a section relative relocation, or a symbol
  1068.                relative relocation ? */
  1069.             abort();
  1070.     
  1071. #if 0
  1072.             if (r->section != (asection*)NULL) 
  1073.             {
  1074.               /* The relent has a section attached, so it must be section
  1075.                  relative */
  1076.               rel_byte |= RELOCATION_TYPE_REL;
  1077.               rel_byte |= r->section->output_section->target_index;
  1078.               *dst++ = rel_byte;
  1079.             }
  1080.             else 
  1081. #endif
  1082.             {
  1083.               asymbol *p = *(r->sym_ptr_ptr);
  1084.  
  1085.               /* If this symbol has a section attached, then it
  1086.                  has already been resolved.  Change from a symbol
  1087.                  ref to a section ref */
  1088.               if(p->section != (asection *)NULL) {
  1089.                 rel_byte |= RELOCATION_TYPE_REL;
  1090.                 rel_byte |=
  1091.                   p->section->output_section->target_index;
  1092.                 *dst++ = rel_byte;
  1093.               }
  1094.               else {
  1095.                 rel_byte |= RELOCATION_TYPE_UND;
  1096.                 *dst++ = rel_byte;
  1097.                 /* Next two bytes are a symbol index - we can get
  1098.                    this from the symbol value which has been zapped
  1099.                    into the symbol index in the table when the
  1100.                    symbol table was written
  1101.                    */
  1102.                 *dst++ = p->value >> 8;
  1103.                 *dst++ = p->value;
  1104.               }
  1105.             }
  1106. #define ADVANCE { if (++i >= 8) { i = 0; mod = dst++; *mod = 0; } current_byte_index++; }
  1107.             /* relocations never occur from an unloadable section,
  1108.                so we can assume that raw_data is not NULL
  1109.              */
  1110.             *dst++ = *raw_data++;
  1111.             ADVANCE
  1112.             *dst++ = *raw_data++;
  1113.             ADVANCE
  1114.             if (how->size == 2) {
  1115.               *dst++ = *raw_data++;
  1116.               ADVANCE
  1117.               *dst++ = *raw_data++;
  1118.               ADVANCE
  1119.             }
  1120.             continue;
  1121.           }
  1122.         }
  1123.         /* If this is coming from an unloadable section then copy
  1124.            zeros */
  1125.         if (raw_data == NULL) {
  1126.           *dst++ = 0;
  1127.         }
  1128.         else {
  1129.           *dst++ = *raw_data++;
  1130.         }
  1131.         ADVANCE
  1132.         }
  1133.  
  1134.         /* Don't write a useless null modification byte */
  1135.         if (dst == mod+1) {
  1136.           --dst;
  1137.         }
  1138.  
  1139.         oasys_write_record(abfd,
  1140.                    oasys_record_is_data_enum,
  1141.                    (oasys_record_union_type *)&processed_data,
  1142.                    dst - (bfd_byte *)&processed_data);
  1143.              
  1144.       }
  1145.     }
  1146.   }
  1147. }
  1148. static boolean
  1149. DEFUN(oasys_write_object_contents, (abfd),
  1150.       bfd *abfd)
  1151. {
  1152.   oasys_write_header(abfd);
  1153.   oasys_write_syms(abfd);
  1154.   if (! oasys_write_sections(abfd))
  1155.     return false;
  1156.   oasys_write_data(abfd);
  1157.   oasys_write_end(abfd);
  1158.   return true;
  1159. }
  1160.  
  1161.  
  1162.  
  1163.  
  1164. /** exec and core file sections */
  1165.  
  1166. /* set section contents is complicated with OASYS since the format is 
  1167. * not a byte image, but a record stream.
  1168. */
  1169. static boolean
  1170. DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
  1171.       bfd *abfd AND
  1172.       sec_ptr section AND 
  1173.       PTR location AND
  1174.       file_ptr offset AND
  1175.       bfd_size_type count)
  1176. {
  1177.   if (count != 0) {
  1178.     if (oasys_per_section(section)->data == (bfd_byte *)NULL ) 
  1179.     {
  1180.       oasys_per_section(section)->data =
  1181.         (bfd_byte *)(bfd_alloc(abfd,section->_cooked_size));    
  1182.     }
  1183.     (void) memcpy((PTR)(oasys_per_section(section)->data + offset),
  1184.           location,
  1185.           count);
  1186.   }
  1187.   return true;
  1188. }
  1189.  
  1190.  
  1191.  
  1192. /* Native-level interface to symbols. */
  1193.  
  1194. /* We read the symbols into a buffer, which is discarded when this
  1195. function exits.  We read the strings into a buffer large enough to
  1196. hold them all plus all the cached symbol entries. */
  1197.  
  1198. static asymbol *
  1199. DEFUN(oasys_make_empty_symbol,(abfd),
  1200.       bfd *abfd)
  1201. {
  1202.  
  1203.   oasys_symbol_type  *new =
  1204.     (oasys_symbol_type *)bfd_zalloc (abfd, sizeof (oasys_symbol_type));
  1205.   new->symbol.the_bfd = abfd;
  1206.   return &new->symbol;
  1207.  
  1208. }
  1209.  
  1210.  
  1211.  
  1212.  
  1213. /* User should have checked the file flags; perhaps we should return
  1214. BFD_NO_MORE_SYMBOLS if there are none? */
  1215.  
  1216. static bfd *
  1217. oasys_openr_next_archived_file(arch, prev)
  1218. bfd *arch;
  1219. bfd *prev;
  1220. {
  1221.   oasys_ar_data_type *ar = OASYS_AR_DATA(arch);
  1222.   oasys_module_info_type *p;
  1223.   /* take the next one from the arch state, or reset */
  1224.   if (prev == (bfd *)NULL) {
  1225.     /* Reset the index - the first two entries are bogus*/
  1226.     ar->module_index = 0;
  1227.   }
  1228.  
  1229.   p = ar->module + ar->module_index;
  1230.   ar->module_index++;
  1231.  
  1232.   if (ar->module_index <= ar->module_count) {
  1233.     if (p->abfd == (bfd *)NULL) {
  1234.       p->abfd = _bfd_create_empty_archive_element_shell(arch);
  1235.       p->abfd->origin = p->pos;
  1236.       p->abfd->filename = p->name;
  1237.  
  1238.       /* Fixup a pointer to this element for the member */
  1239.       p->abfd->arelt_data = (PTR)p;
  1240.     }
  1241.     return p->abfd;
  1242.   }
  1243.   else {
  1244.     bfd_error = no_more_archived_files;
  1245.     return (bfd *)NULL;
  1246.   }
  1247. }
  1248.  
  1249. static boolean
  1250. oasys_find_nearest_line(abfd,
  1251.              section,
  1252.              symbols,
  1253.              offset,
  1254.              filename_ptr,
  1255.              functionname_ptr,
  1256.              line_ptr)
  1257. bfd *abfd;
  1258. asection *section;
  1259. asymbol **symbols;
  1260. bfd_vma offset;
  1261. char **filename_ptr;
  1262. char **functionname_ptr;
  1263. unsigned int *line_ptr;
  1264. {
  1265.   return false;
  1266.  
  1267. }
  1268.  
  1269. static int
  1270. DEFUN(oasys_generic_stat_arch_elt,(abfd, buf),
  1271.       bfd *abfd AND
  1272.       struct stat *buf)
  1273. {
  1274.   oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data;
  1275.   if (mod == (oasys_module_info_type *)NULL) {
  1276.     bfd_error = invalid_operation;
  1277.     return -1;
  1278.   }
  1279.   else {
  1280.     buf->st_size = mod->size;
  1281.     buf->st_mode = 0666;
  1282.     return 0;
  1283.   }
  1284. }
  1285.  
  1286. static int 
  1287. DEFUN(oasys_sizeof_headers,(abfd, exec),
  1288.       bfd *abfd AND
  1289.       boolean exec)
  1290. {
  1291. return 0;
  1292. }
  1293. #define FOO PROTO
  1294. #define oasys_core_file_failing_command (char *(*)())(bfd_nullvoidptr)
  1295. #define oasys_core_file_failing_signal (int (*)())bfd_0
  1296. #define oasys_core_file_matches_executable_p  0 
  1297. #define oasys_slurp_armap bfd_true
  1298. #define oasys_slurp_extended_name_table bfd_true
  1299. #define oasys_truncate_arname (void (*)())bfd_nullvoidptr
  1300. #define oasys_write_armap 0
  1301. #define oasys_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr
  1302. #define    oasys_close_and_cleanup        bfd_generic_close_and_cleanup
  1303. #define oasys_set_arch_mach bfd_default_set_arch_mach
  1304. #define oasys_bfd_debug_info_start bfd_void
  1305. #define oasys_bfd_debug_info_end bfd_void
  1306. #define oasys_bfd_debug_info_accumulate  (FOO(void, (*), (bfd *, asection *)))bfd_void
  1307. #define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
  1308. #define oasys_bfd_relax_section bfd_generic_relax_section
  1309. #define oasys_bfd_reloc_type_lookup \
  1310.   ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
  1311. #define oasys_bfd_make_debug_symbol \
  1312.   ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
  1313. #define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
  1314. #define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
  1315. #define oasys_bfd_final_link _bfd_generic_final_link
  1316.  
  1317. /*SUPPRESS 460 */
  1318. bfd_target oasys_vec =
  1319. {
  1320.   "oasys",            /* name */
  1321.   bfd_target_oasys_flavour,
  1322.   true,                /* target byte order */
  1323.   true,                /* target headers byte order */
  1324.   (HAS_RELOC | EXEC_P |        /* object flags */
  1325.    HAS_LINENO | HAS_DEBUG |
  1326.    HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
  1327.   (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
  1328.    |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
  1329.    0,                /* leading underscore */
  1330.   ' ',                /* ar_pad_char */
  1331.   16,                /* ar_max_namelen */
  1332.   1,                /* minimum alignment */
  1333.   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
  1334.     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
  1335.     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
  1336.   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
  1337.     bfd_getb32, bfd_getb_signed_32, bfd_putb32,
  1338.     bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
  1339.  
  1340.     {_bfd_dummy_target,
  1341.        oasys_object_p,        /* bfd_check_format */
  1342.        oasys_archive_p,
  1343.        _bfd_dummy_target,
  1344.      },
  1345.     {                /* bfd_set_format */
  1346.       bfd_false,
  1347.       oasys_mkobject, 
  1348.       _bfd_generic_mkarchive,
  1349.       bfd_false
  1350.       },
  1351.     {                /* bfd_write_contents */
  1352.       bfd_false,
  1353.       oasys_write_object_contents,
  1354.       _bfd_write_archive_contents,
  1355.       bfd_false,
  1356.     },
  1357.   JUMP_TABLE(oasys),
  1358.   (PTR) 0
  1359. };
  1360.