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 /* emulate the original gld for the given ${EMULATION_NAME}
7 Copyright (C) 1991, 93, 94, 95, 96, 99, 2000
8 Free Software Foundation, Inc.
9 Written by Steve Chamberlain steve@cygnus.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
27 #define TARGET_IS_${EMULATION_NAME}
42 static void gld${EMULATION_NAME}_before_parse PARAMS ((void));
43 static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile));
46 gld${EMULATION_NAME}_before_parse()
48 #ifndef TARGET_ /* I.e., if not generic. */
49 ldfile_set_output_arch ("`echo ${ARCH}`");
50 #endif /* not TARGET_ */
54 gld${EMULATION_NAME}_get_script(isfile)
58 if test -n "$COMPILE_IN"
60 # Scripts compiled in.
62 # sed commands to quote an ld script as a C string.
65 cat >>e${EMULATION_NAME}.c <<EOF
69 if (link_info.relocateable == true && config.build_constructors == true)
72 sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
73 echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c
74 sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
75 echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
76 sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
77 echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
78 sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
79 echo ' ; else return' >> e${EMULATION_NAME}.c
80 sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
81 echo '; }' >> e${EMULATION_NAME}.c
84 # Scripts read from the filesystem.
86 cat >>e${EMULATION_NAME}.c <<EOF
90 if (link_info.relocateable == true && config.build_constructors == true)
91 return "ldscripts/${EMULATION_NAME}.xu";
92 else if (link_info.relocateable == true)
93 return "ldscripts/${EMULATION_NAME}.xr";
94 else if (!config.text_read_only)
95 return "ldscripts/${EMULATION_NAME}.xbn";
96 else if (!config.magic_demand_paged)
97 return "ldscripts/${EMULATION_NAME}.xn";
99 return "ldscripts/${EMULATION_NAME}.x";
105 cat >>e${EMULATION_NAME}.c <<EOF
107 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
109 gld${EMULATION_NAME}_before_parse,
114 after_allocation_default,
115 set_output_arch_default,
116 ldemul_default_target,
117 before_allocation_default,
118 gld${EMULATION_NAME}_get_script,
122 NULL, /* create output section statements */
123 NULL, /* open dynamic archive */
124 NULL, /* place orphan */
125 NULL, /* set symbols */
126 NULL, /* parse args */
127 NULL, /* unrecognized file */
128 NULL, /* list options */
129 NULL, /* recognized file */
130 NULL /* find_potential_libraries */