remove unnecessary blank line
[deliverable/binutils-gdb.git] / ld / emultempl / linux.em
CommitLineData
08f20f66
ILT
1# This shell script emits a C file. -*- C -*-
2# It does some substitutions.
3cat >e${EMULATION_NAME}.c <<EOF
4/* This file is is generated by a shell script. DO NOT EDIT! */
5
6/* Linux a.out emulation code for ${EMULATION_NAME}
7 Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
8 Written by Steve Chamberlain <sac@cygnus.com>
9 Linux support by Eric Youngdale <ericy@cais.cais.com>
10
11This file is part of GLD, the Gnu Linker.
12
13This program is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License as published by
15the Free Software Foundation; either version 2 of the License, or
16(at your option) any later version.
17
18This program is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with this program; if not, write to the Free Software
25Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
26
27#define TARGET_IS_${EMULATION_NAME}
28
29#include "bfd.h"
30#include "sysdep.h"
31#include "bfdlink.h"
32
33#include "ld.h"
34#include "config.h"
35#include "ldmain.h"
36#include "ldemul.h"
37#include "ldfile.h"
38#include "ldmisc.h"
39#include "ldexp.h"
40#include "ldlang.h"
41
42static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
43static boolean gld${EMULATION_NAME}_open_dynamic_archive
44 PARAMS ((const char *, lang_input_statement_type *));
45static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
46static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
47
48static void
49gld${EMULATION_NAME}_before_parse()
50{
51 ldfile_output_architecture = bfd_arch_${ARCH};
52 config.dynamic_link = true;
53}
54
55/* Try to open a dynamic archive. This is where we know that Linux
56 dynamic libraries have an extension of .sa. */
57
58static boolean
59gld${EMULATION_NAME}_open_dynamic_archive (arch, entry)
60 const char *arch;
61 lang_input_statement_type *entry;
62{
63 return ldfile_open_file_search (arch, entry, "lib", ".sa");
64}
65
66/* This is called after the sections have been attached to output
67 sections, but before any sizes or addresses have been set. */
68
69static void
70gld${EMULATION_NAME}_before_allocation ()
71{
72 if (link_info.relocateable)
73 return;
74
75 /* Let the backend work out the sizes of any sections required by
76 dynamic linking. */
77 if (! bfd_linux_size_dynamic_sections (output_bfd, &link_info))
78 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
79}
80
81static char *
82gld${EMULATION_NAME}_get_script(isfile)
83 int *isfile;
84EOF
85
86if test -n "$COMPILE_IN"
87then
88# Scripts compiled in.
89
90# sed commands to quote an ld script as a C string.
91sc='s/["\\]/\\&/g
92s/$/\\n\\/
931s/^/"/
94$s/$/n"/
95'
96
97cat >>e${EMULATION_NAME}.c <<EOF
98{
99 *isfile = 0;
100
101 if (link_info.relocateable == true && config.build_constructors == true)
102 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
103 else if (link_info.relocateable == true)
104 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
105 else if (!config.text_read_only)
106 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
107 else if (!config.magic_demand_paged)
108 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
109 else
110 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
111}
112EOF
113
114else
115# Scripts read from the filesystem.
116
117cat >>e${EMULATION_NAME}.c <<EOF
118{
119 *isfile = 1;
120
121 if (link_info.relocateable == true && config.build_constructors == true)
122 return "ldscripts/${EMULATION_NAME}.xu";
123 else if (link_info.relocateable == true)
124 return "ldscripts/${EMULATION_NAME}.xr";
125 else if (!config.text_read_only)
126 return "ldscripts/${EMULATION_NAME}.xbn";
127 else if (!config.magic_demand_paged)
128 return "ldscripts/${EMULATION_NAME}.xn";
129 else
130 return "ldscripts/${EMULATION_NAME}.x";
131}
132EOF
133
134fi
135
136cat >>e${EMULATION_NAME}.c <<EOF
137
138struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
139{
140 gld${EMULATION_NAME}_before_parse,
141 syslib_default,
142 hll_default,
143 after_parse_default,
144 after_allocation_default,
145 set_output_arch_default,
146 ldemul_default_target,
147 gld${EMULATION_NAME}_before_allocation,
148 gld${EMULATION_NAME}_get_script,
149 "${EMULATION_NAME}",
150 "${OUTPUT_FORMAT}",
151 NULL,
152 NULL,
153 gld${EMULATION_NAME}_open_dynamic_archive
154};
155EOF
This page took 0.133499 seconds and 4 git commands to generate.