Back from Intel with Steve
[deliverable/binutils-gdb.git] / ld / ld-gld.c
1 /* Copyright (C) 1991 Free Software Foundation, Inc.
2
3 This file is part of GLD, the Gnu Linker.
4
5 GLD is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
8 any later version.
9
10 GLD is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GLD; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19 /*
20 * $Id$
21 *
22 * $Log$
23 * Revision 1.1.1.1 1991/03/21 21:28:25 gumby
24 * Back from Intel with Steve
25 *
26 * Revision 1.1 1991/03/21 21:28:24 gumby
27 * Initial revision
28 *
29 * Revision 1.2 1991/03/15 18:45:55 rich
30 * foo
31 *
32 * Revision 1.1 1991/03/13 00:48:11 chrisb
33 * Initial revision
34 *
35 * Revision 1.7 1991/03/10 09:31:18 rich
36 * Modified Files:
37 * Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
38 * ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
39 * ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
40 * ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
41 * ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
42 *
43 * As of this round of changes, ld now builds on all hosts of (Intel960)
44 * interest and copy passes my copy test on big endian hosts again.
45 *
46 * Revision 1.6 1991/03/09 03:23:12 sac
47 * Added -Ur loader script.
48 *
49 * Revision 1.5 1991/03/06 21:59:29 sac
50 * Completed G++ support
51 *
52 * Revision 1.4 1991/03/06 02:23:34 sac
53 * Added support for partial linking.
54 *
55 * Revision 1.3 1991/02/22 17:14:56 sac
56 * Added RCS keywords and copyrights
57 *
58 */
59
60 /*
61 * emulate the original gld
62 *
63 * Written by Steve Chamberlain steve@cygnus.com
64 */
65
66
67 #include "sysdep.h"
68 #include "bfd.h"
69
70
71 #include "ld.h"
72 #include "config.h"
73 #include "ld-emul.h"
74 #include "ldfile.h"
75 #include "ldmisc.h"
76
77 extern boolean lang_float_flag;
78
79
80 extern enum bfd_architecture ldfile_output_architecture;
81 extern unsigned long ldfile_output_machine;
82 extern char *ldfile_output_machine_name;
83
84 extern bfd *output_bfd;
85
86
87
88 static void gld_before_parse()
89 {
90 ldfile_add_library_path("/lib");
91 ldfile_add_library_path("/usr/lib");
92 ldfile_add_library_path("/usr/local/lib/lib");
93 ldfile_output_architecture = bfd_arch_sparc;
94 }
95
96
97 static void
98 gld_after_parse()
99 {
100
101 }
102
103 static void
104 gld_after_allocation()
105 {
106
107 }
108
109 static void
110 gld_before_allocation()
111 {
112
113 }
114
115
116 static void
117 gld_set_output_arch()
118 {
119 /* Set the output architecture and machine if possible */
120 unsigned long machine = 0;
121 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine);
122 }
123
124 static char *
125 gld_choose_target()
126 {
127 char *from_outside = getenv(TARGET_ENVIRON);
128 if (from_outside != (char *)NULL)
129 return from_outside;
130 return GLD_TARGET;
131 }
132
133 static void
134 gld_syslib()
135 {
136 info("%S SYSLIB ignored\n");
137 }
138
139 static void
140 gld_hll(ignore)
141 char *ignore;
142 {
143 info("%S HLL ignored\n");
144 }
145
146 static char *gld_script = " \
147 SEARCH_DIR(/lib) \
148 SEARCH_DIR(/usr/lib) \
149 SEARCH_DIR(/usr/local/lib) \
150 __DYNAMIC = 0; \
151 SECTIONS \
152 { \
153 .text 0x2020 BLOCK(0x2000): \
154 { \
155 CREATE_OBJECT_SYMBOLS \
156 *(.text) \
157 _etext = ALIGN( 0x2000); \
158 } \
159 .data ALIGN(0x2000) : \
160 { \
161 *(.data) \
162 ___DTOR_LIST__=. ; \
163 LONG((___CTOR_LIST__ - .)/4 -2) \
164 *(___DTOR_LIST__) \
165 LONG(0) \
166 ___CTOR_LIST__=. ; \
167 LONG((_edata - .)/4 -2) \
168 *(___CTOR_LIST__) \
169 LONG(0) \
170 _edata = .; \
171 } \
172 .bss SIZEOF(.data) + ADDR(.data) : \
173 { \
174 *(.bss) \
175 [COMMON] \
176 _end=.; \
177 } \
178 }";
179
180
181 static char *gld_script_option_Ur = "\
182 SEARCH_DIR(/lib) \
183 SEARCH_DIR(/usr/lib) \
184 SEARCH_DIR(/usr/local/lib) \
185 SECTIONS \
186 { \
187 .text 0: \
188 { \
189 CREATE_OBJECT_SYMBOLS \
190 *(.text) \
191 } \
192 .data SIZEOF(.text) + ADDR(.text) : \
193 { \
194 *(.data) \
195 ___DTOR_LIST__=. ; \
196 LONG((___CTOR_LIST__ - .)/4 -2) \
197 *(___DTOR_LIST__) \
198 LONG(0) \
199 ___CTOR_LIST__=. ; \
200 LONG((___end_list__ - .)/4 -2) \
201 *(___CTOR_LIST__) \
202 LONG(0) \
203 ___end_list__ = . ; \
204 } \
205 .bss SIZEOF(.data) + ADDR(.data) : \
206 { \
207 *(.bss) \
208 [COMMON] \
209 } \
210 } \
211 ";
212
213 static char *gld_script_option_r = "\
214 SEARCH_DIR(/lib) \
215 SEARCH_DIR(/usr/lib) \
216 SEARCH_DIR(/usr/local/lib) \
217 SECTIONS \
218 { \
219 .text 0: \
220 { \
221 CREATE_OBJECT_SYMBOLS \
222 *(.text) \
223 } \
224 .data SIZEOF(.text) + ADDR(.text) : \
225 { \
226 *(.data) \
227 } \
228 .bss SIZEOF(.data) + ADDR(.data) : \
229 { \
230 *(.bss) \
231 [COMMON] \
232 } \
233 } \
234 ";
235
236 static char *gld_get_script()
237 {
238 extern ld_config_type config;
239 if (config.relocateable_output == true &&
240 config.build_constructors == true) {
241 return gld_script_option_Ur;
242 }
243 if (config.relocateable_output) {
244 return gld_script_option_r;
245 }
246
247 return gld_script;
248 }
249 struct ld_emulation_xfer_struct ld_gld_emulation =
250 {
251 gld_before_parse,
252 gld_syslib,
253 gld_hll,
254 gld_after_parse,
255 gld_after_allocation,
256 gld_set_output_arch,
257 gld_choose_target,
258 gld_before_allocation,
259 gld_get_script,
260 };
261
This page took 0.03391 seconds and 4 git commands to generate.