home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / gdb-4.14-src.lha / gdb-4.14 / bfd / archures.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-04  |  16.5 KB  |  752 lines

  1. /* BFD library support routines for architectures.
  2.    Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3.    Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
  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. /*
  22.  
  23. SECTION
  24.     Architectures
  25.  
  26.     BFD keeps one atom in a BFD describing the
  27.     architecture of the data attached to the BFD: a pointer to a
  28.     <<bfd_arch_info_type>>.  
  29.  
  30.     Pointers to structures can be requested independently of a BFD
  31.     so that an architecture's information can be interrogated
  32.     without access to an open BFD.
  33.  
  34.     The architecture information is provided by each architecture package.
  35.     The set of default architectures is selected by the macro
  36.     <<SELECT_ARCHITECTURES>>.  This is normally set up in the
  37.     @file{config/@var{target}.mt} file of your choice.  If the name is not
  38.     defined, then all the architectures supported are included. 
  39.  
  40.     When BFD starts up, all the architectures are called with an
  41.     initialize method.  It is up to the architecture back end to
  42.     insert as many items into the list of architectures as it wants to;
  43.     generally this would be one for each machine and one for the
  44.     default case (an item with a machine field of 0). 
  45.  
  46.     BFD's idea of an architecture is implemented in    @file{archures.c}.
  47. */
  48.  
  49. /*
  50.  
  51. SUBSECTION
  52.     bfd_architecture
  53.  
  54. DESCRIPTION
  55.     This enum gives the object file's CPU architecture, in a
  56.     global sense---i.e., what processor family does it belong to?
  57.     Another field indicates which processor within
  58.     the family is in use.  The machine gives a number which
  59.     distinguishes different versions of the architecture,
  60.     containing, for example, 2 and 3 for Intel i960 KA and i960 KB,
  61.     and 68020 and 68030 for Motorola 68020 and 68030. 
  62.  
  63. .enum bfd_architecture 
  64. .{
  65. .  bfd_arch_unknown,   {* File arch not known *}
  66. .  bfd_arch_obscure,   {* Arch known, not one of these *}
  67. .  bfd_arch_m68k,      {* Motorola 68xxx *}
  68. .  bfd_arch_vax,       {* DEC Vax *}   
  69. .  bfd_arch_i960,      {* Intel 960 *}
  70. .    {* The order of the following is important.
  71. .       lower number indicates a machine type that 
  72. .       only accepts a subset of the instructions
  73. .       available to machines with higher numbers.
  74. .       The exception is the "ca", which is
  75. .       incompatible with all other machines except 
  76. .       "core". *}
  77. .
  78. .#define bfd_mach_i960_core      1
  79. .#define bfd_mach_i960_ka_sa     2
  80. .#define bfd_mach_i960_kb_sb     3
  81. .#define bfd_mach_i960_mc        4
  82. .#define bfd_mach_i960_xa        5
  83. .#define bfd_mach_i960_ca        6
  84. .
  85. .  bfd_arch_a29k,      {* AMD 29000 *}
  86. .  bfd_arch_sparc,     {* SPARC *}
  87. .  bfd_arch_mips,      {* MIPS Rxxxx *}
  88. .  bfd_arch_i386,      {* Intel 386 *}
  89. .  bfd_arch_we32k,     {* AT&T WE32xxx *}
  90. .  bfd_arch_tahoe,     {* CCI/Harris Tahoe *}
  91. .  bfd_arch_i860,      {* Intel 860 *}
  92. .  bfd_arch_romp,      {* IBM ROMP PC/RT *}
  93. .  bfd_arch_alliant,   {* Alliant *}
  94. .  bfd_arch_convex,    {* Convex *}
  95. .  bfd_arch_m88k,      {* Motorola 88xxx *}
  96. .  bfd_arch_pyramid,   {* Pyramid Technology *}
  97. .  bfd_arch_h8300,     {* Hitachi H8/300 *}
  98. .#define bfd_mach_h8300   1
  99. .#define bfd_mach_h8300h  2
  100. .  bfd_arch_powerpc,   {* PowerPC *}
  101. .  bfd_arch_rs6000,    {* IBM RS/6000 *}
  102. .  bfd_arch_hppa,      {* HP PA RISC *}
  103. .  bfd_arch_z8k,       {* Zilog Z8000 *}
  104. .#define bfd_mach_z8001        1
  105. .#define bfd_mach_z8002        2
  106. .  bfd_arch_h8500,     {* Hitachi H8/500 *}
  107. .  bfd_arch_sh,        {* Hitachi SH *}
  108. .  bfd_arch_alpha,     {* Dec Alpha *}
  109. .  bfd_arch_arm,       {* Advanced Risc Machines ARM *}
  110. .  bfd_arch_ns32k,     {* National Semiconductors ns32000 *}
  111. .  bfd_arch_w65,       {* WDC 65816 *}
  112. .  bfd_arch_last
  113. .  };
  114.  
  115.  
  116. */
  117.  
  118. #include "bfd.h"
  119. #include "sysdep.h"
  120. #include "libbfd.h"
  121.  
  122. /*
  123.  
  124. SUBSECTION
  125.     bfd_arch_info
  126.  
  127. DESCRIPTION
  128.     This structure contains information on architectures for use
  129.     within BFD.
  130.  
  131. .
  132. .typedef struct bfd_arch_info 
  133. .{
  134. .  int bits_per_word;
  135. .  int bits_per_address;
  136. .  int bits_per_byte;
  137. .  enum bfd_architecture arch;
  138. .  long mach;
  139. .  char *arch_name;
  140. .  CONST  char *printable_name;
  141. .  unsigned int section_align_power;
  142. . {* true if this is the default machine for the architecture *}
  143. .  boolean the_default;    
  144. .  CONST struct bfd_arch_info * (*compatible)
  145. .    PARAMS ((CONST struct bfd_arch_info *a,
  146. .             CONST struct bfd_arch_info *b));
  147. .
  148. .  boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *));
  149. .  {* How to disassemble an instruction, producing a printable
  150. .     representation on a specified stdio stream.  This isn't
  151. .     defined for most processors at present, because of the size
  152. .     of the additional tables it would drag in, and because gdb
  153. .     wants to use a different interface.  *}
  154. .  unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data,
  155. .                        PTR stream));
  156. .
  157. .  struct bfd_arch_info *next;
  158. .} bfd_arch_info_type;
  159. */
  160.  
  161. bfd_arch_info_type   *bfd_arch_info_list;
  162.  
  163.  
  164. /*
  165. FUNCTION
  166.     bfd_printable_name
  167.  
  168. SYNOPSIS
  169.     CONST char *bfd_printable_name(bfd *abfd);
  170.  
  171. DESCRIPTION
  172.     Return a printable string representing the architecture and machine
  173.     from the pointer to the architecture info structure.
  174.  
  175. */
  176.  
  177. CONST char *
  178. bfd_printable_name (abfd)
  179.      bfd *abfd;
  180. {
  181.   return abfd->arch_info->printable_name;
  182. }
  183.  
  184.  
  185.  
  186. /*
  187. FUNCTION
  188.     bfd_scan_arch
  189.  
  190. SYNOPSIS
  191.     bfd_arch_info_type *bfd_scan_arch(CONST char *string);
  192.  
  193. DESCRIPTION
  194.     Figure out if BFD supports any cpu which could be described with
  195.     the name @var{string}.  Return a pointer to an <<arch_info>>
  196.     structure if a machine is found, otherwise NULL.
  197.  
  198. */
  199.  
  200. bfd_arch_info_type *
  201. bfd_scan_arch (string)
  202.      CONST char *string;
  203. {
  204.   struct bfd_arch_info *ap;
  205.  
  206.   /* Look through all the installed architectures */
  207.   for (ap = bfd_arch_info_list;
  208.        ap != (bfd_arch_info_type *)NULL;
  209.        ap = ap->next) {
  210.  
  211.     if (ap->scan(ap, string)) 
  212.       return ap;
  213.   }
  214.   return (bfd_arch_info_type *)NULL;
  215. }
  216.  
  217.  
  218.  
  219. /*
  220. FUNCTION
  221.     bfd_arch_get_compatible
  222.  
  223. SYNOPSIS
  224.     CONST bfd_arch_info_type *bfd_arch_get_compatible(
  225.         CONST bfd *abfd,
  226.             CONST bfd *bbfd);
  227.  
  228. DESCRIPTION
  229.     Determine whether two BFDs'
  230.     architectures and machine types are compatible.  Calculates
  231.     the lowest common denominator between the two architectures
  232.     and machine types implied by the BFDs and returns a pointer to
  233.     an <<arch_info>> structure describing the compatible machine.
  234. */
  235.  
  236. CONST bfd_arch_info_type *
  237. bfd_arch_get_compatible (abfd, bbfd)
  238.      CONST bfd *abfd;
  239.      CONST bfd *bbfd;
  240. {
  241.   return  abfd->arch_info->compatible(abfd->arch_info,bbfd->arch_info);
  242. }
  243.  
  244.  
  245. /*
  246. INTERNAL_DEFINITION
  247.     bfd_default_arch_struct
  248.  
  249. DESCRIPTION
  250.     The <<bfd_default_arch_struct>> is an item of
  251.     <<bfd_arch_info_type>> which has been initialized to a fairly
  252.     generic state.  A BFD starts life by pointing to this
  253.     structure, until the correct back end has determined the real
  254.     architecture of the file.
  255.  
  256. .extern bfd_arch_info_type bfd_default_arch_struct;
  257.  
  258. */
  259.  
  260. bfd_arch_info_type bfd_default_arch_struct =
  261. {
  262.     32,32,8,bfd_arch_unknown,0,"unknown","unknown",2,true,
  263.     bfd_default_compatible,
  264.     bfd_default_scan, 
  265.     0,
  266. };
  267.  
  268. /*
  269. FUNCTION
  270.     bfd_set_arch_info
  271.  
  272. SYNOPSIS
  273.     void bfd_set_arch_info(bfd *abfd, bfd_arch_info_type *arg);
  274.  
  275. DESCRIPTION
  276.     Set the architecture info of @var{abfd} to @var{arg}.
  277. */
  278.  
  279. void
  280. bfd_set_arch_info (abfd, arg)
  281.      bfd *abfd;
  282.      bfd_arch_info_type *arg;
  283. {
  284.   abfd->arch_info = arg;
  285. }
  286.  
  287. /*
  288. INTERNAL_FUNCTION
  289.     bfd_default_set_arch_mach
  290.  
  291. SYNOPSIS
  292.     boolean bfd_default_set_arch_mach(bfd *abfd,
  293.         enum bfd_architecture arch,
  294.         unsigned long mach);
  295.  
  296. DESCRIPTION
  297.     Set the architecture and machine type in BFD @var{abfd}
  298.     to @var{arch} and @var{mach}.  Find the correct
  299.     pointer to a structure and insert it into the <<arch_info>>
  300.     pointer. 
  301. */
  302.  
  303. boolean
  304. bfd_default_set_arch_mach (abfd, arch, mach)
  305.      bfd *abfd;
  306.      enum bfd_architecture arch;
  307.      unsigned    long mach;
  308. {
  309.   static struct bfd_arch_info *old_ptr = &bfd_default_arch_struct;
  310.   boolean found = false;
  311.   /* run through the table to find the one we want, we keep a little
  312.      cache to speed things up */
  313.   if (old_ptr == 0 || arch != old_ptr->arch || mach != old_ptr->mach) {
  314.     bfd_arch_info_type *ptr;
  315.     old_ptr = (bfd_arch_info_type *)NULL;
  316.     for (ptr = bfd_arch_info_list;
  317.      ptr != (bfd_arch_info_type *)NULL;
  318.      ptr= ptr->next) {
  319.       if (ptr->arch == arch &&
  320.       ((ptr->mach == mach) || (ptr->the_default && mach == 0))) {
  321.     old_ptr = ptr;
  322.     found = true;
  323.     break;
  324.       }
  325.     }
  326.     if (found==false) {
  327.       /*looked for it and it wasn't there, so put in the default */
  328.       old_ptr = &bfd_default_arch_struct;
  329.       bfd_set_error (bfd_error_bad_value);
  330.     }
  331.   }
  332.   else {
  333.     /* it was in the cache */
  334.     found = true;
  335.   }
  336.  
  337.   abfd->arch_info = old_ptr;
  338.  
  339.   return found;
  340. }
  341.  
  342.  
  343. /*
  344. FUNCTION
  345.     bfd_get_arch
  346.  
  347. SYNOPSIS
  348.     enum bfd_architecture bfd_get_arch(bfd *abfd);
  349.  
  350. DESCRIPTION
  351.     Return the enumerated type which describes the BFD @var{abfd}'s
  352.     architecture.
  353.  
  354. */
  355.  
  356. enum bfd_architecture
  357. bfd_get_arch (abfd)
  358.      bfd *abfd;
  359. {
  360.     return abfd->arch_info->arch;
  361. }
  362.  
  363. /*
  364. FUNCTION
  365.     bfd_get_mach
  366.  
  367. SYNOPSIS
  368.     unsigned long bfd_get_mach(bfd *abfd);
  369.  
  370. DESCRIPTION
  371.     Return the long type which describes the BFD @var{abfd}'s
  372.     machine.
  373. */
  374.  
  375. unsigned long  
  376. bfd_get_mach (abfd)
  377.      bfd *abfd;
  378. {
  379.     return abfd->arch_info->mach;
  380. }
  381.  
  382. /*
  383. FUNCTION
  384.     bfd_arch_bits_per_byte
  385.  
  386. SYNOPSIS
  387.     unsigned int bfd_arch_bits_per_byte(bfd *abfd);
  388.  
  389. DESCRIPTION
  390.     Return the number of bits in one of the BFD @var{abfd}'s
  391.     architecture's bytes.
  392.  
  393. */
  394.  
  395. unsigned int
  396. bfd_arch_bits_per_byte (abfd)
  397.      bfd *abfd;
  398. {
  399.   return abfd->arch_info->bits_per_byte;
  400. }
  401.  
  402. /*
  403. FUNCTION
  404.     bfd_arch_bits_per_address
  405.  
  406. SYNOPSIS
  407.     unsigned int bfd_arch_bits_per_address(bfd *abfd);
  408.  
  409. DESCRIPTION
  410.     Return the number of bits in one of the BFD @var{abfd}'s
  411.     architecture's addresses.
  412. */
  413.  
  414. unsigned int
  415. bfd_arch_bits_per_address (abfd)
  416.      bfd *abfd;
  417. {
  418.   return abfd->arch_info->bits_per_address;
  419. }
  420.  
  421.  
  422. extern void bfd_a29k_arch PARAMS ((void));
  423. extern void bfd_alpha_arch PARAMS ((void));
  424. extern void bfd_arm_arch PARAMS ((void));
  425. extern void bfd_h8300_arch PARAMS ((void));
  426. extern void bfd_h8500_arch PARAMS ((void));
  427. extern void bfd_hppa_arch PARAMS ((void));
  428. extern void bfd_i386_arch PARAMS ((void));
  429. extern void bfd_i960_arch PARAMS ((void));
  430. extern void bfd_m68k_arch PARAMS ((void));
  431. extern void bfd_m88k_arch PARAMS ((void));
  432. extern void bfd_mips_arch PARAMS ((void));
  433. extern void bfd_powerpc_arch PARAMS ((void));
  434. extern void bfd_rs6000_arch PARAMS ((void));
  435. extern void bfd_sh_arch PARAMS ((void));
  436. extern void bfd_sparc_arch PARAMS ((void));
  437. extern void bfd_vax_arch PARAMS ((void));
  438. extern void bfd_we32k_arch PARAMS ((void));
  439. extern void bfd_z8k_arch PARAMS ((void));
  440. extern void bfd_ns32k_arch PARAMS ((void));
  441. extern void bfd_w65_arch PARAMS ((void));
  442.  
  443. static void (*const archures_init_table[]) PARAMS ((void)) = 
  444. {
  445. #ifdef SELECT_ARCHITECTURES
  446.   SELECT_ARCHITECTURES,
  447. #else
  448.   bfd_a29k_arch,
  449.   bfd_alpha_arch,
  450.   bfd_arm_arch,
  451.   bfd_h8300_arch,
  452.   bfd_h8500_arch,
  453.   bfd_hppa_arch,
  454.   bfd_i386_arch,
  455.   bfd_i960_arch,
  456.   bfd_m68k_arch,
  457.   bfd_m88k_arch,
  458.   bfd_mips_arch,
  459.   bfd_powerpc_arch,
  460.   bfd_rs6000_arch,
  461.   bfd_sh_arch,
  462.   bfd_sparc_arch,
  463.   bfd_vax_arch,
  464.   bfd_we32k_arch,
  465.   bfd_z8k_arch,
  466.   bfd_ns32k_arch,
  467.   bfd_w65_arch,
  468. #endif
  469.   0
  470.   };
  471.  
  472.  
  473.  
  474. /*
  475. INTERNAL_FUNCTION 
  476.     bfd_arch_init
  477.  
  478. SYNOPSIS
  479.     void bfd_arch_init(void);
  480.  
  481. DESCRIPTION
  482.     Initialize the architecture dispatch table by
  483.     calling all installed architecture packages and getting them
  484.     to poke around.
  485. */
  486.  
  487. void
  488. bfd_arch_init ()
  489. {
  490.     void (*const *ptable) PARAMS ((void));
  491.     for (ptable = archures_init_table; *ptable ; ptable++)
  492.       (*ptable)();
  493. }
  494.  
  495.  
  496. /*
  497. INTERNAL_FUNCTION
  498.     bfd_arch_linkin
  499.  
  500. SYNOPSIS
  501.     void bfd_arch_linkin(bfd_arch_info_type *ptr);
  502.  
  503. DESCRIPTION
  504.     Link the architecture info structure @var{ptr} into the list.
  505. */
  506.  
  507. void
  508. bfd_arch_linkin (ptr)
  509.      bfd_arch_info_type *ptr;
  510. {
  511.   ptr->next = bfd_arch_info_list;
  512.   bfd_arch_info_list = ptr;
  513. }
  514.  
  515.  
  516. /*
  517. INTERNAL_FUNCTION 
  518.     bfd_default_compatible
  519.  
  520. SYNOPSIS
  521.     CONST bfd_arch_info_type *bfd_default_compatible
  522.     (CONST bfd_arch_info_type *a,
  523.     CONST bfd_arch_info_type *b);
  524.  
  525. DESCRIPTION
  526.     The default function for testing for compatibility.
  527. */
  528.  
  529. CONST bfd_arch_info_type *
  530. bfd_default_compatible (a,b)
  531.      CONST bfd_arch_info_type *a;
  532.      CONST bfd_arch_info_type *b;
  533. {
  534.   if(a->arch != b->arch) return NULL;
  535.  
  536.   if (a->mach > b->mach) {
  537.     return a;
  538.   }
  539.   if (b->mach > a->mach) {
  540.     return b;
  541.   }
  542.   return a;
  543. }
  544.  
  545.  
  546. /*
  547. INTERNAL_FUNCTION
  548.     bfd_default_scan
  549.  
  550. SYNOPSIS
  551.     boolean bfd_default_scan(CONST struct bfd_arch_info *info, CONST char *string);
  552.  
  553. DESCRIPTION
  554.     The default function for working out whether this is an
  555.     architecture hit and a machine hit.
  556. */
  557.  
  558. boolean 
  559. bfd_default_scan (info, string)
  560.      CONST struct bfd_arch_info *info;
  561.      CONST char *string;
  562. {
  563.   CONST  char *ptr_src;
  564.   CONST   char *ptr_tst;
  565.   unsigned long number;
  566.   enum bfd_architecture arch;
  567.   /* First test for an exact match */
  568.   if (strcmp(string, info->printable_name) == 0) return true;
  569.  
  570.   /* See how much of the supplied string matches with the
  571.      architecture, eg the string m68k:68020 would match the 68k entry
  572.      up to the :, then we get left with the machine number */
  573.  
  574.   for (ptr_src = string,
  575.        ptr_tst = info->arch_name; 
  576.        *ptr_src && *ptr_tst;
  577.        ptr_src++,
  578.        ptr_tst++) 
  579.     {
  580.       if (*ptr_src != *ptr_tst) break;
  581.     }
  582.  
  583.   /* Chewed up as much of the architecture as will match, skip any
  584.      colons */
  585.   if (*ptr_src == ':') ptr_src++;
  586.   
  587.   if (*ptr_src == 0) {
  588.     /* nothing more, then only keep this one if it is the default
  589.        machine for this architecture */
  590.     return info->the_default;
  591.   }
  592.   number = 0;
  593.   while (isdigit(*ptr_src)) {
  594.     number = number * 10 + *ptr_src  - '0';
  595.     ptr_src++;
  596.   }
  597.  
  598.   switch (number) 
  599.     {
  600.     case 65:
  601.       arch = bfd_arch_w65;
  602.       break;
  603.  
  604.     case 300:
  605.       arch = bfd_arch_h8300;
  606.       break;
  607.  
  608.     case 500:
  609.       arch = bfd_arch_h8500;
  610.       break;
  611.  
  612.     case 68010:
  613.     case 68020:
  614.     case 68030:
  615.     case 68040:
  616.     case 68332:
  617.     case 68050:        
  618.     case 68000: 
  619.       arch = bfd_arch_m68k; 
  620.       break;
  621.     case 386: 
  622.     case 80386:
  623.     case 486:
  624.     case 80486:
  625.       arch = bfd_arch_i386;
  626.       break;
  627.     case 29000: 
  628.       arch = bfd_arch_a29k;
  629.       break;
  630.  
  631.     case 8000:
  632.       arch = bfd_arch_z8k;
  633.       break;
  634.  
  635.     case 32000:
  636.       arch = bfd_arch_we32k;
  637.       break;
  638.  
  639.     case 860:
  640.     case 80860: 
  641.       arch = bfd_arch_i860; 
  642.       break;
  643.     case 960:
  644.     case 80960:
  645.       arch = bfd_arch_i960;
  646.       break;
  647.  
  648.     case 2000:
  649.     case 3000:
  650.     case 4000:
  651.     case 4400:
  652.       arch = bfd_arch_mips;
  653.       break;
  654.  
  655.     case 6000:
  656.       arch = bfd_arch_rs6000;
  657.       break;
  658.  
  659.     default:  
  660.       return false;
  661.     }
  662.   if (arch != info->arch) 
  663.     return false;
  664.  
  665.   if (number != info->mach)
  666.     return false;
  667.  
  668.   return true;
  669. }
  670.  
  671.  
  672. /*
  673. FUNCTION
  674.     bfd_get_arch_info
  675.  
  676. SYNOPSIS
  677.     bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);
  678.  
  679. DESCRIPTION
  680.     Return the architecture info struct in @var{abfd}.
  681. */
  682.  
  683. bfd_arch_info_type *
  684. bfd_get_arch_info (abfd)
  685.      bfd *abfd;
  686. {
  687.   return  abfd->arch_info;
  688. }
  689.  
  690.  
  691. /*
  692. FUNCTION
  693.     bfd_lookup_arch
  694.  
  695. SYNOPSIS
  696.     bfd_arch_info_type *bfd_lookup_arch
  697.         (enum bfd_architecture
  698.         arch,
  699.         long machine);
  700.  
  701. DESCRIPTION
  702.     Look for the architecure info structure which matches the
  703.     arguments @var{arch} and @var{machine}. A machine of 0 matches the
  704.     machine/architecture structure which marks itself as the
  705.     default.
  706. */
  707.  
  708. bfd_arch_info_type * 
  709. bfd_lookup_arch (arch, machine)
  710.      enum bfd_architecture arch;
  711.      long machine;
  712. {
  713.     bfd_arch_info_type *ap;
  714.     bfd_check_init();  
  715.     for (ap = bfd_arch_info_list; 
  716.      ap !=  (bfd_arch_info_type *)NULL;
  717.      ap = ap->next) {
  718.         if (ap->arch == arch &&
  719.         ((ap->mach == machine) 
  720.          || (ap->the_default && machine == 0))) {
  721.             return ap;
  722.         }
  723.     }
  724.     return (bfd_arch_info_type *)NULL;
  725. }
  726.  
  727.  
  728. /*
  729. FUNCTION
  730.     bfd_printable_arch_mach
  731.  
  732. SYNOPSIS
  733.     CONST char *bfd_printable_arch_mach
  734.         (enum bfd_architecture arch, unsigned long machine);
  735.  
  736. DESCRIPTION
  737.     Return a printable string representing the architecture and
  738.     machine type. 
  739.  
  740.     This routine is depreciated.
  741. */
  742.  
  743. CONST char *
  744. bfd_printable_arch_mach (arch, machine)
  745.      enum bfd_architecture arch;
  746.      unsigned long machine;
  747. {
  748.     bfd_arch_info_type *ap = bfd_lookup_arch(arch, machine);
  749.     if(ap) return ap->printable_name;
  750.     return "UNKNOWN!";
  751. }
  752.