OSDN Git Service

2011-08-05 Hristian Kirtchev <kirtchev@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / link.c
1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                                 L I N K                                  *
6  *                                                                          *
7  *                          C Implementation File                           *
8  *                                                                          *
9  *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
10  *                                                                          *
11  * GNAT is free software;  you can  redistribute it  and/or modify it under *
12  * terms of the  GNU General Public License as published  by the Free Soft- *
13  * ware  Foundation;  either version 3,  or (at your option) any later ver- *
14  * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
15  * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
16  * or FITNESS FOR A PARTICULAR PURPOSE.                                     *
17  *                                                                          *
18  * As a special exception under Section 7 of GPL version 3, you are granted *
19  * additional permissions described in the GCC Runtime Library Exception,   *
20  * version 3.1, as published by the Free Software Foundation.               *
21  *                                                                          *
22  * You should have received a copy of the GNU General Public License and    *
23  * a copy of the GCC Runtime Library Exception along with this program;     *
24  * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    *
25  * <http://www.gnu.org/licenses/>.                                          *
26  *                                                                          *
27  * GNAT was originally developed  by the GNAT team at  New York University. *
28  * Extensive contributions were provided by Ada Core Technologies Inc.      *
29  *                                                                          *
30  ****************************************************************************/
31
32 /*  This file contains host-specific parameters describing the behavior of the
33     linker.  It is used by gnatlink as well as all tools that use Mlib.  */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #ifdef IN_GCC
40 #include "auto-host.h"
41 #endif
42
43 #include <string.h>
44
45 /*  objlist_file_supported is set to 1 when the system linker allows        */
46 /*  response file, that is a file that contains the list of object files.   */
47 /*  This is useful on systems where the command line length is limited,     */
48 /*  meaning that putting all the object files on the command line can       */
49 /*  result in an unacceptable limit on the number of files.                 */
50
51 /*  object_file_option denotes the system dependent linker option which     */
52 /*  allows object file names to be placed in a file and then passed to      */
53 /*  the linker. object_file_option must be set if objlist_file_supported    */
54 /*  is set to 1.                                                            */
55
56 /*  link_max is a conservative system specific threshold (in bytes) of the  */
57 /*  argument length passed to the linker which will trigger a file being    */
58 /*  used instead of the command line directly. If the argument length is    */
59 /*  greater than this threshold, then an objlist_file will be generated     */
60 /*  and object_file_option and objlist_file_supported must be set. If       */
61 /*  objlist_file_supported is set to 0 (unsupported), then link_max is      */
62 /*  set to 2**31-1 so that the limit will never be exceeded.                */
63
64 /*  run_path_option is the system dependent linker option which specifies   */
65 /*  the run time path to use when loading dynamic libraries. This should    */
66 /*  be set to the null string if the system does not support dynamic        */
67 /*  loading of libraries.                                                   */
68
69 /*  shared_libgnat_default gives the system dependent link method that      */
70 /*  be used by default for linking libgnat (shared or static)               */
71
72 /*  shared_libgcc_default gives the system dependent link method that       */
73 /*  be used by default for linking libgcc (shared or static)                */
74
75 /*  using_gnu_linker is set to 1 when the GNU linker is used under this     */
76 /*  target.                                                                 */
77
78 /*  separate_run_path_options is set to 1 when separate "rpath" arguments   */
79 /*  must be passed to the linker for each directory in the rpath.           */
80
81 /*  default_libgcc_subdir is the subdirectory name (from the installation   */
82 /*  root) where we may find a shared libgcc to use by default.              */
83
84 /*  RESPONSE FILE & GNU LINKER                                              */
85 /*  --------------------------                                              */
86 /*  objlist_file_supported and using_gnu_link used together tell gnatlink   */
87 /*  to generate a GNU style response file. Note that object_file_option     */
88 /*  must be set to "" in this case, since no option is required for a       */
89 /*  response file to be passed to GNU ld. With a GNU linker we use the      */
90 /*  linker script to implement the response file feature. Any file passed   */
91 /*  in the GNU ld command line with an unknown extension is supposed to be  */
92 /*  a linker script. Each linker script augment the current configuration.  */
93 /*  The format of such response file is as follow :                         */
94 /*  INPUT (obj1.p obj2.o ...)                                               */
95
96 #define SHARED 'H'
97 #define STATIC 'T'
98
99 #if defined (__osf__)
100 const char *__gnat_object_file_option = "-Wl,-input,";
101 const char *__gnat_run_path_option = "-Wl,-rpath,";
102 int __gnat_link_max = 10000;
103 unsigned char __gnat_objlist_file_supported = 1;
104 char __gnat_shared_libgnat_default = STATIC;
105 char __gnat_shared_libgcc_default = STATIC;
106 unsigned char __gnat_using_gnu_linker = 0;
107 const char *__gnat_object_library_extension = ".a";
108 unsigned char __gnat_separate_run_path_options = 0;
109 const char *__gnat_default_libgcc_subdir = "lib";
110
111 #elif defined (sgi)
112 const char *__gnat_object_file_option = "-Wl,-objectlist,";
113 const char *__gnat_run_path_option = "-Wl,-rpath,";
114 int __gnat_link_max = 5000;
115 unsigned char __gnat_objlist_file_supported = 1;
116 char __gnat_shared_libgnat_default = STATIC;
117 char __gnat_shared_libgcc_default = STATIC;
118 unsigned char __gnat_using_gnu_linker = 0;
119 const char *__gnat_object_library_extension = ".a";
120 unsigned char __gnat_separate_run_path_options = 0;
121
122 /* The libgcc_s locations have changed in GCC 4.  The n32 version used
123    to be in "lib", it moved to "lib32" and "lib" became the home of
124    the o32 version.  We are targetting n32 by default, so ... */
125 #if __GNUC__ < 4
126 const char *__gnat_default_libgcc_subdir = "lib";
127 #else
128 const char *__gnat_default_libgcc_subdir = "lib32";
129 #endif
130
131 #elif defined (__WIN32)
132 const char *__gnat_object_file_option = "";
133 const char *__gnat_run_path_option = "";
134 int __gnat_link_max = 30000;
135 unsigned char __gnat_objlist_file_supported = 1;
136 char __gnat_shared_libgnat_default = STATIC;
137 char __gnat_shared_libgcc_default = STATIC;
138 unsigned char __gnat_using_gnu_linker = 1;
139 const char *__gnat_object_library_extension = ".a";
140 unsigned char __gnat_separate_run_path_options = 0;
141 const char *__gnat_default_libgcc_subdir = "lib";
142
143 #elif defined (__hpux__)
144 const char *__gnat_object_file_option = "-Wl,-c,";
145 const char *__gnat_run_path_option = "-Wl,+b,";
146 int __gnat_link_max = 5000;
147 unsigned char __gnat_objlist_file_supported = 1;
148 char __gnat_shared_libgnat_default = STATIC;
149 char __gnat_shared_libgcc_default = STATIC;
150 unsigned char __gnat_using_gnu_linker = 0;
151 const char *__gnat_object_library_extension = ".a";
152 unsigned char __gnat_separate_run_path_options = 0;
153 const char *__gnat_default_libgcc_subdir = "lib";
154
155 #elif defined (_AIX)
156 const char *__gnat_object_file_option = "-Wl,-f,";
157 const char *__gnat_run_path_option = "";
158 int __gnat_link_max = 15000;
159 const unsigned char __gnat_objlist_file_supported = 1;
160 char __gnat_shared_libgnat_default = STATIC;
161 char __gnat_shared_libgcc_default = STATIC;
162 unsigned char __gnat_using_gnu_linker = 0;
163 const char *__gnat_object_library_extension = ".a";
164 unsigned char __gnat_separate_run_path_options = 0;
165 const char *__gnat_default_libgcc_subdir = "lib";
166
167 #elif defined (__FreeBSD__)
168 const char *__gnat_object_file_option = "";
169 const char *__gnat_run_path_option = "-Wl,-rpath,";
170 char __gnat_shared_libgnat_default = STATIC;
171 char __gnat_shared_libgcc_default = STATIC;
172 int __gnat_link_max = 8192;
173 unsigned char __gnat_objlist_file_supported = 1;
174 unsigned char __gnat_using_gnu_linker = 1;
175 const char *__gnat_object_library_extension = ".a";
176 unsigned char __gnat_separate_run_path_options = 0;
177 const char *__gnat_default_libgcc_subdir = "lib";
178
179 #elif defined (__APPLE__)
180 const char *__gnat_object_file_option = "-Wl,-filelist,";
181 const char *__gnat_run_path_option = "-Wl,-rpath,";
182 char __gnat_shared_libgnat_default = STATIC;
183 char __gnat_shared_libgcc_default = SHARED;
184 int __gnat_link_max = 262144;
185 unsigned char __gnat_objlist_file_supported = 1;
186 unsigned char __gnat_using_gnu_linker = 0;
187 const char *__gnat_object_library_extension = ".a";
188 unsigned char __gnat_separate_run_path_options = 1;
189 const char *__gnat_default_libgcc_subdir = "lib";
190
191 #elif defined (linux) || defined(__GLIBC__)
192 const char *__gnat_object_file_option = "";
193 const char *__gnat_run_path_option = "-Wl,-rpath,";
194 char __gnat_shared_libgnat_default = STATIC;
195 char __gnat_shared_libgcc_default = STATIC;
196 int __gnat_link_max = 8192;
197 unsigned char __gnat_objlist_file_supported = 1;
198 unsigned char __gnat_using_gnu_linker = 1;
199 const char *__gnat_object_library_extension = ".a";
200 unsigned char __gnat_separate_run_path_options = 0;
201 #if defined (__x86_64)
202 const char *__gnat_default_libgcc_subdir = "lib64";
203 #else
204 const char *__gnat_default_libgcc_subdir = "lib";
205 #endif
206
207 #elif (HAVE_GNU_LD)
208 /*  These are the settings for all systems that use gnu ld. GNU style response
209     file is supported, the shared library default is STATIC.  */
210
211 const char *__gnat_run_path_option = "";
212 const char *__gnat_object_file_option = "";
213 char __gnat_shared_libgnat_default = STATIC;
214 char __gnat_shared_libgcc_default = STATIC;
215 int __gnat_link_max = 8192;
216 unsigned char __gnat_objlist_file_supported = 1;
217 unsigned char __gnat_using_gnu_linker = 1;
218 const char *__gnat_object_library_extension = ".a";
219 unsigned char __gnat_separate_run_path_options = 0;
220 const char *__gnat_default_libgcc_subdir = "lib";
221
222 #elif defined (VMS)
223 const char *__gnat_object_file_option = "";
224 const char *__gnat_run_path_option = "";
225 char __gnat_shared_libgnat_default = STATIC;
226 char __gnat_shared_libgcc_default = STATIC;
227 int __gnat_link_max = 2147483647;
228 unsigned char __gnat_objlist_file_supported = 0;
229 unsigned char __gnat_using_gnu_linker = 0;
230 const char *__gnat_object_library_extension = ".olb";
231 unsigned char __gnat_separate_run_path_options = 0;
232 const char *__gnat_default_libgcc_subdir = "lib";
233
234 #elif defined (sun)
235 const char *__gnat_object_file_option = "";
236 const char *__gnat_run_path_option = "-Wl,-R";
237 char __gnat_shared_libgnat_default = STATIC;
238 char __gnat_shared_libgcc_default = STATIC;
239 int __gnat_link_max = 2147483647;
240 unsigned char __gnat_objlist_file_supported = 0;
241 unsigned char __gnat_using_gnu_linker = 0;
242 const char *__gnat_object_library_extension = ".a";
243 unsigned char __gnat_separate_run_path_options = 0;
244 #if defined (__sparc_v9__) || defined (__sparcv9)
245 const char *__gnat_default_libgcc_subdir = "lib/sparcv9";
246 #elif defined (__x86_64)
247 const char *__gnat_default_libgcc_subdir = "lib/amd64";
248 #else
249 const char *__gnat_default_libgcc_subdir = "lib";
250 #endif
251
252 #elif defined (__svr4__) && defined (i386)
253 const char *__gnat_object_file_option = "";
254 const char *__gnat_run_path_option = "";
255 char __gnat_shared_libgnat_default = STATIC;
256 char __gnat_shared_libgcc_default = STATIC;
257 int __gnat_link_max = 2147483647;
258 unsigned char __gnat_objlist_file_supported = 0;
259 unsigned char __gnat_using_gnu_linker = 0;
260 const char *__gnat_object_library_extension = ".a";
261 unsigned char __gnat_separate_run_path_options = 0;
262 const char *__gnat_default_libgcc_subdir = "lib";
263
264 #else
265
266 /*  These are the default settings for all other systems. No response file
267     is supported, the shared library default is STATIC.  */
268 const char *__gnat_run_path_option = "";
269 const char *__gnat_object_file_option = "";
270 char __gnat_shared_libgnat_default = STATIC;
271 char __gnat_shared_libgcc_default = STATIC;
272 int __gnat_link_max = 2147483647;
273 unsigned char __gnat_objlist_file_supported = 0;
274 unsigned char __gnat_using_gnu_linker = 0;
275 const char *__gnat_object_library_extension = ".a";
276 unsigned char __gnat_separate_run_path_options = 0;
277 const char *__gnat_default_libgcc_subdir = "lib";
278 #endif
279
280 #ifdef __cplusplus
281 }
282 #endif