]>
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} | |
597e2591 | 7 | Copyright (C) 1991, 93, 94, 95, 96, 1999 Free Software Foundation, Inc. |
252b5132 RH |
8 | Written by Steve Chamberlain [email protected] |
9 | ||
10 | This file is part of GLD, the Gnu Linker. | |
11 | ||
12 | This program is free software; you can redistribute it and/or modify | |
13 | it under the terms of the GNU General Public License as published by | |
14 | the Free Software Foundation; either version 2 of the License, or | |
15 | (at your option) any later version. | |
16 | ||
17 | This program is distributed in the hope that it will be useful, | |
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 | GNU General Public License for more details. | |
21 | ||
22 | You should have received a copy of the GNU General Public License | |
23 | along with this program; if not, write to the Free Software | |
24 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
25 | ||
26 | #define TARGET_IS_${EMULATION_NAME} | |
27 | ||
28 | #include "bfd.h" | |
29 | #include "sysdep.h" | |
30 | #include "bfdlink.h" | |
31 | ||
32 | #include "ld.h" | |
33 | #include "ldmain.h" | |
34 | #include "ldemul.h" | |
35 | #include "ldfile.h" | |
36 | #include "ldmisc.h" | |
37 | ||
38 | static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); | |
39 | static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); | |
40 | ||
41 | static void | |
42 | gld${EMULATION_NAME}_before_parse() | |
43 | { | |
44 | #ifndef TARGET_ /* I.e., if not generic. */ | |
45 | ldfile_set_output_arch ("`echo ${ARCH}`"); | |
46 | #endif /* not TARGET_ */ | |
47 | } | |
48 | ||
49 | static char * | |
50 | gld${EMULATION_NAME}_get_script(isfile) | |
51 | int *isfile; | |
52 | EOF | |
53 | ||
54 | if test -n "$COMPILE_IN" | |
55 | then | |
56 | # Scripts compiled in. | |
57 | ||
58 | # sed commands to quote an ld script as a C string. | |
597e2591 | 59 | sc="-f stringify.sed" |
252b5132 RH |
60 | |
61 | cat >>e${EMULATION_NAME}.c <<EOF | |
62 | { | |
63 | *isfile = 0; | |
64 | ||
65 | if (link_info.relocateable == true && config.build_constructors == true) | |
66 | return | |
67 | EOF | |
68 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c | |
69 | echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c | |
70 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c | |
71 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
72 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
73 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c | |
74 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
75 | echo ' ; else return' >> e${EMULATION_NAME}.c | |
76 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
77 | echo '; }' >> e${EMULATION_NAME}.c | |
78 | ||
79 | else | |
80 | # Scripts read from the filesystem. | |
81 | ||
82 | cat >>e${EMULATION_NAME}.c <<EOF | |
83 | { | |
84 | *isfile = 1; | |
85 | ||
86 | if (link_info.relocateable == true && config.build_constructors == true) | |
87 | return "ldscripts/${EMULATION_NAME}.xu"; | |
88 | else if (link_info.relocateable == true) | |
89 | return "ldscripts/${EMULATION_NAME}.xr"; | |
90 | else if (!config.text_read_only) | |
91 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
92 | else if (!config.magic_demand_paged) | |
93 | return "ldscripts/${EMULATION_NAME}.xn"; | |
94 | else | |
95 | return "ldscripts/${EMULATION_NAME}.x"; | |
96 | } | |
97 | EOF | |
98 | ||
99 | fi | |
100 | ||
101 | cat >>e${EMULATION_NAME}.c <<EOF | |
102 | ||
103 | struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = | |
104 | { | |
105 | gld${EMULATION_NAME}_before_parse, | |
106 | syslib_default, | |
107 | hll_default, | |
108 | after_parse_default, | |
109 | after_open_default, | |
110 | after_allocation_default, | |
111 | set_output_arch_default, | |
112 | ldemul_default_target, | |
113 | before_allocation_default, | |
114 | gld${EMULATION_NAME}_get_script, | |
115 | "${EMULATION_NAME}", | |
116 | "${OUTPUT_FORMAT}" | |
117 | }; | |
118 | EOF |