1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >e${EMULATION_NAME}.c <<EOF
4 /* This file is is generated by a shell script. DO NOT EDIT! */
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>
11 This file is part of GLD, the Gnu Linker.
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 2 of the License, or
16 (at your option) any later version.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
27 #define TARGET_IS_${EMULATION_NAME}
42 static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
43 static boolean gld${EMULATION_NAME}_open_dynamic_archive
44 PARAMS ((const char *, lang_input_statement_type *));
45 static void gld${EMULATION_NAME}_before_allocation PARAMS ((void));
46 static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
49 gld${EMULATION_NAME}_before_parse()
51 ldfile_output_architecture = bfd_arch_${ARCH};
52 config.dynamic_link = true;
55 /* Try to open a dynamic archive. This is where we know that Linux
56 dynamic libraries have an extension of .sa. */
59 gld${EMULATION_NAME}_open_dynamic_archive (arch, entry)
61 lang_input_statement_type *entry;
63 return ldfile_open_file_search (arch, entry, "lib", ".sa");
66 /* This is called after the sections have been attached to output
67 sections, but before any sizes or addresses have been set. */
70 gld${EMULATION_NAME}_before_allocation ()
72 if (link_info.relocateable)
75 /* Let the backend work out the sizes of any sections required by
77 if (! bfd_linux_size_dynamic_sections (output_bfd, &link_info))
78 einfo ("%P%F: failed to set dynamic section sizes: %E\n");
82 gld${EMULATION_NAME}_get_script(isfile)
86 if test -n "$COMPILE_IN"
88 # Scripts compiled in.
90 # sed commands to quote an ld script as a C string.
97 cat >>e${EMULATION_NAME}.c <<EOF
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`;
110 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
115 # Scripts read from the filesystem.
117 cat >>e${EMULATION_NAME}.c <<EOF
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";
130 return "ldscripts/${EMULATION_NAME}.x";
136 cat >>e${EMULATION_NAME}.c <<EOF
138 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
140 gld${EMULATION_NAME}_before_parse,
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,
153 gld${EMULATION_NAME}_open_dynamic_archive