OSDN Git Service

* prefix.h: Wrap up in extern "C" block.
[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 #include <string.h>
40
41 /*  objlist_file_supported is set to 1 when the system linker allows        */
42 /*  response file, that is a file that contains the list of object files.   */
43 /*  This is useful on systems where the command line length is limited,     */
44 /*  meaning that putting all the object files on the command line can       */
45 /*  result in an unacceptable limit on the number of files.                 */
46
47 /*  object_file_option denotes the system dependent linker option which     */
48 /*  allows object file names to be placed in a file and then passed to      */
49 /*  the linker. object_file_option must be set if objlist_file_supported    */
50 /*  is set to 1.                                                            */
51
52 /*  link_max is a conservative system specific threshold (in bytes) of the  */
53 /*  argument length passed to the linker which will trigger a file being    */
54 /*  used instead of the command line directly. If the argument length is    */
55 /*  greater than this threshold, then an objlist_file will be generated     */
56 /*  and object_file_option and objlist_file_supported must be set. If       */
57 /*  objlist_file_supported is set to 0 (unsupported), then link_max is      */
58 /*  set to 2**31-1 so that the limit will never be exceeded.                */
59
60 /*  run_path_option is the system dependent linker option which specifies   */
61 /*  the run time path to use when loading dynamic libraries. This should    */
62 /*  be set to the null string if the system does not support dynamic        */
63 /*  loading of libraries.                                                   */
64
65 /*  shared_libgnat_default gives the system dependent link method that      */
66 /*  be used by default for linking libgnat (shared or static)               */
67
68 /*  shared_libgcc_default gives the system dependent link method that       */
69 /*  be used by default for linking libgcc (shared or static)                */
70
71 /*  using_gnu_linker is set to 1 when the GNU linker is used under this     */
72 /*  target.                                                                 */
73
74 /*  separate_run_path_options is set to 1 when separate "rpath" arguments   */
75 /*  must be passed to the linker for each directory in the rpath.           */
76
77 /*  default_libgcc_subdir is the subdirectory name (from the installation   */
78 /*  root) where we may find a shared libgcc to use by default.              */
79
80 /*  RESPONSE FILE & GNU LINKER                                              */
81 /*  --------------------------                                              */
82 /*  objlist_file_supported and using_gnu_link used together tell gnatlink   */
83 /*  to generate a GNU style response file. Note that object_file_option     */
84 /*  must be set to "" in this case, since no option is required for a       */
85 /*  response file to be passed to GNU ld. With a GNU linker we use the      */
86 /*  linker script to implement the response file feature. Any file passed   */
87 /*  in the GNU ld command line with an unknown extension is supposed to be  */
88 /*  a linker script. Each linker script augment the current configuration.  */
89 /*  The format of such response file is as follow :                         */
90 /*  INPUT (obj1.p obj2.o ...)                                               */
91
92 #define SHARED 'H'
93 #define STATIC 'T'
94
95 #if defined (__osf__)
96 const char *__gnat_object_file_option = "-Wl,-input,";
97 const char *__gnat_run_path_option = "-Wl,-rpath,";
98 int __gnat_link_max = 10000;
99 unsigned char __gnat_objlist_file_supported = 1;
100 char __gnat_shared_libgnat_default = STATIC;
101 char __gnat_shared_libgcc_default = STATIC;
102 unsigned char __gnat_using_gnu_linker = 0;
103 const char *__gnat_object_library_extension = ".a";
104 unsigned char __gnat_separate_run_path_options = 0;
105 const char *__gnat_default_libgcc_subdir = "lib";
106
107 #elif defined (sgi)
108 const char *__gnat_object_file_option = "-Wl,-objectlist,";
109 const char *__gnat_run_path_option = "-Wl,-rpath,";
110 int __gnat_link_max = 5000;
111 unsigned char __gnat_objlist_file_supported = 1;
112 char __gnat_shared_libgnat_default = STATIC;
113 char __gnat_shared_libgcc_default = STATIC;
114 unsigned char __gnat_using_gnu_linker = 0;
115 const char *__gnat_object_library_extension = ".a";
116 unsigned char __gnat_separate_run_path_options = 0;
117
118 /* The libgcc_s locations have changed in GCC 4.  The n32 version used
119    to be in "lib", it moved to "lib32" and "lib" became the home of
120    the o32 version.  We are targetting n32 by default, so ... */
121 #if __GNUC__ < 4
122 const char *__gnat_default_libgcc_subdir = "lib";
123 #else
124 const char *__gnat_default_libgcc_subdir = "lib32";
125 #endif
126
127 #elif defined (__WIN32)
128 const char *__gnat_object_file_option = "";
129 const char *__gnat_run_path_option = "";
130 int __gnat_link_max = 30000;
131 unsigned char __gnat_objlist_file_supported = 1;
132 char __gnat_shared_libgnat_default = STATIC;
133 char __gnat_shared_libgcc_default = STATIC;
134 unsigned char __gnat_using_gnu_linker = 1;
135 const char *__gnat_object_library_extension = ".a";
136 unsigned char __gnat_separate_run_path_options = 0;
137 const char *__gnat_default_libgcc_subdir = "lib";
138
139 #elif defined (__hpux__)
140 const char *__gnat_object_file_option = "-Wl,-c,";
141 const char *__gnat_run_path_option = "-Wl,+b,";
142 int __gnat_link_max = 5000;
143 unsigned char __gnat_objlist_file_supported = 1;
144 char __gnat_shared_libgnat_default = STATIC;
145 char __gnat_shared_libgcc_default = STATIC;
146 unsigned char __gnat_using_gnu_linker = 0;
147 const char *__gnat_object_library_extension = ".a";
148 unsigned char __gnat_separate_run_path_options = 0;
149 const char *__gnat_default_libgcc_subdir = "lib";
150
151 #elif defined (_AIX)
152 const char *__gnat_object_file_option = "-Wl,-f,";
153 const char *__gnat_run_path_option = "";
154 int __gnat_link_max = 15000;
155 const unsigned char __gnat_objlist_file_supported = 1;
156 char __gnat_shared_libgnat_default = STATIC;
157 char __gnat_shared_libgcc_default = STATIC;
158 unsigned char __gnat_using_gnu_linker = 0;
159 const char *__gnat_object_library_extension = ".a";
160 unsigned char __gnat_separate_run_path_options = 0;
161 const char *__gnat_default_libgcc_subdir = "lib";
162
163 #elif defined (VMS)
164 const char *__gnat_object_file_option = "";
165 const char *__gnat_run_path_option = "";
166 char __gnat_shared_libgnat_default = STATIC;
167 char __gnat_shared_libgcc_default = STATIC;
168 int __gnat_link_max = 2147483647;
169 unsigned char __gnat_objlist_file_supported = 0;
170 unsigned char __gnat_using_gnu_linker = 0;
171 const char *__gnat_object_library_extension = ".olb";
172 unsigned char __gnat_separate_run_path_options = 0;
173 const char *__gnat_default_libgcc_subdir = "lib";
174
175 #elif defined (sun)
176 const char *__gnat_object_file_option = "";
177 const char *__gnat_run_path_option = "-Wl,-R";
178 char __gnat_shared_libgnat_default = STATIC;
179 char __gnat_shared_libgcc_default = STATIC;
180 int __gnat_link_max = 2147483647;
181 unsigned char __gnat_objlist_file_supported = 0;
182 unsigned char __gnat_using_gnu_linker = 0;
183 const char *__gnat_object_library_extension = ".a";
184 unsigned char __gnat_separate_run_path_options = 0;
185 #if defined (__sparc_v9__) || defined (__sparcv9)
186 const char *__gnat_default_libgcc_subdir = "lib/sparcv9";
187 #elif defined (__x86_64)
188 const char *__gnat_default_libgcc_subdir = "lib/amd64";
189 #else
190 const char *__gnat_default_libgcc_subdir = "lib";
191 #endif
192
193 #elif defined (__FreeBSD__)
194 const char *__gnat_object_file_option = "";
195 const char *__gnat_run_path_option = "-Wl,-rpath,";
196 char __gnat_shared_libgnat_default = STATIC;
197 char __gnat_shared_libgcc_default = STATIC;
198 int __gnat_link_max = 8192;
199 unsigned char __gnat_objlist_file_supported = 1;
200 unsigned char __gnat_using_gnu_linker = 1;
201 const char *__gnat_object_library_extension = ".a";
202 unsigned char __gnat_separate_run_path_options = 0;
203 const char *__gnat_default_libgcc_subdir = "lib";
204
205 #elif defined (__APPLE__)
206 const char *__gnat_object_file_option = "-Wl,-filelist,";
207 const char *__gnat_run_path_option = "-Wl,-rpath,";
208 char __gnat_shared_libgnat_default = STATIC;
209 char __gnat_shared_libgcc_default = SHARED;
210 int __gnat_link_max = 262144;
211 unsigned char __gnat_objlist_file_supported = 1;
212 unsigned char __gnat_using_gnu_linker = 0;
213 const char *__gnat_object_library_extension = ".a";
214 unsigned char __gnat_separate_run_path_options = 1;
215 const char *__gnat_default_libgcc_subdir = "lib";
216
217 #elif defined (linux) || defined(__GLIBC__)
218 const char *__gnat_object_file_option = "";
219 const char *__gnat_run_path_option = "-Wl,-rpath,";
220 char __gnat_shared_libgnat_default = STATIC;
221 char __gnat_shared_libgcc_default = STATIC;
222 int __gnat_link_max = 8192;
223 unsigned char __gnat_objlist_file_supported = 1;
224 unsigned char __gnat_using_gnu_linker = 1;
225 const char *__gnat_object_library_extension = ".a";
226 unsigned char __gnat_separate_run_path_options = 0;
227 #if defined (__x86_64)
228 const char *__gnat_default_libgcc_subdir = "lib64";
229 #else
230 const char *__gnat_default_libgcc_subdir = "lib";
231 #endif
232
233 #elif defined (__svr4__) && defined (i386)
234 const char *__gnat_object_file_option = "";
235 const char *__gnat_run_path_option = "";
236 char __gnat_shared_libgnat_default = STATIC;
237 char __gnat_shared_libgcc_default = STATIC;
238 int __gnat_link_max = 2147483647;
239 unsigned char __gnat_objlist_file_supported = 0;
240 unsigned char __gnat_using_gnu_linker = 0;
241 const char *__gnat_object_library_extension = ".a";
242 unsigned char __gnat_separate_run_path_options = 0;
243 const char *__gnat_default_libgcc_subdir = "lib";
244
245 #else
246
247 /*  These are the default settings for all other systems. No response file
248     is supported, the shared library default is STATIC.  */
249 const char *__gnat_run_path_option = "";
250 const char *__gnat_object_file_option = "";
251 char __gnat_shared_libgnat_default = STATIC;
252 char __gnat_shared_libgcc_default = STATIC;
253 int __gnat_link_max = 2147483647;
254 unsigned char __gnat_objlist_file_supported = 0;
255 unsigned char __gnat_using_gnu_linker = 0;
256 const char *__gnat_object_library_extension = ".a";
257 unsigned char __gnat_separate_run_path_options = 0;
258 const char *__gnat_default_libgcc_subdir = "lib";
259 #endif
260
261 #ifdef __cplusplus
262 }
263 #endif