OSDN Git Service

gcc/ada/
[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-2007, 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 2,  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.  See the GNU General Public License *
17  * for  more details.  You should have  received  a copy of the GNU General *
18  * Public License  distributed with GNAT;  see file COPYING.  If not, write *
19  * to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, *
20  * Boston, MA 02110-1301, USA.                                              *
21  *                                                                          *
22  * As a  special  exception,  if you  link  this file  with other  files to *
23  * produce an executable,  this file does not by itself cause the resulting *
24  * executable to be covered by the GNU General Public License. This except- *
25  * ion does not  however invalidate  any other reasons  why the  executable *
26  * file might be covered by the  GNU Public License.                        *
27  *                                                                          *
28  * GNAT was originally developed  by the GNAT team at  New York University. *
29  * Extensive contributions were provided by Ada Core Technologies Inc.      *
30  *                                                                          *
31  ****************************************************************************/
32
33 /*  This file contains host-specific parameters describing the behavior     */
34 /*  of the linker. It is used by gnatlink as well as all tools that use     */
35 /*  Mlib.                                                                   */
36
37 #include <string.h>
38
39 /*  objlist_file_supported is set to 1 when the system linker allows        */
40 /*  response file, that is a file that contains the list of object files.   */
41 /*  This is useful on systems where the command line length is limited,     */
42 /*  meaning that putting all the object files on the command line can       */
43 /*  result in an unacceptable limit on the number of files.                 */
44
45 /*  object_file_option denotes the system dependent linker option which     */
46 /*  allows object file names to be placed in a file and then passed to      */
47 /*  the linker. object_file_option must be set if objlist_file_supported    */
48 /*  is set to 1.                                                            */
49
50 /*  link_max is a conservative system specific threshold (in bytes) of the  */
51 /*  argument length passed to the linker which will trigger a file being    */
52 /*  used instead of the command line directly. If the argument length is    */
53 /*  greater than this threshold, then an objlist_file will be generated     */
54 /*  and object_file_option and objlist_file_supported must be set. If       */
55 /*  objlist_file_supported is set to 0 (unsupported), then link_max is      */
56 /*  set to 2**31-1 so that the limit will never be exceeded.                */
57
58 /*  run_path_option is the system dependent linker option which specifies   */
59 /*  the run time path to use when loading dynamic libraries. This should    */
60 /*  be set to the null string if the system does not support dynamic        */
61 /*  loading of libraries.                                                   */
62
63 /*  shared_libgnat_default gives the system dependent link method that      */
64 /*  be used by default for linking libgnat (shared or static)               */
65
66 /*  using_gnu_linker is set to 1 when the GNU linker is used under this     */
67 /*  target.                                                                 */
68
69 /*  RESPONSE FILE & GNU LINKER                                              */
70 /*  --------------------------                                              */
71 /*  objlist_file_supported and using_gnu_link used together tell gnatlink   */
72 /*  to generate a GNU style response file. Note that object_file_option     */
73 /*  must be set to "" in this case, since no option is required for a       */
74 /*  response file to be passed to GNU ld. With a GNU linker we use the      */
75 /*  linker script to implement the response file feature. Any file passed   */
76 /*  in the GNU ld command line with an unknown extension is supposed to be  */
77 /*  a linker script. Each linker script augment the current configuration.  */
78 /*  The format of such response file is as follow :                         */
79 /*  INPUT (obj1.p obj2.o ...)                                               */
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 unsigned char __gnat_using_gnu_linker = 0;
91 const char *__gnat_object_library_extension = ".a";
92
93 #elif defined (sgi)
94 const char *__gnat_object_file_option = "-Wl,-objectlist,";
95 const char *__gnat_run_path_option = "-Wl,-rpath,";
96 int __gnat_link_max = 5000;
97 unsigned char __gnat_objlist_file_supported = 1;
98 char __gnat_shared_libgnat_default = STATIC;
99 unsigned char __gnat_using_gnu_linker = 0;
100 const char *__gnat_object_library_extension = ".a";
101
102 #elif defined (__WIN32)
103 const char *__gnat_object_file_option = "";
104 const char *__gnat_run_path_option = "";
105 int __gnat_link_max = 30000;
106 unsigned char __gnat_objlist_file_supported = 1;
107 char __gnat_shared_libgnat_default = STATIC;
108 unsigned char __gnat_using_gnu_linker = 1;
109 const char *__gnat_object_library_extension = ".a";
110
111 #elif defined (__hpux__)
112 const char *__gnat_object_file_option = "-Wl,-c,";
113 const char *__gnat_run_path_option = "-Wl,+b,";
114 int __gnat_link_max = 5000;
115 unsigned char __gnat_objlist_file_supported = 1;
116 char __gnat_shared_libgnat_default = STATIC;
117 unsigned char __gnat_using_gnu_linker = 0;
118 const char *__gnat_object_library_extension = ".a";
119
120 #elif defined (_AIX)
121 const char *__gnat_object_file_option = "-Wl,-f,";
122 const char *__gnat_run_path_option = "";
123 int __gnat_link_max = 15000;
124 const unsigned char __gnat_objlist_file_supported = 1;
125 char __gnat_shared_libgnat_default = STATIC;
126 unsigned char __gnat_using_gnu_linker = 0;
127 const char *__gnat_object_library_extension = ".a";
128
129 #elif defined (VMS)
130 const char *__gnat_object_file_option = "";
131 const char *__gnat_run_path_option = "";
132 char __gnat_shared_libgnat_default = STATIC;
133 int __gnat_link_max = 2147483647;
134 unsigned char __gnat_objlist_file_supported = 0;
135 unsigned char __gnat_using_gnu_linker = 0;
136 const char *__gnat_object_library_extension = ".olb";
137
138 #elif defined (sun)
139 const char *__gnat_object_file_option = "";
140 const char *__gnat_run_path_option = "-Wl,-R";
141 char __gnat_shared_libgnat_default = STATIC;
142 int __gnat_link_max = 2147483647;
143 unsigned char __gnat_objlist_file_supported = 0;
144 unsigned char __gnat_using_gnu_linker = 0;
145 const char *__gnat_object_library_extension = ".a";
146
147 #elif defined (__FreeBSD__)
148 const char *__gnat_object_file_option = "";
149 const char *__gnat_run_path_option = "-Wl,-rpath,";
150 char __gnat_shared_libgnat_default = STATIC;
151 int __gnat_link_max = 8192;
152 unsigned char __gnat_objlist_file_supported = 1;
153 unsigned char __gnat_using_gnu_linker = 1;
154 const char *__gnat_object_library_extension = ".a";
155
156 #elif defined (linux)
157 const char *__gnat_object_file_option = "";
158 const char *__gnat_run_path_option = "-Wl,-rpath,";
159 char __gnat_shared_libgnat_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
165 #elif defined (__svr4__) && defined (i386)
166 const char *__gnat_object_file_option = "";
167 const char *__gnat_run_path_option = "";
168 char __gnat_shared_libgnat_default = STATIC;
169 int __gnat_link_max = 2147483647;
170 unsigned char __gnat_objlist_file_supported = 0;
171 unsigned char __gnat_using_gnu_linker = 0;
172 const char *__gnat_object_library_extension = ".a";
173
174 #else
175
176 /*  These are the default settings for all other systems. No response file
177     is supported, the shared library default is STATIC.  */
178 const char *__gnat_run_path_option = "";
179 const char *__gnat_object_file_option = "";
180 char __gnat_shared_libgnat_default = STATIC;
181 int __gnat_link_max = 2147483647;
182 unsigned char __gnat_objlist_file_supported = 0;
183 unsigned char __gnat_using_gnu_linker = 0;
184 const char *__gnat_object_library_extension = ".a";
185 #endif