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/] [armcoff.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
fragment <
4
/* This file is is generated by a shell script.  DO NOT EDIT! */
5
 
6
/* emulate the original gld for the given ${EMULATION_NAME}
7
   Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
8
   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
9
   Written by Steve Chamberlain steve@cygnus.com
10
 
11
   This file is part of the GNU Binutils.
12
 
13
   This program is free software; you can redistribute it and/or modify
14
   it under the terms of the GNU General Public License as published by
15
   the Free Software Foundation; either version 3 of the License, or
16
   (at your option) any later version.
17
 
18
   This program is distributed in the hope that it will be useful,
19
   but WITHOUT ANY WARRANTY; without even the implied warranty of
20
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
   GNU General Public License for more details.
22
 
23
   You should have received a copy of the GNU General Public License
24
   along with this program; if not, write to the Free Software
25
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
26
   MA 02110-1301, USA.  */
27
 
28
#define TARGET_IS_${EMULATION_NAME}
29
 
30
#include "sysdep.h"
31
#include "bfd.h"
32
#include "bfdlink.h"
33
#include "getopt.h"
34
 
35
#include "ld.h"
36
#include "ldmain.h"
37
#include "ldmisc.h"
38
 
39
#include "ldexp.h"
40
#include "ldlang.h"
41
#include "ldfile.h"
42
#include "ldemul.h"
43
 
44
/* If TRUE, then interworking stubs which support calls to old,
45
   non-interworking aware ARM code should be generated.  */
46
 
47
static int support_old_code = 0;
48
static char * thumb_entry_symbol = NULL;
49
 
50
#define OPTION_SUPPORT_OLD_CODE         300
51
#define OPTION_THUMB_ENTRY              301
52
 
53
static void
54
gld${EMULATION_NAME}_add_options
55
  (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
56
   struct option **longopts, int nrl ATTRIBUTE_UNUSED,
57
   struct option **really_longopts ATTRIBUTE_UNUSED)
58
{
59
  static const struct option xtra_long[] = {
60
    {"support-old-code", no_argument, NULL, OPTION_SUPPORT_OLD_CODE},
61
    {"thumb-entry", required_argument, NULL, OPTION_THUMB_ENTRY},
62
    {NULL, no_argument, NULL, 0}
63
  };
64
 
65
  *longopts = xrealloc (*longopts,
66
                        nl * sizeof (struct option) + sizeof (xtra_long));
67
  memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
68
}
69
 
70
static void
71
gld${EMULATION_NAME}_list_options (FILE *file)
72
{
73
  fprintf (file, _("  --support-old-code          Support interworking with old code\n"));
74
  fprintf (file, _("  --thumb-entry=         Set the entry point to be Thumb symbol \n"));
75
}
76
 
77
static bfd_boolean
78
gld${EMULATION_NAME}_handle_option (int optc)
79
{
80
  switch (optc)
81
    {
82
    default:
83
      return FALSE;
84
 
85
    case OPTION_SUPPORT_OLD_CODE:
86
      support_old_code = 1;
87
      break;
88
 
89
    case OPTION_THUMB_ENTRY:
90
      thumb_entry_symbol = optarg;
91
      break;
92
    }
93
 
94
  return TRUE;
95
}
96
 
97
static void
98
gld${EMULATION_NAME}_before_parse (void)
99
{
100
#ifndef TARGET_                 /* I.e., if not generic.  */
101
  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
102
#endif /* not TARGET_ */
103
}
104
 
105
/* This is called after the sections have been attached to output
106
   sections, but before any sizes or addresses have been set.  */
107
 
108
static void
109
gld${EMULATION_NAME}_before_allocation (void)
110
{
111
  /* we should be able to set the size of the interworking stub section */
112
 
113
  /* Here we rummage through the found bfds to collect glue information */
114
  /* FIXME: should this be based on a command line option? krk@cygnus.com */
115
  {
116
    LANG_FOR_EACH_INPUT_STATEMENT (is)
117
      {
118
        if (! bfd_arm_process_before_allocation
119
            (is->the_bfd, & link_info, support_old_code))
120
          {
121
            /* xgettext:c-format */
122
            einfo (_("Errors encountered processing file %s"), is->filename);
123
          }
124
      }
125
  }
126
 
127
  /* We have seen it all. Allocate it, and carry on */
128
  bfd_arm_allocate_interworking_sections (& link_info);
129
 
130
  before_allocation_default ();
131
}
132
 
133
static void
134
gld${EMULATION_NAME}_after_open (void)
135
{
136
  if (strstr (bfd_get_target (link_info.output_bfd), "arm") == NULL)
137
    {
138
      /* The arm backend needs special fields in the output hash structure.
139
         These will only be created if the output format is an arm format,
140
         hence we do not support linking and changing output formats at the
141
         same time.  Use a link followed by objcopy to change output formats.  */
142
      einfo ("%F%X%P: error: cannot change output format whilst linking ARM binaries\n");
143
      return;
144
    }
145
 
146
  {
147
    LANG_FOR_EACH_INPUT_STATEMENT (is)
148
      {
149
        if (bfd_arm_get_bfd_for_interworking (is->the_bfd, & link_info))
150
          break;
151
      }
152
  }
153
}
154
 
155
static void
156
gld${EMULATION_NAME}_finish (void)
157
{
158
  if (thumb_entry_symbol != NULL)
159
    {
160
      struct bfd_link_hash_entry * h;
161
 
162
      h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol,
163
                                FALSE, FALSE, TRUE);
164
 
165
      if (h != (struct bfd_link_hash_entry *) NULL
166
          && (h->type == bfd_link_hash_defined
167
              || h->type == bfd_link_hash_defweak)
168
          && h->u.def.section->output_section != NULL)
169
        {
170
          static char buffer[32];
171
          bfd_vma val;
172
 
173
          /* Special procesing is required for a Thumb entry symbol.  The
174
             bottom bit of its address must be set.  */
175
          val = (h->u.def.value
176
                 + bfd_get_section_vma (link_info.output_bfd,
177
                                        h->u.def.section->output_section)
178
                 + h->u.def.section->output_offset);
179
 
180
          val |= 1;
181
 
182
          /* Now convert this value into a string and store it in entry_symbol
183
             where the lang_finish() function will pick it up.  */
184
          buffer[0] = '0';
185
          buffer[1] = 'x';
186
 
187
          sprintf_vma (buffer + 2, val);
188
 
189
          if (entry_symbol.name != NULL && entry_from_cmdline)
190
            einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
191
                   thumb_entry_symbol, entry_symbol.name);
192
          entry_symbol.name = buffer;
193
        }
194
      else
195
        einfo (_("%P: warning: cannot find thumb start symbol %s\n"),
196
               thumb_entry_symbol);
197
    }
198
 
199
  finish_default ();
200
}
201
 
202
static char *
203
gld${EMULATION_NAME}_get_script (int *isfile)
204
EOF
205
 
206
if test -n "$COMPILE_IN"
207
then
208
# Scripts compiled in.
209
 
210
# sed commands to quote an ld script as a C string.
211
sc="-f stringify.sed"
212
 
213
fragment <
214
{
215
  *isfile = 0;
216
 
217
  if (link_info.relocatable && config.build_constructors)
218
    return
219
EOF
220
sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
221
echo '  ; else if (link_info.relocatable) return'     >> e${EMULATION_NAME}.c
222
sed $sc ldscripts/${EMULATION_NAME}.xr                 >> e${EMULATION_NAME}.c
223
echo '  ; else if (!config.text_read_only) return'     >> e${EMULATION_NAME}.c
224
sed $sc ldscripts/${EMULATION_NAME}.xbn                >> e${EMULATION_NAME}.c
225
echo '  ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
226
sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
227
echo '  ; else return'                                 >> e${EMULATION_NAME}.c
228
sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
229
echo '; }'                                             >> e${EMULATION_NAME}.c
230
 
231
else
232
# Scripts read from the filesystem.
233
 
234
fragment <
235
{
236
  *isfile = 1;
237
 
238
  if (link_info.relocatable && config.build_constructors)
239
    return "ldscripts/${EMULATION_NAME}.xu";
240
  else if (link_info.relocatable)
241
    return "ldscripts/${EMULATION_NAME}.xr";
242
  else if (!config.text_read_only)
243
    return "ldscripts/${EMULATION_NAME}.xbn";
244
  else if (!config.magic_demand_paged)
245
    return "ldscripts/${EMULATION_NAME}.xn";
246
  else
247
    return "ldscripts/${EMULATION_NAME}.x";
248
}
249
EOF
250
 
251
fi
252
 
253
fragment <
254
 
255
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
256
{
257
  gld${EMULATION_NAME}_before_parse,
258
  syslib_default,
259
  hll_default,
260
  after_parse_default,
261
  gld${EMULATION_NAME}_after_open,
262
  after_allocation_default,
263
  set_output_arch_default,
264
  ldemul_default_target,
265
  gld${EMULATION_NAME}_before_allocation,
266
  gld${EMULATION_NAME}_get_script,
267
  "${EMULATION_NAME}",
268
  "${OUTPUT_FORMAT}",
269
  gld${EMULATION_NAME}_finish,
270
  NULL, /* create output section statements */
271
  NULL, /* open dynamic archive */
272
  NULL, /* place orphan */
273
  NULL, /* set symbols */
274
  NULL, /* parse_args */
275
  gld${EMULATION_NAME}_add_options,
276
  gld${EMULATION_NAME}_handle_option,
277
  NULL, /* unrecognised file */
278
  gld${EMULATION_NAME}_list_options,
279
  NULL, /* recognized file */
280
  NULL, /* find_potential_libraries */
281
  NULL  /* new_vers_pattern */
282
};
283
EOF

powered by: WebSVN 2.1.0

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