Commit | Line | Data |
---|---|---|
252b5132 RH |
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! */ | |
5 | ||
6 | /* emulate the original gld for the given ${EMULATION_NAME} | |
b34976b6 | 7 | Copyright 1991, 1992, 1994, 1996, 2000, 2001, 2002 |
b71e2778 | 8 | Free Software Foundation, Inc. |
252b5132 RH |
9 | Written by Steve Chamberlain steve@cygnus.com |
10 | ||
11 | This file is part of GLD, the Gnu Linker. | |
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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "ldmain.h" | |
252b5132 RH |
35 | #include "ldmisc.h" |
36 | ||
b71e2778 AM |
37 | #include "ldexp.h" |
38 | #include "ldlang.h" | |
39 | #include "ldfile.h" | |
40 | #include "ldemul.h" | |
41 | ||
252b5132 RH |
42 | static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); |
43 | static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); | |
44 | ||
55ab6103 HPN |
45 | EOF |
46 | ||
47 | # Import any needed special functions and/or overrides. | |
48 | # | |
49 | if test -n "$EXTRA_EM_FILE" ; then | |
50 | . ${srcdir}/emultempl/${EXTRA_EM_FILE}.em | |
51 | fi | |
52 | ||
53 | if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then | |
54 | cat >>e${EMULATION_NAME}.c <<EOF | |
55 | ||
252b5132 RH |
56 | static void |
57 | gld${EMULATION_NAME}_before_parse() | |
58 | { | |
59 | #ifndef TARGET_ /* I.e., if not generic. */ | |
60 | ldfile_set_output_arch ("`echo ${ARCH}`"); | |
61 | #endif /* not TARGET_ */ | |
62 | } | |
63 | ||
55ab6103 HPN |
64 | EOF |
65 | fi | |
66 | ||
67 | if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then | |
68 | cat >>e${EMULATION_NAME}.c <<EOF | |
69 | ||
252b5132 RH |
70 | static char * |
71 | gld${EMULATION_NAME}_get_script(isfile) | |
72 | int *isfile; | |
73 | EOF | |
74 | ||
75 | if test -n "$COMPILE_IN" | |
76 | then | |
77 | # Scripts compiled in. | |
78 | ||
79 | # sed commands to quote an ld script as a C string. | |
597e2591 | 80 | sc="-f stringify.sed" |
252b5132 RH |
81 | |
82 | cat >>e${EMULATION_NAME}.c <<EOF | |
83 | { | |
84 | *isfile = 0; | |
85 | ||
b34976b6 | 86 | if (link_info.relocateable && config.build_constructors) |
252b5132 RH |
87 | return |
88 | EOF | |
b34976b6 AM |
89 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
90 | echo ' ; else if (link_info.relocateable) return' >> e${EMULATION_NAME}.c | |
91 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c | |
92 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
93 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
94 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c | |
95 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
96 | echo ' ; else return' >> e${EMULATION_NAME}.c | |
97 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
98 | echo '; }' >> e${EMULATION_NAME}.c | |
252b5132 RH |
99 | |
100 | else | |
101 | # Scripts read from the filesystem. | |
102 | ||
103 | cat >>e${EMULATION_NAME}.c <<EOF | |
104 | { | |
105 | *isfile = 1; | |
106 | ||
b34976b6 | 107 | if (link_info.relocateable && config.build_constructors) |
252b5132 | 108 | return "ldscripts/${EMULATION_NAME}.xu"; |
b34976b6 | 109 | else if (link_info.relocateable) |
252b5132 RH |
110 | return "ldscripts/${EMULATION_NAME}.xr"; |
111 | else if (!config.text_read_only) | |
112 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
113 | else if (!config.magic_demand_paged) | |
114 | return "ldscripts/${EMULATION_NAME}.xn"; | |
115 | else | |
116 | return "ldscripts/${EMULATION_NAME}.x"; | |
117 | } | |
118 | EOF | |
55ab6103 | 119 | fi |
252b5132 RH |
120 | fi |
121 | ||
122 | cat >>e${EMULATION_NAME}.c <<EOF | |
123 | ||
124 | struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = | |
125 | { | |
55ab6103 HPN |
126 | ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse}, |
127 | ${LDEMUL_SYSLIB-syslib_default}, | |
128 | ${LDEMUL_HLL-hll_default}, | |
129 | ${LDEMUL_AFTER_PARSE-after_parse_default}, | |
130 | ${LDEMUL_AFTER_OPEN-after_open_default}, | |
131 | ${LDEMUL_AFTER_ALLOCATION-after_allocation_default}, | |
132 | ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default}, | |
133 | ${LDEMUL_CHOOSE_TARGET-ldemul_default_target}, | |
134 | ${LDEMUL_BEFORE_ALLOCATION-before_allocation_default}, | |
135 | ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script}, | |
252b5132 | 136 | "${EMULATION_NAME}", |
e1c47aa4 | 137 | "${OUTPUT_FORMAT}", |
55ab6103 HPN |
138 | ${LDEMUL_FINISH-NULL}, |
139 | ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL}, | |
140 | ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-NULL}, | |
141 | ${LDEMUL_PLACE_ORPHAN-NULL}, | |
142 | ${LDEMUL_SET_SYMBOLS-NULL}, | |
143 | ${LDEMUL_PARSE_ARGS-NULL}, | |
144 | ${LDEMUL_UNRECOGNIZED_FILE-NULL}, | |
145 | ${LDEMUL_LIST_OPTIONS-NULL}, | |
146 | ${LDEMUL_RECOGNIZED_FILE-NULL}, | |
fac1652d AM |
147 | ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, |
148 | ${LDEMUL_NEW_VERS_PATTERN-NULL} | |
252b5132 RH |
149 | }; |
150 | EOF |