1 # This shell script emits C code -*- C -*-
2 # to keep track of the machine type of Z80 object files
3 # It does some substitutions.
5 LDEMUL_BEFORE_PARSE=gldz80_before_parse
6 LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
7 LDEMUL_AFTER_OPEN=gldz80_after_open
9 cat >>e${EMULATION_NAME}.c <<EOF
10 /* --- \begin{z80.em} */
11 /* Codes for machine types, bitwise or gives the code to use for the
19 /* Bitwise or of the machine types seen so far. */
20 static int result_mach_type;
23 ${LDEMUL_BEFORE_PARSE} (void)
25 #ifndef TARGET_ /* I.e., if not generic. */
26 ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
27 #endif /* not TARGET_ */
28 result_mach_type = M_Z80STRICT;
32 /* Update result_mach_type. */
34 ${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
36 unsigned long mach_type;
38 mach_type = bfd_get_mach (entry->the_bfd);
41 case bfd_mach_z80strict:
42 result_mach_type |= M_Z80STRICT;
45 result_mach_type |= M_Z80;
47 case bfd_mach_z80full:
48 result_mach_type |= M_Z80FULL;
51 result_mach_type |= M_R800;
54 result_mach_type |= M_Z80ANY;
59 /* Set the machine type of the output file based on result_mach_type. */
61 gldz80_after_open (void)
63 unsigned long mach_type;
65 switch (result_mach_type)
68 mach_type = bfd_mach_z80strict;
71 mach_type = bfd_mach_z80;
74 mach_type = bfd_mach_z80full;
77 mach_type = bfd_mach_r800;
82 bfd_set_arch_mach (output_bfd, bfd_arch_z80, mach_type);
84 /* --- \end{z80.em} */