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 | |
597e2591 | 4 | /* Copyright (C) 1991, 93, 94, 95, 1999 Free Software Foundation, Inc. |
252b5132 RH |
5 | |
6 | This file is part of GLD, the Gnu Linker. | |
7 | ||
8 | GLD is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 1, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GLD is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GLD; see the file COPYING. If not, write to | |
20 | the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | /* | |
23 | * emulate the Intels port of gld | |
24 | */ | |
25 | ||
26 | ||
27 | #include "bfd.h" | |
28 | #include "sysdep.h" | |
29 | #include "libiberty.h" | |
30 | #include "bfdlink.h" | |
31 | ||
32 | #include "ld.h" | |
33 | #include "ldemul.h" | |
34 | #include "ldfile.h" | |
35 | #include "ldmisc.h" | |
36 | #include "ldmain.h" | |
37 | ||
38 | #ifdef GNU960 | |
39 | ||
40 | static void | |
41 | gld960_before_parse() | |
42 | { | |
43 | static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; | |
44 | char **p; | |
45 | char *env ; | |
46 | ||
47 | for ( p = env_variables; *p; p++ ){ | |
48 | env = (char *) getenv(*p); | |
49 | if (env) { | |
50 | ldfile_add_library_path (concat (env, | |
51 | "/lib/libbout", | |
52 | (const char *) NULL), | |
53 | false); | |
54 | } | |
55 | } | |
56 | ldfile_output_architecture = bfd_arch_i960; | |
57 | } | |
58 | ||
59 | #else /* not GNU960 */ | |
60 | ||
61 | static void gld960_before_parse() | |
62 | { | |
63 | char *env ; | |
64 | env = getenv("G960LIB"); | |
65 | if (env) { | |
66 | ldfile_add_library_path(env, false); | |
67 | } | |
68 | env = getenv("G960BASE"); | |
69 | if (env) | |
70 | ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), false); | |
71 | ldfile_output_architecture = bfd_arch_i960; | |
72 | } | |
73 | ||
74 | #endif /* GNU960 */ | |
75 | ||
76 | ||
77 | static void | |
78 | gld960_set_output_arch() | |
79 | { | |
80 | bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core); | |
81 | } | |
82 | ||
83 | static char * | |
84 | gld960_choose_target() | |
85 | { | |
86 | #ifdef GNU960 | |
87 | ||
88 | output_filename = "b.out"; | |
89 | return bfd_make_targ_name(BFD_BOUT_FORMAT, 0); | |
90 | ||
91 | #else | |
92 | ||
93 | char *from_outside = getenv(TARGET_ENVIRON); | |
94 | output_filename = "b.out"; | |
95 | ||
96 | if (from_outside != (char *)NULL) | |
97 | return from_outside; | |
98 | ||
99 | return "b.out.little"; | |
100 | ||
101 | #endif | |
102 | } | |
103 | ||
104 | static char * | |
105 | gld960_get_script(isfile) | |
106 | int *isfile; | |
107 | EOF | |
108 | ||
109 | if test -n "$COMPILE_IN" | |
110 | then | |
111 | # Scripts compiled in. | |
112 | ||
113 | # sed commands to quote an ld script as a C string. | |
597e2591 | 114 | sc="-f stringify.sed" |
252b5132 RH |
115 | |
116 | cat >>e${EMULATION_NAME}.c <<EOF | |
117 | { | |
118 | *isfile = 0; | |
119 | ||
120 | if (link_info.relocateable == true && config.build_constructors == true) | |
597e2591 | 121 | return |
252b5132 | 122 | EOF |
597e2591 ILT |
123 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
124 | echo ' ; else if (link_info.relocateable == true) return' >> e${EMULATION_NAME}.c | |
125 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c | |
126 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
127 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
128 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c | |
129 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
130 | echo ' ; else return' >> e${EMULATION_NAME}.c | |
131 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
132 | echo '; }' >> e${EMULATION_NAME}.c | |
252b5132 RH |
133 | |
134 | else | |
135 | # Scripts read from the filesystem. | |
136 | ||
137 | cat >>e${EMULATION_NAME}.c <<EOF | |
138 | { | |
139 | *isfile = 1; | |
140 | ||
141 | if (link_info.relocateable == true && config.build_constructors == true) | |
142 | return "ldscripts/${EMULATION_NAME}.xu"; | |
143 | else if (link_info.relocateable == true) | |
144 | return "ldscripts/${EMULATION_NAME}.xr"; | |
145 | else if (!config.text_read_only) | |
146 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
147 | else if (!config.magic_demand_paged) | |
148 | return "ldscripts/${EMULATION_NAME}.xn"; | |
149 | else | |
150 | return "ldscripts/${EMULATION_NAME}.x"; | |
151 | } | |
152 | EOF | |
153 | ||
154 | fi | |
155 | ||
156 | cat >>e${EMULATION_NAME}.c <<EOF | |
157 | ||
158 | struct ld_emulation_xfer_struct ld_gld960_emulation = | |
159 | { | |
160 | gld960_before_parse, | |
161 | syslib_default, | |
162 | hll_default, | |
163 | after_parse_default, | |
164 | after_open_default, | |
165 | after_allocation_default, | |
166 | gld960_set_output_arch, | |
167 | gld960_choose_target, | |
168 | before_allocation_default, | |
169 | gld960_get_script, | |
170 | "960", | |
e1c47aa4 AM |
171 | "", |
172 | NULL, /* finish */ | |
173 | NULL, /* create output section statements */ | |
174 | NULL, /* open dynamic archive */ | |
175 | NULL, /* place orphan */ | |
176 | NULL, /* set symbols */ | |
177 | NULL, /* parse args */ | |
178 | NULL, /* unrecognized file */ | |
179 | NULL, /* list options */ | |
180 | NULL /* recognized file */ | |
252b5132 RH |
181 | }; |
182 | EOF |