OSDN Git Service

* gcc-interface/trans.c (Call_to_gnu): Robustify test for function case
[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 /*  separate_run_path_options is set to 1 when separate "rpath" arguments   */
76 /*  must be passed to the linker for each directory in the rpath.           */
77
78 /*  default_libgcc_subdir is the subdirectory name (from the installation   */
79 /*  root) where we may find a shared libgcc to use by default.              */
80
81 #define SHARED 'H'
82 #define STATIC 'T'
83
84 #if defined (__osf__)
85 const char *__gnat_object_file_option = "-Wl,-input,";
86 const char *__gnat_run_path_option = "-Wl,-rpath,";
87 int __gnat_link_max = 10000;
88 unsigned char __gnat_objlist_file_supported = 1;
89 char __gnat_shared_libgnat_default = STATIC;
90 char __gnat_shared_libgcc_default = STATIC;
91 const char *__gnat_object_library_extension = ".a";
92 unsigned char __gnat_separate_run_path_options = 0;
93 const char *__gnat_default_libgcc_subdir = "lib";
94
95 #elif defined (sgi)
96 const char *__gnat_object_file_option = "-Wl,-objectlist,";
97 const char *__gnat_run_path_option = "-Wl,-rpath,";
98 int __gnat_link_max = 5000;
99 unsigned char __gnat_objlist_file_supported = 1;
100 char __gnat_shared_libgnat_default = STATIC;
101 char __gnat_shared_libgcc_default = STATIC;
102 const char *__gnat_object_library_extension = ".a";
103 unsigned char __gnat_separate_run_path_options = 0;
104
105 /* The libgcc_s locations have changed in GCC 4.  The n32 version used
106    to be in "lib", it moved to "lib32" and "lib" became the home of
107    the o32 version.  We are targetting n32 by default, so ... */
108 #if __GNUC__ < 4
109 const char *__gnat_default_libgcc_subdir = "lib";
110 #else
111 const char *__gnat_default_libgcc_subdir = "lib32";
112 #endif
113
114 #elif defined (__WIN32)
115 const char *__gnat_object_file_option = "-Wl,@";
116 const char *__gnat_run_path_option = "";
117 int __gnat_link_max = 30000;
118 unsigned char __gnat_objlist_file_supported = 1;
119 char __gnat_shared_libgnat_default = STATIC;
120 char __gnat_shared_libgcc_default = STATIC;
121 const char *__gnat_object_library_extension = ".a";
122 unsigned char __gnat_separate_run_path_options = 0;
123 const char *__gnat_default_libgcc_subdir = "lib";
124
125 #elif defined (__hpux__)
126 const char *__gnat_object_file_option = "-Wl,-c,";
127 const char *__gnat_run_path_option = "-Wl,+b,";
128 int __gnat_link_max = 5000;
129 unsigned char __gnat_objlist_file_supported = 1;
130 char __gnat_shared_libgnat_default = STATIC;
131 char __gnat_shared_libgcc_default = STATIC;
132 const char *__gnat_object_library_extension = ".a";
133 unsigned char __gnat_separate_run_path_options = 0;
134 const char *__gnat_default_libgcc_subdir = "lib";
135
136 #elif defined (__FreeBSD__)
137 const char *__gnat_object_file_option = "-Wl,@";
138 const char *__gnat_run_path_option = "-Wl,-rpath,";
139 char __gnat_shared_libgnat_default = STATIC;
140 char __gnat_shared_libgcc_default = STATIC;
141 int __gnat_link_max = 8192;
142 unsigned char __gnat_objlist_file_supported = 1;
143 const char *__gnat_object_library_extension = ".a";
144 unsigned char __gnat_separate_run_path_options = 0;
145 const char *__gnat_default_libgcc_subdir = "lib";
146
147 #elif defined (__APPLE__)
148 const char *__gnat_object_file_option = "-Wl,-filelist,";
149 const char *__gnat_run_path_option = "-Wl,-rpath,";
150 char __gnat_shared_libgnat_default = STATIC;
151 char __gnat_shared_libgcc_default = SHARED;
152 int __gnat_link_max = 262144;
153 unsigned char __gnat_objlist_file_supported = 1;
154 const char *__gnat_object_library_extension = ".a";
155 unsigned char __gnat_separate_run_path_options = 1;
156 const char *__gnat_default_libgcc_subdir = "lib";
157
158 #elif defined (linux) || defined(__GLIBC__)
159 const char *__gnat_object_file_option = "-Wl,@";
160 const char *__gnat_run_path_option = "-Wl,-rpath,";
161 char __gnat_shared_libgnat_default = STATIC;
162 char __gnat_shared_libgcc_default = STATIC;
163 int __gnat_link_max = 8192;
164 unsigned char __gnat_objlist_file_supported = 1;
165 const char *__gnat_object_library_extension = ".a";
166 unsigned char __gnat_separate_run_path_options = 0;
167 #if defined (__x86_64)
168 const char *__gnat_default_libgcc_subdir = "lib64";
169 #else
170 const char *__gnat_default_libgcc_subdir = "lib";
171 #endif
172
173 #elif defined (_AIX)
174 /* On AIX, even when with GNU ld we use native linker switches.  This is
175    particularly important for '-f' as it should be interpreted by collect2.  */
176
177 const char *__gnat_object_file_option = "-Wl,-f,";
178 const char *__gnat_run_path_option = "";
179 char __gnat_shared_libgnat_default = STATIC;
180 char __gnat_shared_libgcc_default = STATIC;
181 int __gnat_link_max = 15000;
182 const unsigned char __gnat_objlist_file_supported = 1;
183 const char *__gnat_object_library_extension = ".a";
184 unsigned char __gnat_separate_run_path_options = 0;
185 const char *__gnat_default_libgcc_subdir = "lib";
186
187 #elif (HAVE_GNU_LD)
188 /*  These are the settings for all systems that use gnu ld. GNU style response
189     file is supported, the shared library default is STATIC.  */
190
191 const char *__gnat_object_file_option = "-Wl,@";
192 const char *__gnat_run_path_option = "";
193 char __gnat_shared_libgnat_default = STATIC;
194 char __gnat_shared_libgcc_default = STATIC;
195 int __gnat_link_max = 8192;
196 unsigned char __gnat_objlist_file_supported = 1;
197 const char *__gnat_object_library_extension = ".a";
198 unsigned char __gnat_separate_run_path_options = 0;
199 const char *__gnat_default_libgcc_subdir = "lib";
200
201 #elif defined (VMS)
202 const char *__gnat_object_file_option = "";
203 const char *__gnat_run_path_option = "";
204 char __gnat_shared_libgnat_default = STATIC;
205 char __gnat_shared_libgcc_default = STATIC;
206 int __gnat_link_max = 2147483647;
207 unsigned char __gnat_objlist_file_supported = 0;
208 const char *__gnat_object_library_extension = ".olb";
209 unsigned char __gnat_separate_run_path_options = 0;
210 const char *__gnat_default_libgcc_subdir = "lib";
211
212 #elif defined (sun)
213 const char *__gnat_object_file_option = "";
214 const char *__gnat_run_path_option = "-Wl,-R";
215 char __gnat_shared_libgnat_default = STATIC;
216 char __gnat_shared_libgcc_default = STATIC;
217 int __gnat_link_max = 2147483647;
218 unsigned char __gnat_objlist_file_supported = 0;
219 const char *__gnat_object_library_extension = ".a";
220 unsigned char __gnat_separate_run_path_options = 0;
221 #if defined (__sparc_v9__) || defined (__sparcv9)
222 const char *__gnat_default_libgcc_subdir = "lib/sparcv9";
223 #elif defined (__x86_64)
224 const char *__gnat_default_libgcc_subdir = "lib/amd64";
225 #else
226 const char *__gnat_default_libgcc_subdir = "lib";
227 #endif
228
229 #elif defined (__svr4__) && defined (i386)
230 const char *__gnat_object_file_option = "";
231 const char *__gnat_run_path_option = "";
232 char __gnat_shared_libgnat_default = STATIC;
233 char __gnat_shared_libgcc_default = STATIC;
234 int __gnat_link_max = 2147483647;
235 unsigned char __gnat_objlist_file_supported = 0;
236 const char *__gnat_object_library_extension = ".a";
237 unsigned char __gnat_separate_run_path_options = 0;
238 const char *__gnat_default_libgcc_subdir = "lib";
239
240 #else
241
242 /*  These are the default settings for all other systems. No response file
243     is supported, the shared library default is STATIC.  */
244 const char *__gnat_run_path_option = "";
245 const char *__gnat_object_file_option = "";
246 char __gnat_shared_libgnat_default = STATIC;
247 char __gnat_shared_libgcc_default = STATIC;
248 int __gnat_link_max = 2147483647;
249 unsigned char __gnat_objlist_file_supported = 0;
250 const char *__gnat_object_library_extension = ".a";
251 unsigned char __gnat_separate_run_path_options = 0;
252 const char *__gnat_default_libgcc_subdir = "lib";
253 #endif
254
255 #ifdef __cplusplus
256 }
257 #endif