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