OSDN Git Service

* gcc-interface/trans.c (lhs_or_actual_p): New predicate.
[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 (__FreeBSD__)
156 const char *__gnat_object_file_option = "";
157 const char *__gnat_run_path_option = "-Wl,-rpath,";
158 char __gnat_shared_libgnat_default = STATIC;
159 char __gnat_shared_libgcc_default = STATIC;
160 int __gnat_link_max = 8192;
161 unsigned char __gnat_objlist_file_supported = 1;
162 unsigned char __gnat_using_gnu_linker = 1;
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 (__APPLE__)
168 const char *__gnat_object_file_option = "-Wl,-filelist,";
169 const char *__gnat_run_path_option = "-Wl,-rpath,";
170 char __gnat_shared_libgnat_default = STATIC;
171 char __gnat_shared_libgcc_default = SHARED;
172 int __gnat_link_max = 262144;
173 unsigned char __gnat_objlist_file_supported = 1;
174 unsigned char __gnat_using_gnu_linker = 0;
175 const char *__gnat_object_library_extension = ".a";
176 unsigned char __gnat_separate_run_path_options = 1;
177 const char *__gnat_default_libgcc_subdir = "lib";
178
179 #elif defined (linux) || defined(__GLIBC__)
180 const char *__gnat_object_file_option = "";
181 const char *__gnat_run_path_option = "-Wl,-rpath,";
182 char __gnat_shared_libgnat_default = STATIC;
183 char __gnat_shared_libgcc_default = STATIC;
184 int __gnat_link_max = 8192;
185 unsigned char __gnat_objlist_file_supported = 1;
186 unsigned char __gnat_using_gnu_linker = 1;
187 const char *__gnat_object_library_extension = ".a";
188 unsigned char __gnat_separate_run_path_options = 0;
189 #if defined (__x86_64)
190 const char *__gnat_default_libgcc_subdir = "lib64";
191 #else
192 const char *__gnat_default_libgcc_subdir = "lib";
193 #endif
194
195 #elif defined (_AIX)
196 /* On AIX, even when with GNU ld we use native linker switches.  This is
197    particularly important for '-f' as it should be interpreted by collect2.  */
198
199 const char *__gnat_object_file_option = "-Wl,-f,";
200 const char *__gnat_run_path_option = "";
201 char __gnat_shared_libgnat_default = STATIC;
202 char __gnat_shared_libgcc_default = STATIC;
203 int __gnat_link_max = 15000;
204 const unsigned char __gnat_objlist_file_supported = 1;
205 unsigned char __gnat_using_gnu_linker = 0;
206 const char *__gnat_object_library_extension = ".a";
207 unsigned char __gnat_separate_run_path_options = 0;
208 const char *__gnat_default_libgcc_subdir = "lib";
209
210 #elif (HAVE_GNU_LD)
211 /*  These are the settings for all systems that use gnu ld. GNU style response
212     file is supported, the shared library default is STATIC.  */
213
214 const char *__gnat_object_file_option = "";
215 const char *__gnat_run_path_option = "";
216 char __gnat_shared_libgnat_default = STATIC;
217 char __gnat_shared_libgcc_default = STATIC;
218 int __gnat_link_max = 8192;
219 unsigned char __gnat_objlist_file_supported = 1;
220 unsigned char __gnat_using_gnu_linker = 1;
221 const char *__gnat_object_library_extension = ".a";
222 unsigned char __gnat_separate_run_path_options = 0;
223 const char *__gnat_default_libgcc_subdir = "lib";
224
225 #elif defined (VMS)
226 const char *__gnat_object_file_option = "";
227 const char *__gnat_run_path_option = "";
228 char __gnat_shared_libgnat_default = STATIC;
229 char __gnat_shared_libgcc_default = STATIC;
230 int __gnat_link_max = 2147483647;
231 unsigned char __gnat_objlist_file_supported = 0;
232 unsigned char __gnat_using_gnu_linker = 0;
233 const char *__gnat_object_library_extension = ".olb";
234 unsigned char __gnat_separate_run_path_options = 0;
235 const char *__gnat_default_libgcc_subdir = "lib";
236
237 #elif defined (sun)
238 const char *__gnat_object_file_option = "";
239 const char *__gnat_run_path_option = "-Wl,-R";
240 char __gnat_shared_libgnat_default = STATIC;
241 char __gnat_shared_libgcc_default = STATIC;
242 int __gnat_link_max = 2147483647;
243 unsigned char __gnat_objlist_file_supported = 0;
244 unsigned char __gnat_using_gnu_linker = 0;
245 const char *__gnat_object_library_extension = ".a";
246 unsigned char __gnat_separate_run_path_options = 0;
247 #if defined (__sparc_v9__) || defined (__sparcv9)
248 const char *__gnat_default_libgcc_subdir = "lib/sparcv9";
249 #elif defined (__x86_64)
250 const char *__gnat_default_libgcc_subdir = "lib/amd64";
251 #else
252 const char *__gnat_default_libgcc_subdir = "lib";
253 #endif
254
255 #elif defined (__svr4__) && defined (i386)
256 const char *__gnat_object_file_option = "";
257 const char *__gnat_run_path_option = "";
258 char __gnat_shared_libgnat_default = STATIC;
259 char __gnat_shared_libgcc_default = STATIC;
260 int __gnat_link_max = 2147483647;
261 unsigned char __gnat_objlist_file_supported = 0;
262 unsigned char __gnat_using_gnu_linker = 0;
263 const char *__gnat_object_library_extension = ".a";
264 unsigned char __gnat_separate_run_path_options = 0;
265 const char *__gnat_default_libgcc_subdir = "lib";
266
267 #else
268
269 /*  These are the default settings for all other systems. No response file
270     is supported, the shared library default is STATIC.  */
271 const char *__gnat_run_path_option = "";
272 const char *__gnat_object_file_option = "";
273 char __gnat_shared_libgnat_default = STATIC;
274 char __gnat_shared_libgcc_default = STATIC;
275 int __gnat_link_max = 2147483647;
276 unsigned char __gnat_objlist_file_supported = 0;
277 unsigned char __gnat_using_gnu_linker = 0;
278 const char *__gnat_object_library_extension = ".a";
279 unsigned char __gnat_separate_run_path_options = 0;
280 const char *__gnat_default_libgcc_subdir = "lib";
281 #endif
282
283 #ifdef __cplusplus
284 }
285 #endif