OSDN Git Service

2004-01-05 Robert Dewar <dewar@gnat.com>
[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-2003, 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,  59 Temple Place - Suite 330,  Boston, *
20  * MA 02111-1307, 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 parameterizations used by gnatlink.adb in handling   */
34 /*  very long linker lines in systems where there are limitations on the    */
35 /*  argument length when the command line is used to pass items to the      */
36 /*  linker                                                                  */
37
38 #include <string.h>
39
40 /*  objlist_file_supported is set to 1 when the system linker allows        */
41 /*  response file, that is a file that contains the list of object files.   */
42 /*  This is useful on systems where the command line length is limited,     */
43 /*  meaning that putting all the object files on the command line can       */
44 /*  result in an unacceptable limit on the number of files.                 */
45
46 /*  object_file_option denotes the system dependent linker option which     */
47 /*  allows object file names to be placed in a file and then passed to      */
48 /*  the linker. object_file_option must be set if objlist_file_supported    */
49 /*  is set to 1.                                                            */
50
51 /*  link_max is a conservative system specific threshold (in bytes) of the  */
52 /*  argument length passed to the linker which will trigger a file being    */
53 /*  used instead of the command line directly. If the argument length is    */
54 /*  greater than this threshhold, then an objlist_file will be generated    */
55 /*  and object_file_option and objlist_file_supported must be set. If       */
56 /*  objlist_file_supported is set to 0 (unsupported), then link_max is      */
57 /*  set to 2**31-1 so that the limit will never be exceeded.                */
58
59 /*  run_path_option is the system dependent linker option which specifies   */
60 /*  the run time path to use when loading dynamic libraries. This should    */
61 /*  be set to the null string if the system does not support dynmamic       */
62 /*  loading of libraries.                                                   */
63
64 /*  shared_libgnat_default gives the system dependent link method that      */
65 /*  be used by default for linking libgnat (shared or static)               */
66
67 /*  using_gnu_linker is set to 1 when the GNU linker is used under this     */
68 /*  target.                                                                 */
69
70 /*  RESPONSE FILE & GNU LINKER                                              */
71 /*  --------------------------                                              */
72 /*  objlist_file_supported and using_gnu_link used together tell gnatlink   */
73 /*  to generate a GNU style response file. Note that object_file_option     */
74 /*  must be set to "" in this case, since no option is required for a       */
75 /*  response file to be passed to GNU ld. With a GNU linker we use the      */
76 /*  linker script to implement the response file feature. Any file passed   */
77 /*  in the GNU ld command line with an unknown extension is supposed to be  */
78 /*  a linker script. Each linker script augment the current configuration.  */
79 /*  The format of such response file is as follow :                         */
80 /*  INPUT (obj1.p obj2.o ...)                                               */
81
82 #define SHARED 'H'
83 #define STATIC 'T'
84
85 #if defined (__osf__)
86 const char *object_file_option = "-Wl,-input,";
87 const char *run_path_option = "-Wl,-rpath,";
88 int link_max = 10000;
89 unsigned char objlist_file_supported = 1;
90 char shared_libgnat_default = STATIC;
91 unsigned char using_gnu_linker = 0;
92 const char *object_library_extension = ".a";
93
94 #elif defined (sgi)
95 const char *object_file_option = "-Wl,-objectlist,";
96 const char *run_path_option = "-Wl,-rpath,";
97 int link_max = 5000;
98 unsigned char objlist_file_supported = 1;
99 char shared_libgnat_default = SHARED;
100 unsigned char using_gnu_linker = 0;
101 const char *object_library_extension = ".a";
102
103 #elif defined (__WIN32)
104 const char *object_file_option = "";
105 const char *run_path_option = "";
106 int link_max = 30000;
107 unsigned char objlist_file_supported = 1;
108 char shared_libgnat_default = STATIC;
109 unsigned char using_gnu_linker = 1;
110 const char *object_library_extension = ".a";
111
112 #elif defined (__INTERIX)
113 const char *object_file_option = "";
114 const char *run_path_option = "";
115 int link_max = 5000;
116 unsigned char objlist_file_supported = 1;
117 char shared_libgnat_default = STATIC;
118 unsigned char using_gnu_linker = 1;
119 const char *object_library_extension = ".a";
120
121 #elif defined (hpux)
122 const char *object_file_option = "-Wl,-c,";
123 const char *run_path_option = "-Wl,+b,";
124 int link_max = 5000;
125 unsigned char objlist_file_supported = 1;
126 char shared_libgnat_default = STATIC;
127 unsigned char using_gnu_linker = 0;
128 const char *object_library_extension = ".a";
129
130 #elif defined (_AIX)
131 const char *object_file_option = "-Wl,-f,";
132 const char *run_path_option = "";
133 int link_max = 15000;
134 const unsigned char objlist_file_supported = 1;
135 char shared_libgnat_default = STATIC;
136 unsigned char using_gnu_linker = 0;
137 const char *object_library_extension = ".a";
138
139 #elif defined (VMS)
140 const char *object_file_option = "";
141 const char *run_path_option = "";
142 char shared_libgnat_default = STATIC;
143 int link_max = 2147483647;
144 unsigned char objlist_file_supported = 0;
145 unsigned char using_gnu_linker = 0;
146 const char *object_library_extension = ".olb";
147
148 #elif defined (sun)
149 const char *object_file_option = "";
150 const char *run_path_option = "-R";
151 char shared_libgnat_default = STATIC;
152 int link_max = 2147483647;
153 unsigned char objlist_file_supported = 0;
154 unsigned char using_gnu_linker = 0;
155 const char *object_library_extension = ".a";
156
157 #elif defined (__FreeBSD__)
158 char *object_file_option = "";
159 char *run_path_option = "";
160 char shared_libgnat_default = SHARED;
161 int link_max = 2147483647;
162 unsigned char objlist_file_supported = 0;
163 unsigned char using_gnu_linker = 0;
164 char *object_library_extension = ".a";
165
166 #elif defined (linux)
167 const char *object_file_option = "";
168 const char *run_path_option = "-Wl,-rpath,";
169 char shared_libgnat_default = STATIC;
170 int link_max = 8192;
171 unsigned char objlist_file_supported = 1;
172 unsigned char using_gnu_linker = 1;
173 const char *object_library_extension = ".a";
174
175 #elif defined (__svr4__) && defined (i386)
176 const char *object_file_option = "";
177 const char *run_path_option = "";
178 char shared_libgnat_default = STATIC;
179 int link_max = 2147483647;
180 unsigned char objlist_file_supported = 0;
181 unsigned char using_gnu_linker = 0;
182 const char *object_library_extension = ".a";
183
184 #else
185
186 /*  These are the default settings for all other systems. No response file
187     is supported, the shared library default is STATIC.  */
188 const char *run_path_option = "";
189 const char *object_file_option = "";
190 char shared_libgnat_default = STATIC;
191 int link_max = 2147483647;
192 unsigned char objlist_file_supported = 0;
193 unsigned char using_gnu_linker = 0;
194 const char *object_library_extension = ".a";
195 #endif