OSDN Git Service

Add new files.
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa64-hpux.h
1 /* Definitions of target machine for GNU compiler, for HPs running
2    HPUX using the 64bit runtime model.
3    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* We can debug dynamically linked executables on hpux11; we also
23    want dereferencing of a NULL pointer to cause a SEGV.  */
24 #undef LINK_SPEC
25 #define LINK_SPEC \
26   "-E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:-shared}"
27
28 /* Like the default, except no -lg.  */
29 #undef LIB_SPEC
30 #define LIB_SPEC \
31   "%{!shared:\
32      %{!p:\
33        %{!pg:\
34          %{!threads:-lc}\
35          %{threads:-lcma -lc_r}}\
36        %{p: -L/lib/libp/ -lc}\
37        %{pg: -L/lib/libp/ -lc}}} /usr/lib/pa20_64/milli.a"
38
39 /* Under hpux11, the normal location of the `ld' and `as' programs is the
40    /usr/ccs/bin directory.  */
41
42 #ifndef CROSS_COMPILE
43 #undef MD_EXEC_PREFIX
44 #define MD_EXEC_PREFIX "/opt/langtools/bin"
45 #endif
46
47 /* Under hpux11 the normal location of the various *crt*.o files is the
48    /usr/ccs/lib directory.  */
49
50 #ifndef CROSS_COMPILE
51 #undef MD_STARTFILE_PREFIX
52 #define MD_STARTFILE_PREFIX "/opt/langtools/lib/pa20_64/"
53 #endif
54
55 /* hpux11 has the new HP assembler.  It's still lousy, but it's a whole lot
56    better than the assembler shipped with older versions of hpux.  */
57 #undef NEW_HP_ASSEMBLER
58 #define NEW_HP_ASSEMBLER 1
59
60 #undef ASM_FILE_START
61 #define ASM_FILE_START(FILE) \
62 do {  \
63      if (TARGET_64BIT) \
64        fputs("\t.LEVEL 2.0w\n", FILE); \
65      else if (TARGET_PA_20) \
66        fputs("\t.LEVEL 2.0\n", FILE); \
67      else if (TARGET_PA_11) \
68        fputs("\t.LEVEL 1.1\n", FILE); \
69      else \
70        fputs("\t.LEVEL 1.0\n", FILE); \
71      if (profile_flag)\
72        fprintf (FILE, "\t.IMPORT _mcount, CODE\n");\
73      if (write_symbols != NO_DEBUG) \
74        output_file_directive ((FILE), main_input_filename); \
75    } while (0)
76
77 /* It looks like DWARF2 will be the easiest debug format to handle on this
78    platform.  */
79 #define OBJECT_FORMAT_ELF
80 #define DWARF2_DEBUGGING_INFO
81 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
82 /* This isn't quite ready yet.  I'm seeing it mess up some line
83    tables.  For example, we're getting lines starting/ending at
84    impossible addresses.  */
85 #define DWARF2_ASM_LINE_DEBUG_INFO 1
86
87
88 /* The rest of this file is copied from the generic svr4.h.  One day we
89    would like to simply include svr4.h instead of copying all these
90    definitions.  */
91
92 /* Support const sections and the ctors and dtors sections for g++.
93    Note that there appears to be two different ways to support const
94    sections at the moment.  You can either #define the symbol
95    READONLY_DATA_SECTION (giving it some code which switches to the
96    readonly data section) or else you can #define the symbols
97    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
98    SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
99
100 #define USE_CONST_SECTION       1
101
102 #define CONST_SECTION_ASM_OP    "\t.section\t.rodata"
103
104 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
105
106    Note that we want to give these sections the SHF_WRITE attribute
107    because these sections will actually contain data (i.e. tables of
108    addresses of functions in the current root executable or shared library
109    file) and, in the case of a shared library, the relocatable addresses
110    will have to be properly resolved/relocated (and then written into) by
111    the dynamic linker when it actually attaches the given shared library
112    to the executing process.  (Note that on SVR4, you may wish to use the
113    `-z text' option to the ELF linker, when building a shared library, as
114    an additional check that you are doing everything right.  But if you do
115    use the `-z text' option when building a shared library, you will get
116    errors unless the .ctors and .dtors sections are marked as writable
117    via the SHF_WRITE attribute.)  */
118
119 #define CTORS_SECTION_ASM_OP    "\t.section\t.ctors,\"aw\""
120 #define DTORS_SECTION_ASM_OP    "\t.section\t.dtors,\"aw\""
121
122 /* On svr4, we *do* have support for the .init and .fini sections, and we
123    can put stuff in there to be executed before and after `main'.  We let
124    crtstuff.c and other files know this by defining the following symbols.
125    The definitions say how to change sections to the .init and .fini
126    sections.  This is the same for all known svr4 assemblers.  */
127
128 /* ??? For the time being, we aren't using init sections. */
129 #if 0
130 #define INIT_SECTION_ASM_OP     "\t.section\t.init"
131 #define FINI_SECTION_ASM_OP     "\t.section\t.fini"
132 #endif
133
134 /* A default list of other sections which we might be "in" at any given
135    time.  For targets that use additional sections (e.g. .tdesc) you
136    should override this definition in the target-specific file which
137    includes this file.  */
138
139 #undef EXTRA_SECTIONS
140 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors
141
142 /* A default list of extra section function definitions.  For targets
143    that use additional sections (e.g. .tdesc) you should override this
144    definition in the target-specific file which includes this file.  */
145
146 #undef EXTRA_SECTION_FUNCTIONS
147 #define EXTRA_SECTION_FUNCTIONS                                         \
148   CONST_SECTION_FUNCTION                                                \
149   CTORS_SECTION_FUNCTION                                                \
150   DTORS_SECTION_FUNCTION
151
152 #define READONLY_DATA_SECTION() const_section ()
153
154 #define CONST_SECTION_FUNCTION                                          \
155 void                                                                    \
156 const_section ()                                                        \
157 {                                                                       \
158   if (!USE_CONST_SECTION)                                               \
159     text_section();                                                     \
160   else if (in_section != in_const)                                      \
161     {                                                                   \
162       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
163       in_section = in_const;                                            \
164     }                                                                   \
165 }
166
167 #define CTORS_SECTION_FUNCTION                                          \
168 void                                                                    \
169 ctors_section ()                                                        \
170 {                                                                       \
171   if (in_section != in_ctors)                                           \
172     {                                                                   \
173       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);             \
174       in_section = in_ctors;                                            \
175     }                                                                   \
176 }
177
178 #define DTORS_SECTION_FUNCTION                                          \
179 void                                                                    \
180 dtors_section ()                                                        \
181 {                                                                       \
182   if (in_section != in_dtors)                                           \
183     {                                                                   \
184       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);             \
185       in_section = in_dtors;                                            \
186     }                                                                   \
187 }
188
189 /* Switch into a generic section.
190  
191    We make the section read-only and executable for a function decl,
192    read-only for a const data decl, and writable for a non-const data decl.
193  
194    If the section has already been defined, we must not
195    emit the attributes here. The SVR4 assembler does not
196    recognize section redefinitions.
197    If DECL is NULL, no attributes are emitted.  */
198
199 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)                \
200   do                                                                    \
201     {                                                                   \
202       static htab_t htab;                                               \
203                                                                         \
204       struct section_info                                               \
205       {                                                                 \
206         enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type;              \
207       };                                                                \
208                                                                         \
209       struct section_info *s;                                           \
210       const char *mode;                                                 \
211       enum sect_enum type;                                              \
212       PTR* slot;                                                        \
213                                                                         \
214       /* The names we put in the hashtable will always be the unique    \
215          versions gived to us by the stringtable, so we can just use    \
216          their addresses as the keys.  */                               \
217       if (!htab)                                                        \
218         htab = htab_create (31,                                         \
219                             htab_hash_pointer,                          \
220                             htab_eq_pointer,                            \
221                             NULL);                                      \
222                                                                         \
223       if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                    \
224         type = SECT_EXEC, mode = "ax";                                  \
225       else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))             \
226         type = SECT_RO, mode = "a";                                     \
227       else                                                              \
228         type = SECT_RW, mode = "aw";                                    \
229                                                                         \
230                                                                         \
231       /* See if we already have an entry for this section.  */          \
232       slot = htab_find_slot (htab, NAME, INSERT);                       \
233       if (!*slot)                                                       \
234         {                                                               \
235           s = (struct section_info *) xmalloc (sizeof (* s));           \
236           s->type = type;                                               \
237           *slot = s;                                                    \
238           fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n",           \
239                    NAME, mode);                                         \
240         }                                                               \
241       else                                                              \
242         {                                                               \
243           s = (struct section_info *) *slot;                            \
244           if (DECL && s->type != type)                                  \
245             error_with_decl (DECL,                                      \
246                              "%s causes a section type conflict");      \
247                                                                         \
248           fprintf (FILE, "\t.section\t%s\n", NAME);                     \
249         }                                                               \
250     }                                                                   \
251   while (0)
252
253 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
254 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
255 #define UNIQUE_SECTION(DECL,RELOC)                              \
256 do {                                                            \
257   int len;                                                      \
258   char *name, *string, *prefix;                                 \
259                                                                 \
260   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));       \
261                                                                 \
262   if (! DECL_ONE_ONLY (DECL))                                   \
263     {                                                           \
264       prefix = ".";                                             \
265       if (TREE_CODE (DECL) == FUNCTION_DECL)                    \
266         prefix = ".text.";                                      \
267       else if (DECL_READONLY_SECTION (DECL, RELOC))             \
268         prefix = ".rodata.";                                    \
269       else                                                      \
270         prefix = ".data.";                                      \
271     }                                                           \
272   else if (TREE_CODE (DECL) == FUNCTION_DECL)                   \
273     prefix = ".gnu.linkonce.t.";                                \
274   else if (DECL_READONLY_SECTION (DECL, RELOC))                 \
275     prefix = ".gnu.linkonce.r.";                                \
276   else                                                          \
277     prefix = ".gnu.linkonce.d.";                                \
278                                                                 \
279   len = strlen (name) + strlen (prefix);                        \
280   string = alloca (len + 1);                                    \
281   sprintf (string, "%s%s", prefix, name);                       \
282                                                                 \
283   DECL_SECTION_NAME (DECL) = build_string (len, string);        \
284 } while (0)
285
286 #define INT_ASM_OP "\t.dword\t"
287 /* A C statement (sans semicolon) to output an element in the table of
288    global constructors.  */
289 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                               \
290   do {                                                                  \
291     ctors_section ();                                                   \
292     fprintf (FILE, "%sP%%", INT_ASM_OP);                                \
293     assemble_name (FILE, NAME);                                         \
294     fprintf (FILE, "\n");                                               \
295   } while (0)
296
297 /* A C statement (sans semicolon) to output an element in the table of
298    global destructors.  */
299 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
300   do {                                                                  \
301     dtors_section ();                                                   \
302     fprintf (FILE, "%sP%%", INT_ASM_OP);                                \
303     assemble_name (FILE, NAME);                                         \
304     fprintf (FILE, "\n");                                               \
305   } while (0)
306
307 /* ??? For the time being, we aren't using .ctors/.dtors sections. */
308 #undef ASM_OUTPUT_DESTRUCTOR
309 #undef ASM_OUTPUT_CONSTRUCTOR
310
311 /* Define the strings used for the special svr4 .type and .size directives.
312    These strings generally do not vary from one system running svr4 to
313    another, but if a given system (e.g. m88k running svr) needs to use
314    different pseudo-op names for these, they may be overridden in the
315    file which includes this one.  */
316
317 #define TYPE_ASM_OP     "\t.type\t"
318 #define SIZE_ASM_OP     "\t.size\t"
319
320 /* This is how we tell the assembler that a symbol is weak.  */
321
322 #define ASM_WEAKEN_LABEL(FILE,NAME) \
323   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
324        fputc ('\n', FILE); } while (0)
325
326 /* The following macro defines the format used to output the second
327    operand of the .type assembler directive.  Different svr4 assemblers
328    expect various different forms for this operand.  The one given here
329    is just a default.  You may need to override it in your machine-
330    specific tm.h file (depending upon the particulars of your assembler).  */
331
332 #define TYPE_OPERAND_FMT        "@%s"
333
334 /* Write the extra assembler code needed to declare a function's result.
335    Most svr4 assemblers don't require any special declaration of the
336    result value, but there are exceptions.  */
337
338 #ifndef ASM_DECLARE_RESULT
339 #define ASM_DECLARE_RESULT(FILE, RESULT)
340 #endif