]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/link.c
gcc/
[thirdparty/gcc.git] / gcc / ada / link.c
CommitLineData
83cce46b 1/****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * L I N K *
6 * *
83cce46b 7 * C Implementation File *
8 * *
126b6848 9 * Copyright (C) 1992-2012, Free Software Foundation, Inc. *
83cce46b 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- *
6bc9506f 13 * ware Foundation; either version 3, or (at your option) any later ver- *
83cce46b 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 *
6bc9506f 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/>. *
83cce46b 26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
e78e8c8e 28 * Extensive contributions were provided by Ada Core Technologies Inc. *
83cce46b 29 * *
30 ****************************************************************************/
31
becb63f5 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
36extern "C" {
37#endif
83cce46b 38
9b94c9e7 39#ifdef IN_GCC
6cb4b973 40#include "auto-host.h"
9b94c9e7 41#endif
83cce46b 42
d0c9584a 43#include <string.h>
44
83cce46b 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 */
27f48659 59/* greater than this threshold, then an objlist_file will be generated */
83cce46b 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 */
27f48659 66/* be set to the null string if the system does not support dynamic */
83cce46b 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
d2697a05 72/* shared_libgcc_default gives the system dependent link method that */
6fb3c314 73/* be used by default for linking libgcc (shared or static) */
d2697a05 74
83cce46b 75/* using_gnu_linker is set to 1 when the GNU linker is used under this */
76/* target. */
77
5e0f2e2f 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
bfcff2f0 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
83cce46b 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
5641963c 99#if defined (__WIN32)
f270dc82 100const char *__gnat_object_file_option = "";
101const char *__gnat_run_path_option = "";
102int __gnat_link_max = 30000;
103unsigned char __gnat_objlist_file_supported = 1;
104char __gnat_shared_libgnat_default = STATIC;
d2697a05 105char __gnat_shared_libgcc_default = STATIC;
f270dc82 106unsigned char __gnat_using_gnu_linker = 1;
107const char *__gnat_object_library_extension = ".a";
5e0f2e2f 108unsigned char __gnat_separate_run_path_options = 0;
bfcff2f0 109const char *__gnat_default_libgcc_subdir = "lib";
83cce46b 110
21a87c1d 111#elif defined (__hpux__)
f270dc82 112const char *__gnat_object_file_option = "-Wl,-c,";
113const char *__gnat_run_path_option = "-Wl,+b,";
114int __gnat_link_max = 5000;
115unsigned char __gnat_objlist_file_supported = 1;
116char __gnat_shared_libgnat_default = STATIC;
d2697a05 117char __gnat_shared_libgcc_default = STATIC;
f270dc82 118unsigned char __gnat_using_gnu_linker = 0;
119const char *__gnat_object_library_extension = ".a";
5e0f2e2f 120unsigned char __gnat_separate_run_path_options = 0;
bfcff2f0 121const char *__gnat_default_libgcc_subdir = "lib";
83cce46b 122
c73904bb 123#elif defined (__FreeBSD__)
eabcce03 124const char *__gnat_object_file_option = "";
125const char *__gnat_run_path_option = "-Wl,-rpath,";
f270dc82 126char __gnat_shared_libgnat_default = STATIC;
d2697a05 127char __gnat_shared_libgcc_default = STATIC;
44d43e97 128int __gnat_link_max = 8192;
129unsigned char __gnat_objlist_file_supported = 1;
130unsigned char __gnat_using_gnu_linker = 1;
eabcce03 131const char *__gnat_object_library_extension = ".a";
5e0f2e2f 132unsigned char __gnat_separate_run_path_options = 0;
bfcff2f0 133const char *__gnat_default_libgcc_subdir = "lib";
83cce46b 134
8a3d0a8f 135#elif defined (__APPLE__)
723bd332 136const char *__gnat_object_file_option = "-Wl,-filelist,";
8a3d0a8f 137const char *__gnat_run_path_option = "-Wl,-rpath,";
138char __gnat_shared_libgnat_default = STATIC;
d2697a05 139char __gnat_shared_libgcc_default = SHARED;
8a3d0a8f 140int __gnat_link_max = 262144;
141unsigned char __gnat_objlist_file_supported = 1;
723bd332 142unsigned char __gnat_using_gnu_linker = 0;
8a3d0a8f 143const char *__gnat_object_library_extension = ".a";
5e0f2e2f 144unsigned char __gnat_separate_run_path_options = 1;
bfcff2f0 145const char *__gnat_default_libgcc_subdir = "lib";
8a3d0a8f 146
9d093602 147#elif defined (linux) || defined(__GLIBC__)
f270dc82 148const char *__gnat_object_file_option = "";
149const char *__gnat_run_path_option = "-Wl,-rpath,";
150char __gnat_shared_libgnat_default = STATIC;
d2697a05 151char __gnat_shared_libgcc_default = STATIC;
f270dc82 152int __gnat_link_max = 8192;
153unsigned char __gnat_objlist_file_supported = 1;
154unsigned char __gnat_using_gnu_linker = 1;
155const char *__gnat_object_library_extension = ".a";
5e0f2e2f 156unsigned char __gnat_separate_run_path_options = 0;
bfcff2f0 157#if defined (__x86_64)
70d595c8 158# if defined (__LP64__)
bfcff2f0 159const char *__gnat_default_libgcc_subdir = "lib64";
70d595c8 160# else
161const char *__gnat_default_libgcc_subdir = "libx32";
162# endif
bfcff2f0 163#else
164const char *__gnat_default_libgcc_subdir = "lib";
165#endif
83cce46b 166
ce9ee49d 167#elif defined (_AIX)
168/* On AIX, even when with GNU ld we use native linker switches. This is
169 particularly important for '-f' as it should be interpreted by collect2. */
170
171const char *__gnat_object_file_option = "-Wl,-f,";
172const char *__gnat_run_path_option = "";
173char __gnat_shared_libgnat_default = STATIC;
174char __gnat_shared_libgcc_default = STATIC;
175int __gnat_link_max = 15000;
176const unsigned char __gnat_objlist_file_supported = 1;
177unsigned char __gnat_using_gnu_linker = 0;
178const char *__gnat_object_library_extension = ".a";
179unsigned char __gnat_separate_run_path_options = 0;
180const char *__gnat_default_libgcc_subdir = "lib";
181
6cb4b973 182#elif (HAVE_GNU_LD)
183/* These are the settings for all systems that use gnu ld. GNU style response
184 file is supported, the shared library default is STATIC. */
185
6cb4b973 186const char *__gnat_object_file_option = "";
ce9ee49d 187const char *__gnat_run_path_option = "";
6cb4b973 188char __gnat_shared_libgnat_default = STATIC;
189char __gnat_shared_libgcc_default = STATIC;
190int __gnat_link_max = 8192;
191unsigned char __gnat_objlist_file_supported = 1;
192unsigned char __gnat_using_gnu_linker = 1;
193const char *__gnat_object_library_extension = ".a";
194unsigned char __gnat_separate_run_path_options = 0;
195const char *__gnat_default_libgcc_subdir = "lib";
196
197#elif defined (VMS)
198const char *__gnat_object_file_option = "";
199const char *__gnat_run_path_option = "";
200char __gnat_shared_libgnat_default = STATIC;
201char __gnat_shared_libgcc_default = STATIC;
202int __gnat_link_max = 2147483647;
203unsigned char __gnat_objlist_file_supported = 0;
204unsigned char __gnat_using_gnu_linker = 0;
205const char *__gnat_object_library_extension = ".olb";
206unsigned char __gnat_separate_run_path_options = 0;
207const char *__gnat_default_libgcc_subdir = "lib";
208
209#elif defined (sun)
210const char *__gnat_object_file_option = "";
211const char *__gnat_run_path_option = "-Wl,-R";
212char __gnat_shared_libgnat_default = STATIC;
213char __gnat_shared_libgcc_default = STATIC;
214int __gnat_link_max = 2147483647;
215unsigned char __gnat_objlist_file_supported = 0;
216unsigned char __gnat_using_gnu_linker = 0;
217const char *__gnat_object_library_extension = ".a";
218unsigned char __gnat_separate_run_path_options = 0;
219#if defined (__sparc_v9__) || defined (__sparcv9)
220const char *__gnat_default_libgcc_subdir = "lib/sparcv9";
221#elif defined (__x86_64)
222const char *__gnat_default_libgcc_subdir = "lib/amd64";
223#else
224const char *__gnat_default_libgcc_subdir = "lib";
225#endif
226
83cce46b 227#elif defined (__svr4__) && defined (i386)
f270dc82 228const char *__gnat_object_file_option = "";
229const char *__gnat_run_path_option = "";
230char __gnat_shared_libgnat_default = STATIC;
d2697a05 231char __gnat_shared_libgcc_default = STATIC;
f270dc82 232int __gnat_link_max = 2147483647;
233unsigned char __gnat_objlist_file_supported = 0;
234unsigned char __gnat_using_gnu_linker = 0;
235const char *__gnat_object_library_extension = ".a";
5e0f2e2f 236unsigned char __gnat_separate_run_path_options = 0;
bfcff2f0 237const char *__gnat_default_libgcc_subdir = "lib";
83cce46b 238
239#else
240
241/* These are the default settings for all other systems. No response file
242 is supported, the shared library default is STATIC. */
f270dc82 243const char *__gnat_run_path_option = "";
244const char *__gnat_object_file_option = "";
245char __gnat_shared_libgnat_default = STATIC;
d2697a05 246char __gnat_shared_libgcc_default = STATIC;
f270dc82 247int __gnat_link_max = 2147483647;
248unsigned char __gnat_objlist_file_supported = 0;
249unsigned char __gnat_using_gnu_linker = 0;
250const char *__gnat_object_library_extension = ".a";
5e0f2e2f 251unsigned char __gnat_separate_run_path_options = 0;
bfcff2f0 252const char *__gnat_default_libgcc_subdir = "lib";
83cce46b 253#endif
becb63f5 254
255#ifdef __cplusplus
256}
257#endif