~ubuntu-branches/ubuntu/utopic/binutils-arm64-cross/utopic

« back to all changes in this revision

Viewing changes to binutils-2.23.52.20130611/ld/emultempl/z80.em

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-06-20 17:38:09 UTC
  • Revision ID: package-import@ubuntu.com-20130620173809-app8lzgvymy5fg6c
Tags: 0.7
Build-depend on binutils-source (>= 2.23.52.20130620-1~).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
#   Copyright 2005, 2007, 2008 Free Software Foundation, Inc.
 
5
# This file is part of the GNU Binutils.
 
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 3 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., 51 Franklin Street - Fifth Floor, Boston,
 
20
# MA 02110-1301, USA.
 
21
 
 
22
LDEMUL_BEFORE_PARSE=gldz80_before_parse
 
23
LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
 
24
LDEMUL_AFTER_OPEN=gldz80_after_open
 
25
 
 
26
fragment <<EOF
 
27
/* --- \begin{z80.em} */
 
28
/* Codes for machine types, bitwise or gives the code to use for the
 
29
   output.  */
 
30
#define M_Z80STRICT 1
 
31
#define M_Z80 3
 
32
#define M_Z80FULL 7
 
33
#define M_R800 11
 
34
#define M_Z80ANY 15
 
35
 
 
36
/* Bitwise or of the machine types seen so far.  */
 
37
static int result_mach_type;
 
38
 
 
39
static void
 
40
${LDEMUL_BEFORE_PARSE} (void)
 
41
{
 
42
#ifndef TARGET_                 /* I.e., if not generic.  */
 
43
  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 
44
#endif /* not TARGET_ */
 
45
  result_mach_type = M_Z80STRICT;
 
46
}
 
47
 
 
48
 
 
49
/* Update result_mach_type.  */
 
50
static bfd_boolean
 
51
${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
 
52
{
 
53
  unsigned long mach_type;
 
54
 
 
55
  mach_type = bfd_get_mach (entry->the_bfd);
 
56
  switch (mach_type)
 
57
    {
 
58
    case bfd_mach_z80strict:
 
59
      result_mach_type |= M_Z80STRICT;
 
60
      break;
 
61
    case bfd_mach_z80:
 
62
      result_mach_type |= M_Z80;
 
63
      break;
 
64
    case bfd_mach_z80full:
 
65
      result_mach_type |= M_Z80FULL;
 
66
      break;
 
67
    case bfd_mach_r800:
 
68
      result_mach_type |= M_R800;
 
69
      break;
 
70
    default:
 
71
      result_mach_type |= M_Z80ANY;
 
72
    }
 
73
  return FALSE;
 
74
}
 
75
 
 
76
/* Set the machine type of the output file based on result_mach_type.  */
 
77
static void
 
78
gldz80_after_open (void)
 
79
{
 
80
  unsigned long mach_type;
 
81
 
 
82
  after_open_default ();
 
83
 
 
84
  switch (result_mach_type)
 
85
    {
 
86
    case M_Z80STRICT:
 
87
      mach_type = bfd_mach_z80strict;
 
88
      break;
 
89
    case M_Z80:
 
90
      mach_type = bfd_mach_z80;
 
91
      break;
 
92
    case M_Z80FULL:
 
93
      mach_type = bfd_mach_z80full;
 
94
      break;
 
95
    case M_R800:
 
96
      mach_type = bfd_mach_r800;
 
97
      break;
 
98
    default:
 
99
      mach_type = 0;
 
100
    }
 
101
  bfd_set_arch_mach (link_info.output_bfd, bfd_arch_z80, mach_type);
 
102
}
 
103
/* --- \end{z80.em} */
 
104
EOF