]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/vax/vms.h
system.h (ENCODE_SECTION_INFO): Poison it.
[thirdparty/gcc.git] / gcc / config / vax / vms.h
CommitLineData
4e81a331 1/* Output variables, constants and external declarations, for GNU compiler.
ae46c4e0
RH
2 Copyright (C) 1988, 1994, 1995, 1996, 1997, 1999, 2001, 2002
3 Free Software Foundation, Inc.
4e81a331
RS
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
c15c9075
RK
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
4e81a331 21
45936a85
DD
22#define TARGET_EXECUTABLE_SUFFIX ".exe"
23#define TARGET_OBJECT_SUFFIX ".obj"
24
4e81a331
RS
25/* This enables certain macros in vax.h, which will make an indirect
26 reference to an external symbol an invalid address. This needs to be
27 defined before we include vax.h, since it determines which macros
28 are used for GO_IF_*. */
29
30#define NO_EXTERNAL_INDIRECT_ADDRESS
31
a87fdbf9 32#include "vax/vax.h"
4e81a331 33
08c148a8
NB
34#undef VMS_TARGET
35#define VMS_TARGET 1
36
4e81a331
RS
37#undef LIB_SPEC
38#undef CPP_PREDEFINES
50a1e705 39#undef TARGET_NAME
4e81a331
RS
40#undef TARGET_DEFAULT
41#undef CALL_USED_REGISTERS
0007bde5 42#undef STARTING_FRAME_OFFSET
4e81a331
RS
43
44/* Predefine this in CPP because VMS limits the size of command options
45 and GNU CPP is not used on VMS except with GNU C. */
6ac36afb
RK
46#define CPP_PREDEFINES \
47"-Dvax -Dvms -DVMS -D__vax__ -D__vms__ -D__VMS__\
2b57e919 48 -D__GNUC__=2 -D__GNUC_MINOR__=7 -Asystem=vms -Acpu=vax -Amachine=vax"
4e81a331 49
b4ac57ab
RS
50/* These match the definitions used in VAXCRTL, the VMS C run-time library */
51
97cf2138
RK
52#define SIZE_TYPE "unsigned int"
53#define PTRDIFF_TYPE "int"
b4ac57ab 54#define WCHAR_TYPE "unsigned int"
97cf2138 55#define WCHAR_TYPE_SIZE 32 /* in bits */
b4ac57ab
RS
56
57/* Use memcpy for structure copying, and so forth. */
58#define TARGET_MEM_FUNCTIONS
59
4e81a331
RS
60/* Strictly speaking, VMS does not use DBX at all, but the interpreter built
61 into gas only speaks straight DBX. */
62
63#define DEFAULT_GDB_EXTENSIONS 0
64
4e81a331 65#define TARGET_DEFAULT 1
50a1e705 66#define TARGET_NAME "vax/vms"
4e81a331 67
635c7420
RS
68/* The structure return address arrives as an "argument" on VMS. */
69#undef STRUCT_VALUE_REGNUM
70#define STRUCT_VALUE 0
7801a9dc 71#undef PCC_STATIC_STRUCT_RETURN
635c7420 72
4e81a331
RS
73#define CALL_USED_REGISTERS {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
74
59927d6b
RK
75/* The run-time library routine VAXC$ESTABLISH (necessary when mixing
76 VMS exception handling and setjmp/longjmp in the same program) requires
77 that a hidden automatic variable at the top of the stack be reserved
78 for its use. We accomplish this by simply adding 4 bytes to the local
79 stack for all functions, and making sure that normal local variables
80 are 4 bytes lower on the stack then they would otherwise have been. */
0007bde5
RS
81
82#define STARTING_FRAME_OFFSET -4
83
4e81a331
RS
84/* This macro definition sets up a default value for `main' to return. */
85#define DEFAULT_MAIN_RETURN c_expand_return (integer_one_node)
86\f
903da765
RS
87/* This is how to output a command to make the user-level label named NAME
88 defined for reference from other files. */
89
90#undef ASM_GLOBALIZE_LABEL
91#define ASM_GLOBALIZE_LABEL(FILE,NAME) \
92 do { fputs (".globl ", FILE); \
93 assemble_name (FILE, NAME); \
94 fputs ("\n", FILE); \
eb11192f 95 vms_check_external (NULL_TREE, NAME, 0); \
903da765
RS
96 } while (0)
97
4e81a331
RS
98/* Under VMS we write the actual size of the storage to be allocated even
99 though the symbol is external. Although it is possible to give external
100 symbols a size of 0 (as unix does), the VMS linker does not make the
101 distinction between a variable definition and an external reference of a
102 variable, and thus the linker will not complain about a missing definition.
103 If we followed the unix example of giving external symbols a size of
104 zero, you tried to link a program where a given variable was externally
105 defined but none of the object modules contained a non-extern definition,
106 the linker would allocate 0 bytes for the variable, and any attempt to
107 use that variable would use the storage allocated to some other variable.
108
109 We must also select either const_section or data_section: this will indicate
110 whether or not the variable will get the readonly bit set. Since the
111 VMS linker does not distinguish between a variable's definition and an
112 external reference, all usages of a given variable must have the readonly
113 bit set the same way, or the linker will get confused and give warning
114 messages. */
115
116/* We used to round the size up to a multiple of 4,
117 but that causes linker errors sometimes when the variable was initialized
118 since the size of its definition was not likewise rounded up. */
119
eb11192f
RK
120/* Note: the original ASM_OUTPUT_EXTERNAL code has been moved into
121 vms_check_external and vms_flush_pending_externals. */
122
4e81a331 123#define ASM_OUTPUT_EXTERNAL(FILE,DECL,NAME) \
eb11192f
RK
124{ if (DECL_INITIAL (DECL) == 0 && TREE_CODE (DECL) != FUNCTION_DECL) \
125 vms_check_external ((DECL), (NAME), 1); \
126}
127
128/* ASM_OUTPUT_EXTERNAL will have wait until after an initializer is
129 completed in order to switch sections for an external object, so
130 use the DECLARE_OBJECT hooks to manage deferred declarations. */
131
132/* This is the default action for ASM_DECLARE_OBJECT_NAME, but if it
133 is explicitly defined, then ASM_FINISH_DECLARE_OBJECT will be used. */
134
135#define ASM_DECLARE_OBJECT_NAME(ASM_OUT_FILE,NAME,DECL) \
c02f953e 136 ASM_OUTPUT_LABEL ((ASM_OUT_FILE), (NAME))
4e81a331 137
eb11192f
RK
138/* We don't need to do anything special to finish the current object, but it
139 should now be safe to output any deferred external global declarations. */
140
141#define ASM_FINISH_DECLARE_OBJECT(FILE,DECL,TOPLVL,ATEND) \
142 vms_flush_pending_externals(FILE)
143
144/* Anything still pending must be flushed at the very end. */
145
146#define ASM_FILE_END(STREAM) \
147 vms_flush_pending_externals(STREAM)
148
4e81a331
RS
149/* Here we redefine ASM_OUTPUT_COMMON to select the data_section or the
150 const_section before writing the ".const" assembler directive.
151 If we were specifying a size of zero for external variables, we would
152 not have to select a section, since the assembler can assume that
153 when the size > 0, the storage is for a non-external, uninitialized
154 variable (for which a "const" declaration would be senseless),
155 and the assembler can make the storage read/write.
156
157 Since the ".const" directive specifies the actual size of the storage used
158 for both external and non-external variables, the assembler cannot
159 make this assumption, and thus it has no way of deciding if storage should
160 be read/write or read-only. To resolve this, we give the assembler some
161 assistance, in the form of a ".const" or a ".data" directive.
162
163 Under GCC 1.40, external variables were declared with a size of zero.
164 The GNU assembler, GAS, will recognize the "-2" switch when built for VMS;
165 when compiling programs with GCC 2.n this switch should be used or the
166 assembler will not give the read-only attribute to external constants.
167 Failure to use this switch will result in linker warning messages about
168 mismatched psect attributes. */
169
170#undef ASM_OUTPUT_COMMON
171
172#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
173( ((TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl)) \
174 ? (const_section (), 0) : (data_section (), 0)), \
175 fputs (".comm ", (FILE)), \
176 assemble_name ((FILE), (NAME)), \
412dc348 177 fprintf ((FILE), ",%u\n", (SIZE)))
4e81a331
RS
178
179/* We define this to prevent the name mangler from putting dollar signs into
180 function names. This isn't really needed, but it has been here for
181 some time and removing it would cause the object files generated by the
182 compiler to be incompatible with the object files from a compiler that
183 had this defined. Since it does no harm, we leave it in. */
184
185#define NO_DOLLAR_IN_LABEL
186
b4ac57ab 187/* Add a "const" section. This is viewed by the assembler as being nearly
4e81a331
RS
188 the same as the "data" section, with the only difference being that a
189 flag is set for variables declared while in the const section. This
190 flag is used to determine whether or not the read/write bit should be
191 set in the Psect definition. */
192
193#define EXTRA_SECTIONS in_const
194
195#define EXTRA_SECTION_FUNCTIONS \
196void \
197const_section () \
198{ \
199 if (in_section != in_const) { \
200 fprintf(asm_out_file,".const\n"); \
201 in_section = in_const; \
202 } \
203}
204
4e81a331
RS
205/* This is used by a hook in varasm.c to write the assembler directives
206 that are needed to tell the startup code which constructors need to
207 be run. */
208
2cc07db4
RH
209#define TARGET_ASM_CONSTRUCTOR vms_asm_out_constructor
210#define TARGET_ASM_DESTRUCTOR vms_asm_out_destructor
4e81a331 211
1d7fac3a
RS
212/* The following definitions are used in libgcc2.c with the __main
213 function. The _SHR symbol is used when the sharable image library
e5e809f4
JL
214 for the C++ library is used - this is picked up automatically by the linker
215 and this symbol points to the start of __CTOR_LIST__ from the C++ library.
216 If the C++ library is not used, then __CTOR_LIST_SHR__ occurs just after
1d7fac3a
RS
217 __CTOR_LIST__, and essentially points to the same list as __CTOR_LIST. */
218
219#ifdef L__main
1d7fac3a
RS
220
221#define __CTOR_LIST__ __gxx_init_0
222#define __CTOR_LIST_END__ __gxx_init_2
223
224#define __CTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_init_0_shr
225#define __CTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_init_2_shr
226
227#define DO_GLOBAL_CTORS_BODY \
228do { \
229 func_ptr *p; \
98ee239e
RK
230 extern func_ptr __CTOR_LIST__[1], __CTOR_LIST_END__[1]; \
231 extern func_ptr __CTOR_LIST_SHR__[1], __CTOR_LIST_SHR_END__[1]; \
232 if (&__CTOR_LIST_SHR__[0] != &__CTOR_LIST__[1]) \
233 for (p = __CTOR_LIST_SHR__ + 1; p < __CTOR_LIST_SHR_END__ ; p++ ) \
234 if (*p) (*p) (); \
1d7fac3a
RS
235 for (p = __CTOR_LIST__ + 1; p < __CTOR_LIST_END__ ; p++ ) \
236 if (*p) (*p) (); \
98ee239e 237 do { /* arrange for `return' from main() to pass through exit() */ \
1d7fac3a
RS
238 __label__ foo; \
239 int *callers_caller_fp = (int *) __builtin_frame_address (3); \
240 register int retval asm ("r0"); \
241 callers_caller_fp[4] = (int) && foo; \
98ee239e 242 break; /* out of do-while block */ \
1d7fac3a
RS
243 foo: \
244 exit (retval); \
98ee239e 245 } while (0); \
1d7fac3a
RS
246} while (0)
247
248#define __DTOR_LIST__ __gxx_clean_0
249#define __DTOR_LIST_END__ __gxx_clean_2
250
251#define __DTOR_LIST_SHR__ $$PsectAttributes_NOSHR$$__gxx_clean_0_shr
252#define __DTOR_LIST_SHR_END__ $$PsectAttributes_NOSHR$$__gxx_clean_2_shr
253
254#define DO_GLOBAL_DTORS_BODY \
255do { \
256 func_ptr *p; \
98ee239e
RK
257 extern func_ptr __DTOR_LIST__[1], __DTOR_LIST_END__[1]; \
258 extern func_ptr __DTOR_LIST_SHR__[1], __DTOR_LIST_SHR_END__[1]; \
1d7fac3a
RS
259 for (p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__ ; p++ ) \
260 if (*p) (*p) (); \
98ee239e
RK
261 if (&__DTOR_LIST_SHR__[0] != &__DTOR_LIST__[1]) \
262 for (p = __DTOR_LIST_SHR__ + 1; p < __DTOR_LIST_SHR_END__ ; p++ ) \
263 if (*p) (*p) (); \
1d7fac3a
RS
264} while (0)
265
266#endif /* L__main */
328da75c
JL
267
268/* Specify the list of include file directories. */
269#define INCLUDE_DEFAULTS \
270{ \
271 { "GNU_GXX_INCLUDE:", "G++", 1, 1 }, \
272 { "GNU_CC_INCLUDE:", "GCC", 0, 0 }, /* GNU includes */ \
273 { "SYS$SYSROOT:[SYSLIB.]", 0, 0, 0 }, /* VAX-11 "C" includes */ \
274 { ".", 0, 0, 1 }, /* Make normal VMS filespecs work. */ \
275 { 0, 0, 0, 0 } \
276}