OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [ld/] [emultempl/] [ticoff.em] - Blame information for rev 438

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
# This shell script emits a C file. -*- C -*-
2
# It does some substitutions.
3
(echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
4
fragment <
5
/* This file is part of GLD, the Gnu Linker.
6
   Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2007
7
   Free Software Foundation, Inc.
8
 
9
   This file is part of the GNU Binutils.
10
 
11
   This program is free software; you can redistribute it and/or modify
12
   it under the terms of the GNU General Public License as published by
13
   the Free Software Foundation; either version 3 of the License, or
14
   (at your option) any later version.
15
 
16
   This program is distributed in the hope that it will be useful,
17
   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
   GNU General Public License for more details.
20
 
21
   You should have received a copy of the GNU General Public License
22
   along with this program; if not, write to the Free Software
23
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24
   MA 02110-1301, USA.  */
25
 
26
/* For TI COFF */
27
/* Need to determine load and run pages for output sections */
28
 
29
#define TARGET_IS_${EMULATION_NAME}
30
 
31
#include "sysdep.h"
32
#include "bfd.h"
33
#include "bfdlink.h"
34
#include "getopt.h"
35
 
36
#include "ld.h"
37
#include "ldmain.h"
38
#include "ldmisc.h"
39
#include "ldexp.h"
40
#include "ldlang.h"
41
#include "ldfile.h"
42
#include "ldemul.h"
43
 
44
static int coff_version;
45
 
46
/* TI COFF extra command line options */
47
#define OPTION_COFF_FORMAT              (300 + 1)
48
 
49
static void
50
gld${EMULATION_NAME}_add_options
51
  (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
52
   struct option **longopts, int nrl ATTRIBUTE_UNUSED,
53
   struct option **really_longopts ATTRIBUTE_UNUSED)
54
{
55
  static const struct option xtra_long[] = {
56
    /* TI COFF options */
57
    {"format", required_argument, NULL, OPTION_COFF_FORMAT },
58
    {NULL, no_argument, NULL, 0}
59
  };
60
 
61
  *longopts = (struct option *)
62
    xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
63
  memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
64
}
65
 
66
static void
67
gld_${EMULATION_NAME}_list_options (FILE * file)
68
{
69
  fprintf (file, _("  --format 0|1|2              Specify which COFF version to use\n"));
70
}
71
 
72
static bfd_boolean
73
gld${EMULATION_NAME}_handle_option (int optc)
74
{
75
  switch (optc)
76
    {
77
    default:
78
      return FALSE;
79
 
80
    case OPTION_COFF_FORMAT:
81
      if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
82
          && optarg[1] == '\0')
83
      {
84
        static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
85
        coff_version = *optarg - '0';
86
        buf[4] = *optarg;
87
        lang_add_output_format (buf, NULL, NULL, 0);
88
      }
89
      else
90
        {
91
          einfo (_("%P%F: invalid COFF format version %s\n"), optarg);
92
        }
93
      break;
94
    }
95
  return FALSE;
96
}
97
 
98
static void
99
gld_${EMULATION_NAME}_before_parse(void)
100
{
101
#ifndef TARGET_                 /* I.e., if not generic.  */
102
  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
103
#endif /* not TARGET_ */
104
}
105
 
106
static char *
107
gld_${EMULATION_NAME}_get_script (int *isfile)
108
EOF
109
if test -n "$COMPILE_IN"
110
then
111
# Scripts compiled in.
112
 
113
# sed commands to quote an ld script as a C string.
114
sc='s/["\\]/\\&/g
115
s/$/\\n\\/
116
1s/^/"/
117
$s/$/n"/
118
'
119
fragment <
120
{
121
  *isfile = 0;
122
  if (link_info.relocatable && config.build_constructors)
123
    return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
124
  else if (link_info.relocatable)
125
    return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
126
  else if (!config.text_read_only)
127
    return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
128
  else if (!config.magic_demand_paged)
129
    return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
130
  else
131
    return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
132
}
133
EOF
134
 
135
else
136
# Scripts read from the filesystem.
137
 
138
fragment <
139
{
140
  *isfile = 1;
141
 
142
  if (link_info.relocatable && config.build_constructors)
143
    return "ldscripts/${EMULATION_NAME}.xu";
144
  else if (link_info.relocatable)
145
    return "ldscripts/${EMULATION_NAME}.xr";
146
  else if (!config.text_read_only)
147
    return "ldscripts/${EMULATION_NAME}.xbn";
148
  else if (!config.magic_demand_paged)
149
    return "ldscripts/${EMULATION_NAME}.xn";
150
  else
151
    return "ldscripts/${EMULATION_NAME}.x";
152
}
153
EOF
154
 
155
fi
156
 
157
fragment <
158
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
159
{
160
  gld_${EMULATION_NAME}_before_parse,
161
  syslib_default,
162
  hll_default,
163
  after_parse_default,
164
  after_open_default,
165
  after_allocation_default,
166
  set_output_arch_default,
167
  ldemul_default_target,
168
  before_allocation_default,
169
  gld_${EMULATION_NAME}_get_script,
170
  "${EMULATION_NAME}",
171
  "${OUTPUT_FORMAT}",
172
  finish_default,
173
  NULL, /* create output section statements */
174
  NULL, /* open dynamic archive */
175
  NULL, /* place orphan */
176
  NULL, /* set_symbols */
177
  NULL, /* parse_args */
178
  gld${EMULATION_NAME}_add_options,
179
  gld${EMULATION_NAME}_handle_option,
180
  NULL, /* unrecognized_file */
181
  gld_${EMULATION_NAME}_list_options,
182
  NULL, /* recognized file */
183
  NULL, /* find_potential_libraries */
184
  NULL  /* new_vers_pattern */
185
};
186
EOF

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.