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