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 RH |
28 | #include "libiberty.h" |
29 | #include "bfdlink.h" | |
30 | ||
31 | #include "ld.h" | |
252b5132 RH |
32 | #include "ldmisc.h" |
33 | #include "ldmain.h" | |
34 | ||
b71e2778 AM |
35 | #include "ldexp.h" |
36 | #include "ldlang.h" | |
37 | #include "ldfile.h" | |
38 | #include "ldemul.h" | |
39 | ||
0c7a8e5a | 40 | static void gld960_before_parse (void) |
252b5132 RH |
41 | { |
42 | char *env ; | |
43 | env = getenv("G960LIB"); | |
44 | if (env) { | |
b34976b6 | 45 | ldfile_add_library_path(env, FALSE); |
252b5132 RH |
46 | } |
47 | env = getenv("G960BASE"); | |
48 | if (env) | |
b34976b6 | 49 | ldfile_add_library_path (concat (env, "/lib", (const char *) NULL), FALSE); |
252b5132 RH |
50 | ldfile_output_architecture = bfd_arch_i960; |
51 | } | |
52 | ||
252b5132 | 53 | static void |
0c7a8e5a | 54 | gld960_set_output_arch (void) |
252b5132 | 55 | { |
f13a99db AM |
56 | bfd_set_arch_mach (link_info.output_bfd, |
57 | ldfile_output_architecture, bfd_mach_i960_core); | |
252b5132 RH |
58 | } |
59 | ||
60 | static char * | |
0c7a8e5a | 61 | gld960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) |
252b5132 | 62 | { |
252b5132 RH |
63 | char *from_outside = getenv(TARGET_ENVIRON); |
64 | output_filename = "b.out"; | |
65 | ||
66 | if (from_outside != (char *)NULL) | |
67 | return from_outside; | |
68 | ||
69 | return "b.out.little"; | |
252b5132 RH |
70 | } |
71 | ||
72 | static char * | |
0c7a8e5a | 73 | gld960_get_script (int *isfile) |
252b5132 RH |
74 | EOF |
75 | ||
7225345d | 76 | if test x"$COMPILE_IN" = xyes |
252b5132 RH |
77 | then |
78 | # Scripts compiled in. | |
79 | ||
80 | # sed commands to quote an ld script as a C string. | |
597e2591 | 81 | sc="-f stringify.sed" |
252b5132 | 82 | |
92b93329 | 83 | fragment <<EOF |
0c7a8e5a | 84 | { |
252b5132 RH |
85 | *isfile = 0; |
86 | ||
0e1862bb | 87 | if (bfd_link_relocatable (&link_info) && config.build_constructors) |
597e2591 | 88 | return |
252b5132 | 89 | EOF |
b34976b6 | 90 | sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c |
0e1862bb | 91 | echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c |
b34976b6 AM |
92 | sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c |
93 | echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c | |
94 | sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c | |
95 | echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c | |
96 | sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c | |
97 | echo ' ; else return' >> e${EMULATION_NAME}.c | |
98 | sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c | |
99 | echo '; }' >> e${EMULATION_NAME}.c | |
252b5132 RH |
100 | |
101 | else | |
102 | # Scripts read from the filesystem. | |
103 | ||
92b93329 | 104 | fragment <<EOF |
0c7a8e5a | 105 | { |
252b5132 RH |
106 | *isfile = 1; |
107 | ||
0e1862bb | 108 | if (bfd_link_relocatable (&link_info) && config.build_constructors) |
252b5132 | 109 | return "ldscripts/${EMULATION_NAME}.xu"; |
0e1862bb | 110 | else if (bfd_link_relocatable (&link_info)) |
252b5132 RH |
111 | return "ldscripts/${EMULATION_NAME}.xr"; |
112 | else if (!config.text_read_only) | |
113 | return "ldscripts/${EMULATION_NAME}.xbn"; | |
114 | else if (!config.magic_demand_paged) | |
115 | return "ldscripts/${EMULATION_NAME}.xn"; | |
116 | else | |
117 | return "ldscripts/${EMULATION_NAME}.x"; | |
118 | } | |
119 | EOF | |
120 | ||
121 | fi | |
122 | ||
92b93329 | 123 | fragment <<EOF |
252b5132 | 124 | |
0c7a8e5a | 125 | struct ld_emulation_xfer_struct ld_gld960_emulation = |
252b5132 RH |
126 | { |
127 | gld960_before_parse, | |
128 | syslib_default, | |
129 | hll_default, | |
130 | after_parse_default, | |
131 | after_open_default, | |
132 | after_allocation_default, | |
133 | gld960_set_output_arch, | |
134 | gld960_choose_target, | |
135 | before_allocation_default, | |
136 | gld960_get_script, | |
137 | "960", | |
e1c47aa4 | 138 | "", |
1e035701 | 139 | finish_default, |
e1c47aa4 AM |
140 | NULL, /* create output section statements */ |
141 | NULL, /* open dynamic archive */ | |
142 | NULL, /* place orphan */ | |
143 | NULL, /* set symbols */ | |
144 | NULL, /* parse args */ | |
3bcf5557 AM |
145 | NULL, /* add_options */ |
146 | NULL, /* handle_option */ | |
e1c47aa4 AM |
147 | NULL, /* unrecognized file */ |
148 | NULL, /* list options */ | |
40d109bf | 149 | NULL, /* recognized file */ |
fac1652d | 150 | NULL, /* find_potential_libraries */ |
7a2f2d82 DD |
151 | NULL, /* new_vers_pattern */ |
152 | NULL /* extra_map_file_text */ | |
252b5132 RH |
153 | }; |
154 | EOF |