Commit | Line | Data |
---|---|---|
a6152e39 DM |
1 | # This shell script emits a C file. -*- C -*- |
2 | # It does some substitutions. | |
3 | cat >em_${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} | |
7 | Copyright (C) 1991 Free Software Foundation, Inc. | |
8 | Written by Steve Chamberlain steve@cygnus.com | |
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., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
25 | ||
26 | #define TARGET_IS_${EMULATION_NAME} | |
27 | ||
28 | #include "bfd.h" | |
29 | #include "sysdep.h" | |
30 | #include "ld.h" | |
31 | #include "config.h" | |
32 | #include "ldemul.h" | |
33 | #include "ldfile.h" | |
34 | #include "ldmisc.h" | |
35 | ||
36 | extern boolean lang_float_flag; | |
37 | ||
38 | extern enum bfd_architecture ldfile_output_architecture; | |
39 | extern unsigned long ldfile_output_machine; | |
40 | extern char *ldfile_output_machine_name; | |
41 | ||
42 | static void | |
43 | gld${EMULATION_NAME}_before_parse() | |
44 | { | |
45 | extern char lprefix; | |
46 | lprefix = '@'; | |
47 | ||
48 | ldfile_output_architecture = bfd_arch_${ARCH}; | |
49 | } | |
50 | ||
51 | static char * | |
52 | gld${EMULATION_NAME}_get_script(isfile) | |
53 | int *isfile; | |
54 | EOF | |
55 | ||
56 | if test "$DEFAULT_EMULATION" = "$EMULATION_NAME" | |
57 | then | |
58 | # Scripts compiled in. | |
59 | ||
60 | # sed commands to quote an ld script as a C string. | |
61 | sc='s/["\\]/\\&/g | |
62 | s/$/\\n\\/ | |
63 | 1s/^/"{/ | |
64 | $s/$/n}"/ | |
65 | ' | |
66 | ||
67 | cat >>em_${EMULATION_NAME}.c <<EOF | |
68 | { | |
69 | extern ld_config_type config; | |
70 | ||
71 | *isfile = 0; | |
72 | ||
73 | if (config.relocateable_output == true && config.build_constructors == true) | |
74 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`; | |
75 | else if (config.relocateable_output == true) | |
76 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`; | |
77 | else if (!config.text_read_only) | |
78 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`; | |
79 | else if (!config.magic_demand_paged) | |
80 | return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`; | |
81 | else | |
82 | return `sed "$sc" ldscripts/${EMULATION_NAME}.x`; | |
83 | } | |
84 | EOF | |
85 | ||
86 | else | |
87 | # Scripts read from the filesystem. | |
88 | ||
89 | cat >>em_${EMULATION_NAME}.c <<EOF | |
90 | { | |
91 | extern ld_config_type config; | |
92 | ||
93 | *isfile = 1; | |
94 | ||
95 | if (config.relocateable_output == true && config.build_constructors == true) | |
96 | return "ldscripts/${EMULATION_NAME}.xu"; | |
97 | else if (config.relocateable_output == true) | |
98 | return "ldscripts/${EMULATION_NAME}.xr"; | |
99 | else if (!config.text_read_only) | |
100 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
101 | else if (!config.magic_demand_paged) | |
102 | return "ldscripts/${EMULATION_NAME}.xn"; | |
103 | else | |
104 | return "ldscripts/${EMULATION_NAME}.x"; | |
105 | } | |
106 | EOF | |
107 | ||
108 | fi | |
109 | ||
110 | cat >>em_${EMULATION_NAME}.c <<EOF | |
111 | ||
112 | struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = | |
113 | { | |
114 | gld${EMULATION_NAME}_before_parse, | |
115 | syslib_default, | |
116 | hll_default, | |
117 | after_parse_default, | |
118 | after_allocation_default, | |
119 | set_output_arch_default, | |
120 | ldemul_default_target, | |
121 | before_allocation_default, | |
122 | gld${EMULATION_NAME}_get_script, | |
123 | "${EMULATION_NAME}", | |
124 | "${OUTPUT_FORMAT}" | |
125 | }; | |
126 | EOF |