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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [emultempl/] [m68kcoff.em] - Blame information for rev 306

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

Line No. Rev Author Line
1 145 khays
# 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
/* Handle embedded relocs for m68k.
7
   Copyright 2000, 2002, 2003, 2004, 2005, 2007, 2008
8
   Free Software Foundation, Inc.
9
   Written by Michael Sokolov , based on generic.em
10
   by Steve Chamberlain , embedded relocs code based on
11
   mipsecoff.em by Ian Lance Taylor .
12
 
13
   This file is part of the GNU Binutils.
14
 
15
   This program is free software; you can redistribute it and/or modify
16
   it under the terms of the GNU General Public License as published by
17
   the Free Software Foundation; either version 3 of the License, or
18
   (at your option) any later version.
19
 
20
   This program is distributed in the hope that it will be useful,
21
   but WITHOUT ANY WARRANTY; without even the implied warranty of
22
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
   GNU General Public License for more details.
24
 
25
   You should have received a copy of the GNU General Public License
26
   along with this program; if not, write to the Free Software
27
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
28
   MA 02110-1301, USA.  */
29
 
30
#define TARGET_IS_${EMULATION_NAME}
31
 
32
#include "sysdep.h"
33
#include "bfd.h"
34
#include "bfdlink.h"
35
 
36
#include "ld.h"
37
#include "ldmain.h"
38
#include "ldexp.h"
39
#include "ldlang.h"
40
#include "ldfile.h"
41
#include "ldemul.h"
42
#include "ldmisc.h"
43
 
44
static void check_sections (bfd *, asection *, void *);
45
 
46
static void
47
gld${EMULATION_NAME}_before_parse (void)
48
{
49
#ifndef TARGET_                 /* I.e., if not generic.  */
50
  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
51
#endif /* not TARGET_ */
52
}
53
 
54
/* This function is run after all the input files have been opened.
55
   We create a .emreloc section for each input file with a non zero
56
   .data section.  The BFD backend will fill in these sections with
57
   magic numbers which can be used to relocate the data section at run
58
   time.  */
59
 
60
static void
61
gld${EMULATION_NAME}_after_open (void)
62
{
63
  bfd *abfd;
64
 
65
  after_open_default ();
66
 
67
  if (! command_line.embedded_relocs
68
      || link_info.relocatable)
69
    return;
70
 
71
  for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
72
    {
73
      asection *datasec;
74
 
75
      /* As first-order business, make sure that each input BFD is COFF. It
76
         better be, as we are directly calling a COFF backend function.  */
77
      if (bfd_get_flavour (abfd) != bfd_target_coff_flavour)
78
        einfo ("%F%B: all input objects must be COFF for --embedded-relocs\n");
79
 
80
      datasec = bfd_get_section_by_name (abfd, ".data");
81
 
82
      /* Note that we assume that the reloc_count field has already
83
         been set up.  We could call bfd_get_reloc_upper_bound, but
84
         that returns the size of a memory buffer rather than a reloc
85
         count.  We do not want to call bfd_canonicalize_reloc,
86
         because although it would always work it would force us to
87
         read in the relocs into BFD canonical form, which would waste
88
         a significant amount of time and memory.  */
89
      if (datasec != NULL && datasec->reloc_count > 0)
90
        {
91
          asection *relsec;
92
 
93
          relsec = bfd_make_section_with_flags (abfd, ".emreloc",
94
                                                (SEC_ALLOC
95
                                                 | SEC_LOAD
96
                                                 | SEC_HAS_CONTENTS
97
                                                 | SEC_IN_MEMORY));
98
          if (relsec == NULL
99
              || ! bfd_set_section_alignment (abfd, relsec, 2)
100
              || ! bfd_set_section_size (abfd, relsec,
101
                                         datasec->reloc_count * 12))
102
            einfo ("%F%B: can not create .emreloc section: %E\n");
103
        }
104
 
105
      /* Double check that all other data sections are empty, as is
106
         required for embedded PIC code.  */
107
      bfd_map_over_sections (abfd, check_sections, datasec);
108
    }
109
}
110
 
111
/* Check that of the data sections, only the .data section has
112
   relocs.  This is called via bfd_map_over_sections.  */
113
 
114
static void
115
check_sections (bfd *abfd, asection *sec, void *datasec)
116
{
117
  if ((bfd_get_section_flags (abfd, sec) & SEC_DATA)
118
      && sec != datasec
119
      && sec->reloc_count != 0)
120
    einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n",
121
           abfd, bfd_get_section_name (abfd, sec));
122
}
123
 
124
/* This function is called after the section sizes and offsets have
125
   been set.  If we are generating embedded relocs, it calls a special
126
   BFD backend routine to do the work.  */
127
 
128
static void
129
gld${EMULATION_NAME}_after_allocation (void)
130
{
131
  bfd *abfd;
132
 
133
  if (! command_line.embedded_relocs
134
      || link_info.relocatable)
135
    return;
136
 
137
  for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next)
138
    {
139
      asection *datasec, *relsec;
140
      char *errmsg;
141
 
142
      datasec = bfd_get_section_by_name (abfd, ".data");
143
 
144
      if (datasec == NULL || datasec->reloc_count == 0)
145
        continue;
146
 
147
      relsec = bfd_get_section_by_name (abfd, ".emreloc");
148
      ASSERT (relsec != NULL);
149
 
150
      if (! bfd_m68k_coff_create_embedded_relocs (abfd, &link_info,
151
                                                   datasec, relsec,
152
                                                   &errmsg))
153
        {
154
          if (errmsg == NULL)
155
            einfo ("%B%X: can not create runtime reloc information: %E\n",
156
                   abfd);
157
          else
158
            einfo ("%X%B: can not create runtime reloc information: %s\n",
159
                   abfd, errmsg);
160
        }
161
    }
162
}
163
 
164
static char *
165
gld${EMULATION_NAME}_get_script (int *isfile)
166
EOF
167
 
168
if test -n "$COMPILE_IN"
169
then
170
# Scripts compiled in.
171
 
172
# sed commands to quote an ld script as a C string.
173
sc="-f stringify.sed"
174
 
175
fragment <
176
{
177
  *isfile = 0;
178
 
179
  if (link_info.relocatable && config.build_constructors)
180
    return
181
EOF
182
sed $sc ldscripts/${EMULATION_NAME}.xu                 >> e${EMULATION_NAME}.c
183
echo '  ; else if (link_info.relocatable) return'     >> e${EMULATION_NAME}.c
184
sed $sc ldscripts/${EMULATION_NAME}.xr                 >> e${EMULATION_NAME}.c
185
echo '  ; else if (!config.text_read_only) return'     >> e${EMULATION_NAME}.c
186
sed $sc ldscripts/${EMULATION_NAME}.xbn                >> e${EMULATION_NAME}.c
187
echo '  ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
188
sed $sc ldscripts/${EMULATION_NAME}.xn                 >> e${EMULATION_NAME}.c
189
echo '  ; else return'                                 >> e${EMULATION_NAME}.c
190
sed $sc ldscripts/${EMULATION_NAME}.x                  >> e${EMULATION_NAME}.c
191
echo '; }'                                             >> e${EMULATION_NAME}.c
192
 
193
else
194
# Scripts read from the filesystem.
195
 
196
fragment <
197
{
198
  *isfile = 1;
199
 
200
  if (link_info.relocatable && config.build_constructors)
201
    return "ldscripts/${EMULATION_NAME}.xu";
202
  else if (link_info.relocatable)
203
    return "ldscripts/${EMULATION_NAME}.xr";
204
  else if (!config.text_read_only)
205
    return "ldscripts/${EMULATION_NAME}.xbn";
206
  else if (!config.magic_demand_paged)
207
    return "ldscripts/${EMULATION_NAME}.xn";
208
  else
209
    return "ldscripts/${EMULATION_NAME}.x";
210
}
211
EOF
212
 
213
fi
214
 
215
fragment <
216
 
217
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
218
{
219
  gld${EMULATION_NAME}_before_parse,
220
  syslib_default,
221
  hll_default,
222
  after_parse_default,
223
  gld${EMULATION_NAME}_after_open,
224
  gld${EMULATION_NAME}_after_allocation,
225
  set_output_arch_default,
226
  ldemul_default_target,
227
  before_allocation_default,
228
  gld${EMULATION_NAME}_get_script,
229
  "${EMULATION_NAME}",
230
  "${OUTPUT_FORMAT}",
231
  finish_default,
232
  NULL, /* create output section statements */
233
  NULL, /* open dynamic archive */
234
  NULL, /* place orphan */
235
  NULL, /* set symbols */
236
  NULL, /* parse args */
237
  NULL, /* add_options */
238
  NULL, /* handle_option */
239
  NULL, /* unrecognized file */
240
  NULL, /* list options */
241
  NULL, /* recognized file */
242
  NULL, /* find_potential_libraries */
243
  NULL  /* new_vers_pattern */
244
};
245
EOF

powered by: WebSVN 2.1.0

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