fixing pr42337
[official-gcc.git] / gcc / ada / link.c
blob6ebd329612ff1b25ade4e4347955550c0392868e
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * L I N K *
6 * *
7 * C Implementation File *
8 * *
9 * Copyright (C) 1992-2009, 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 ****************************************************************************/
32 /* This file contains host-specific parameters describing the behavior */
33 /* of the linker. It is used by gnatlink as well as all tools that use */
34 /* Mlib. */
36 #include <string.h>
38 /* objlist_file_supported is set to 1 when the system linker allows */
39 /* response file, that is a file that contains the list of object files. */
40 /* This is useful on systems where the command line length is limited, */
41 /* meaning that putting all the object files on the command line can */
42 /* result in an unacceptable limit on the number of files. */
44 /* object_file_option denotes the system dependent linker option which */
45 /* allows object file names to be placed in a file and then passed to */
46 /* the linker. object_file_option must be set if objlist_file_supported */
47 /* is set to 1. */
49 /* link_max is a conservative system specific threshold (in bytes) of the */
50 /* argument length passed to the linker which will trigger a file being */
51 /* used instead of the command line directly. If the argument length is */
52 /* greater than this threshold, then an objlist_file will be generated */
53 /* and object_file_option and objlist_file_supported must be set. If */
54 /* objlist_file_supported is set to 0 (unsupported), then link_max is */
55 /* set to 2**31-1 so that the limit will never be exceeded. */
57 /* run_path_option is the system dependent linker option which specifies */
58 /* the run time path to use when loading dynamic libraries. This should */
59 /* be set to the null string if the system does not support dynamic */
60 /* loading of libraries. */
62 /* shared_libgnat_default gives the system dependent link method that */
63 /* be used by default for linking libgnat (shared or static) */
65 /* shared_libgcc_default gives the system dependent link method that */
66 /* be used by default for linking libgcc (shared or statis) */
68 /* using_gnu_linker is set to 1 when the GNU linker is used under this */
69 /* target. */
71 /* separate_run_path_options is set to 1 when separate "rpath" arguments */
72 /* must be passed to the linker for each directory in the rpath. */
74 /* RESPONSE FILE & GNU LINKER */
75 /* -------------------------- */
76 /* objlist_file_supported and using_gnu_link used together tell gnatlink */
77 /* to generate a GNU style response file. Note that object_file_option */
78 /* must be set to "" in this case, since no option is required for a */
79 /* response file to be passed to GNU ld. With a GNU linker we use the */
80 /* linker script to implement the response file feature. Any file passed */
81 /* in the GNU ld command line with an unknown extension is supposed to be */
82 /* a linker script. Each linker script augment the current configuration. */
83 /* The format of such response file is as follow : */
84 /* INPUT (obj1.p obj2.o ...) */
86 #define SHARED 'H'
87 #define STATIC 'T'
89 #if defined (__osf__)
90 const char *__gnat_object_file_option = "-Wl,-input,";
91 const char *__gnat_run_path_option = "-Wl,-rpath,";
92 int __gnat_link_max = 10000;
93 unsigned char __gnat_objlist_file_supported = 1;
94 char __gnat_shared_libgnat_default = STATIC;
95 char __gnat_shared_libgcc_default = STATIC;
96 unsigned char __gnat_using_gnu_linker = 0;
97 const char *__gnat_object_library_extension = ".a";
98 unsigned char __gnat_separate_run_path_options = 0;
100 #elif defined (sgi)
101 const char *__gnat_object_file_option = "-Wl,-objectlist,";
102 const char *__gnat_run_path_option = "-Wl,-rpath,";
103 int __gnat_link_max = 5000;
104 unsigned char __gnat_objlist_file_supported = 1;
105 char __gnat_shared_libgnat_default = STATIC;
106 char __gnat_shared_libgcc_default = STATIC;
107 unsigned char __gnat_using_gnu_linker = 0;
108 const char *__gnat_object_library_extension = ".a";
109 unsigned char __gnat_separate_run_path_options = 0;
111 #elif defined (__WIN32)
112 const char *__gnat_object_file_option = "";
113 const char *__gnat_run_path_option = "";
114 int __gnat_link_max = 30000;
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 = 1;
119 const char *__gnat_object_library_extension = ".a";
120 unsigned char __gnat_separate_run_path_options = 0;
122 #elif defined (__hpux__)
123 const char *__gnat_object_file_option = "-Wl,-c,";
124 const char *__gnat_run_path_option = "-Wl,+b,";
125 int __gnat_link_max = 5000;
126 unsigned char __gnat_objlist_file_supported = 1;
127 char __gnat_shared_libgnat_default = STATIC;
128 char __gnat_shared_libgcc_default = STATIC;
129 unsigned char __gnat_using_gnu_linker = 0;
130 const char *__gnat_object_library_extension = ".a";
131 unsigned char __gnat_separate_run_path_options = 0;
133 #elif defined (_AIX)
134 const char *__gnat_object_file_option = "-Wl,-f,";
135 const char *__gnat_run_path_option = "";
136 int __gnat_link_max = 15000;
137 const unsigned char __gnat_objlist_file_supported = 1;
138 char __gnat_shared_libgnat_default = STATIC;
139 char __gnat_shared_libgcc_default = STATIC;
140 unsigned char __gnat_using_gnu_linker = 0;
141 const char *__gnat_object_library_extension = ".a";
142 unsigned char __gnat_separate_run_path_options = 0;
144 #elif defined (VMS)
145 const char *__gnat_object_file_option = "";
146 const char *__gnat_run_path_option = "";
147 char __gnat_shared_libgnat_default = STATIC;
148 char __gnat_shared_libgcc_default = STATIC;
149 int __gnat_link_max = 2147483647;
150 unsigned char __gnat_objlist_file_supported = 0;
151 unsigned char __gnat_using_gnu_linker = 0;
152 const char *__gnat_object_library_extension = ".olb";
153 unsigned char __gnat_separate_run_path_options = 0;
155 #elif defined (sun)
156 const char *__gnat_object_file_option = "";
157 const char *__gnat_run_path_option = "-Wl,-R";
158 char __gnat_shared_libgnat_default = STATIC;
159 char __gnat_shared_libgcc_default = STATIC;
160 int __gnat_link_max = 2147483647;
161 unsigned char __gnat_objlist_file_supported = 0;
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;
166 #elif defined (__FreeBSD__)
167 const char *__gnat_object_file_option = "";
168 const char *__gnat_run_path_option = "-Wl,-rpath,";
169 char __gnat_shared_libgnat_default = STATIC;
170 char __gnat_shared_libgcc_default = STATIC;
171 int __gnat_link_max = 8192;
172 unsigned char __gnat_objlist_file_supported = 1;
173 unsigned char __gnat_using_gnu_linker = 1;
174 const char *__gnat_object_library_extension = ".a";
175 unsigned char __gnat_separate_run_path_options = 0;
177 #elif defined (__APPLE__)
178 const char *__gnat_object_file_option = "-Wl,-filelist,";
179 const char *__gnat_run_path_option = "-Wl,-rpath,";
180 char __gnat_shared_libgnat_default = STATIC;
181 char __gnat_shared_libgcc_default = SHARED;
182 int __gnat_link_max = 262144;
183 unsigned char __gnat_objlist_file_supported = 1;
184 unsigned char __gnat_using_gnu_linker = 0;
185 const char *__gnat_object_library_extension = ".a";
186 unsigned char __gnat_separate_run_path_options = 1;
188 #elif defined (linux) || defined(__GLIBC__)
189 const char *__gnat_object_file_option = "";
190 const char *__gnat_run_path_option = "-Wl,-rpath,";
191 char __gnat_shared_libgnat_default = STATIC;
192 char __gnat_shared_libgcc_default = STATIC;
193 int __gnat_link_max = 8192;
194 unsigned char __gnat_objlist_file_supported = 1;
195 unsigned char __gnat_using_gnu_linker = 1;
196 const char *__gnat_object_library_extension = ".a";
197 unsigned char __gnat_separate_run_path_options = 0;
199 #elif defined (__svr4__) && defined (i386)
200 const char *__gnat_object_file_option = "";
201 const char *__gnat_run_path_option = "";
202 char __gnat_shared_libgnat_default = STATIC;
203 char __gnat_shared_libgcc_default = STATIC;
204 int __gnat_link_max = 2147483647;
205 unsigned char __gnat_objlist_file_supported = 0;
206 unsigned char __gnat_using_gnu_linker = 0;
207 const char *__gnat_object_library_extension = ".a";
208 unsigned char __gnat_separate_run_path_options = 0;
210 #else
212 /* These are the default settings for all other systems. No response file
213 is supported, the shared library default is STATIC. */
214 const char *__gnat_run_path_option = "";
215 const char *__gnat_object_file_option = "";
216 char __gnat_shared_libgnat_default = STATIC;
217 char __gnat_shared_libgcc_default = STATIC;
218 int __gnat_link_max = 2147483647;
219 unsigned char __gnat_objlist_file_supported = 0;
220 unsigned char __gnat_using_gnu_linker = 0;
221 const char *__gnat_object_library_extension = ".a";
222 unsigned char __gnat_separate_run_path_options = 0;
223 #endif