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