Initial revision
[binutils-gdb.git] / ld / ldtemplate
1 /* NOTE: If there are angle brackets here: <TARGET> then this is a
2 * template file (ldtemplate), intended for processing by sed.
3 * Otherwise, this file has already been processed by sed,
4 * and customized for a particular emulation target.
5 * In that DO NOT EDIT the file; edit ldtemplate instead.
6 */
7
8 /* Copyright (C) 1991 Free Software Foundation, Inc.
9
10 This file is part of GLD, the Gnu Linker.
11
12 GLD is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 1, or (at your option)
15 any later version.
16
17 GLD is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with GLD; see the file COPYING. If not, write to
24 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25
26 /*
27 * $Id:#
28 */
29
30 /*
31 * emulate the original gld for the given <TARGET>
32 *
33 * Written by Steve Chamberlain steve@cygnus.com
34 */
35
36 #define TARGET_IS_<TARGET>
37
38 #include "sysdep.h"
39 #include "bfd.h"
40
41 #include "ld.h"
42 #include "config.h"
43 #include "ldemul.h"
44 #include "ldfile.h"
45 #include "ldmisc.h"
46
47 extern boolean lang_float_flag;
48
49
50 extern enum bfd_architecture ldfile_output_architecture;
51 extern unsigned long ldfile_output_machine;
52 extern char *ldfile_output_machine_name;
53
54 extern bfd *output_bfd;
55
56
57
58 static void gld<target>_before_parse()
59 {
60 #ifdef TARGET_IS_M88KBCS
61 extern char lprefix;
62 lprefix = '@';
63 #else
64 ldfile_add_library_path("/lib");
65 ldfile_add_library_path("/usr/lib");
66 ldfile_add_library_path("/usr/local/lib");
67 #ifndef TARGET_ /* I.e., if not generic */
68 ldfile_output_architecture = bfd_arch_<arch>;
69 #endif
70 #endif
71 }
72
73
74 static void
75 gld<target>_after_parse()
76 {
77
78 }
79
80 static void
81 gld<target>_after_allocation()
82 {
83
84 }
85
86 static void
87 gld<target>_before_allocation()
88 {
89
90 }
91
92
93 static void
94 gld<target>_set_output_arch()
95 {
96 /* Set the output architecture and machine if possible */
97 bfd_set_arch_mach(output_bfd,
98 ldfile_output_architecture, ldfile_output_machine);
99 }
100
101 static char *
102 gld<target>_choose_target()
103 {
104 char *from_outside = getenv(TARGET_ENVIRON);
105 if (from_outside != (char *)NULL)
106 return from_outside;
107 return GLD<TARGET>_TARGET;
108 }
109
110 static void
111 gld<target>_syslib()
112 {
113 info("%S SYSLIB ignored\n");
114 }
115
116 static void
117 gld<target>_hll(ignore)
118 char *ignore;
119 {
120 info("%S HLL ignored\n");
121 }
122
123 static char *gld<target>_script =
124 #include "<ldtarget>.x"
125 ;
126 static char *gld<target>_script_option_Ur =
127 #include "<ldtarget>.xu"
128 ;
129 static char *gld<target>_script_option_r =
130 #include "<ldtarget>.xr"
131 ;
132
133 static char *gld<target>_get_script()
134 {
135 extern ld_config_type config;
136 if (config.relocateable_output == true &&
137 config.build_constructors == true) {
138 return gld<target>_script_option_Ur;
139 }
140 if (config.relocateable_output) {
141 return gld<target>_script_option_r;
142 }
143
144 return gld<target>_script;
145 }
146 struct ld_emulation_xfer_struct ld_gld<target>_emulation =
147 {
148 gld<target>_before_parse,
149 gld<target>_syslib,
150 gld<target>_hll,
151 gld<target>_after_parse,
152 gld<target>_after_allocation,
153 gld<target>_set_output_arch,
154 gld<target>_choose_target,
155 gld<target>_before_allocation,
156 gld<target>_get_script,
157 };