Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # This shell script emits a C file. -*- C -*- |
2 | # It does some substitutions. | |
92b93329 | 3 | fragment <<EOF |
b90efa5b | 4 | /* Copyright (C) 1991-2015 Free Software Foundation, Inc. |
252b5132 | 5 | |
f96b4a7b | 6 | This file is part of the GNU Binutils. |
252b5132 | 7 | |
f96b4a7b NC |
8 | This program 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 3 of the License, or | |
11 | (at your option) any later version. | |
252b5132 | 12 | |
f96b4a7b NC |
13 | This program 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. | |
252b5132 | 17 | |
f96b4a7b NC |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
21 | MA 02110-1301, USA. */ | |
252b5132 | 22 | |
252b5132 | 23 | |
f96b4a7b | 24 | /* Emulate the Intel's port of gld. */ |
252b5132 | 25 | |
252b5132 | 26 | #include "sysdep.h" |
3db64b00 | 27 | #include "bfd.h" |
252b5132 | 28 | #include "libiberty.h" |
3882b010 | 29 | #include "safe-ctype.h" |
252b5132 RH |
30 | #include "bfdlink.h" |
31 | ||
32 | #include "ld.h" | |
252b5132 RH |
33 | #include "ldmisc.h" |
34 | #include "ldmain.h" | |
35 | ||
b71e2778 AM |
36 | #include "ldexp.h" |
37 | #include "ldlang.h" | |
38 | #include "ldfile.h" | |
39 | #include "ldemul.h" | |
40 | ||
0c7a8e5a | 41 | static void gld960_before_parse (void) |
252b5132 RH |
42 | { |
43 | char *env ; | |
44 | env = getenv("G960LIB"); | |
45 | if (env) { | |
b34976b6 | 46 | ldfile_add_library_path(env, FALSE); |
252b5132 RH |
47 | } |
48 | env = getenv("G960BASE"); | |
49 | if (env) | |
50 | ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), | |
b34976b6 | 51 | FALSE); |
252b5132 RH |
52 | ldfile_output_architecture = bfd_arch_i960; |
53 | } | |
54 | ||
252b5132 | 55 | static void |
0c7a8e5a | 56 | gld960_set_output_arch (void) |
252b5132 RH |
57 | { |
58 | if (ldfile_output_machine_name != NULL | |
59 | && *ldfile_output_machine_name != '\0') | |
60 | { | |
61 | char *s, *s1; | |
62 | ||
63 | s = concat ("i960:", ldfile_output_machine_name, (char *) NULL); | |
64 | for (s1 = s; *s1 != '\0'; s1++) | |
3882b010 | 65 | *s1 = TOLOWER (*s1); |
5e2f1575 | 66 | ldfile_set_output_arch (s, bfd_arch_unknown); |
252b5132 RH |
67 | free (s); |
68 | } | |
69 | ||
70 | set_output_arch_default (); | |
71 | } | |
72 | ||
73 | static char * | |
0c7a8e5a | 74 | gld960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) |
252b5132 | 75 | { |
252b5132 RH |
76 | char *from_outside = getenv(TARGET_ENVIRON); |
77 | output_filename = "b.out"; | |
78 | ||
79 | if (from_outside != (char *)NULL) | |
80 | return from_outside; | |
81 | ||
82 | return "coff-Intel-little"; | |
252b5132 RH |
83 | } |
84 | ||
85 | static char * | |
0c7a8e5a | 86 | gld960_get_script (int *isfile) |
252b5132 RH |
87 | EOF |
88 | ||
7225345d | 89 | if test x"$COMPILE_IN" = xyes |
252b5132 RH |
90 | then |
91 | # Scripts compiled in. | |
92 | ||
93 | # sed commands to quote an ld script as a C string. | |
597e2591 | 94 | sc="-f stringify.sed" |
252b5132 | 95 | |
92b93329 | 96 | fragment <<EOF |
5e2f1575 | 97 | { |
252b5132 RH |
98 | *isfile = 0; |
99 | ||
1049f94e | 100 | if (link_info.relocatable && config.build_constructors) |
597e2591 | 101 | return |
252b5132 | 102 | EOF |
b34976b6 | 103 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
1049f94e | 104 | echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c |
b34976b6 AM |
105 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c |
106 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
107 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
108 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c | |
109 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
110 | echo ' ; else return' >> e${EMULATION_NAME}.c | |
111 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
112 | echo '; }' >> e${EMULATION_NAME}.c | |
252b5132 RH |
113 | |
114 | else | |
115 | # Scripts read from the filesystem. | |
116 | ||
92b93329 | 117 | fragment <<EOF |
5e2f1575 | 118 | { |
252b5132 RH |
119 | *isfile = 1; |
120 | ||
1049f94e | 121 | if (link_info.relocatable && config.build_constructors) |
252b5132 | 122 | return "ldscripts/${EMULATION_NAME}.xu"; |
1049f94e | 123 | else if (link_info.relocatable) |
252b5132 RH |
124 | return "ldscripts/${EMULATION_NAME}.xr"; |
125 | else if (!config.text_read_only) | |
126 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
127 | else if (!config.magic_demand_paged) | |
128 | return "ldscripts/${EMULATION_NAME}.xn"; | |
129 | else | |
130 | return "ldscripts/${EMULATION_NAME}.x"; | |
131 | } | |
132 | EOF | |
133 | ||
134 | fi | |
135 | ||
92b93329 | 136 | fragment <<EOF |
252b5132 | 137 | |
5e2f1575 | 138 | struct ld_emulation_xfer_struct ld_gld960coff_emulation = |
252b5132 RH |
139 | { |
140 | gld960_before_parse, | |
141 | syslib_default, | |
142 | hll_default, | |
143 | after_parse_default, | |
144 | after_open_default, | |
145 | after_allocation_default, | |
146 | gld960_set_output_arch, | |
147 | gld960_choose_target, | |
148 | before_allocation_default, | |
149 | gld960_get_script, | |
150 | "960coff", | |
e1c47aa4 | 151 | "", |
1e035701 | 152 | finish_default, |
e1c47aa4 AM |
153 | NULL, /* create output section statements */ |
154 | NULL, /* open dynamic archive */ | |
155 | NULL, /* place orphan */ | |
156 | NULL, /* set symbols */ | |
157 | NULL, /* parse args */ | |
3bcf5557 AM |
158 | NULL, /* add_options */ |
159 | NULL, /* handle_option */ | |
e1c47aa4 AM |
160 | NULL, /* unrecognized file */ |
161 | NULL, /* list options */ | |
40d109bf | 162 | NULL, /* recognized file */ |
fac1652d | 163 | NULL, /* find_potential_libraries */ |
7a2f2d82 DD |
164 | NULL, /* new_vers_pattern */ |
165 | NULL /* extra_map_file_text */ | |
252b5132 RH |
166 | }; |
167 | EOF |