OSDN Git Service

1682eda49dfefcd3986a48ea8429277f6031e354
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / sco5.h
1 /* Definitions for Intel 386 running SCO Unix System V 3.2 Version 5.
2    Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2002
3    Free Software Foundation, Inc.
4    Contributed by Kean Johnston (hug@netcom.com)
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 #define TARGET_VERSION fprintf (stderr, " (i386, SCO OpenServer 5 Syntax)");
24
25 #undef LPREFIX
26 #define LPREFIX                         ".L"
27
28 #undef ALIGN_ASM_OP
29 #define ALIGN_ASM_OP                    "\t.align\t"
30
31 #undef ASCII_DATA_ASM_OP
32 #define ASCII_DATA_ASM_OP               "\t.ascii\t"
33
34 #undef IDENT_ASM_OP
35 #define IDENT_ASM_OP                    "\t.ident\t"
36
37 #undef COMMON_ASM_OP
38 #define COMMON_ASM_OP                   "\t.comm\t"
39
40 #undef SET_ASM_OP
41 #define SET_ASM_OP                      "\t.set\t"
42
43 #undef LOCAL_ASM_OP
44 #define LOCAL_ASM_OP                    "\t.local\t"
45
46 #undef ASM_SHORT
47 #define ASM_SHORT                       "\t.value\t"
48
49 #undef ASM_LONG
50 #define ASM_LONG                        "\t.long\t"
51
52 #undef ASM_QUAD
53
54 #undef TYPE_ASM_OP
55 #define TYPE_ASM_OP                     "\t.type\t"
56
57 #undef SIZE_ASM_OP
58 #define SIZE_ASM_OP                     "\t.size\t"
59
60 #undef STRING_ASM_OP
61 #define STRING_ASM_OP                   "\t.string\t"
62
63 #undef SKIP_ASM_OP
64 #define SKIP_ASM_OP                     "\t.zero\t"
65
66 #undef GLOBAL_ASM_OP
67 #define GLOBAL_ASM_OP                   "\t.globl\t"
68
69 #undef EH_FRAME_SECTION_ASM_OP
70 #define EH_FRAME_SECTION_NAME_COFF      ".ehfram"
71 #define EH_FRAME_SECTION_NAME_ELF       ".eh_frame"
72 #define EH_FRAME_SECTION_NAME   \
73   ((TARGET_ELF) ? EH_FRAME_SECTION_NAME_ELF : EH_FRAME_SECTION_NAME_COFF)
74
75 /* Avoid problems (long sectino names, forward assembler refs) with DWARF
76    exception unwinding when we're generating COFF */
77 #define DWARF2_UNWIND_INFO      \
78   ((TARGET_ELF) ? 1 : 0 )  
79
80 #undef CONST_SECTION_ASM_OP
81 #define CONST_SECTION_ASM_OP_COFF       "\t.section\t.rodata, \"x\""
82 #define CONST_SECTION_ASM_OP_ELF        "\t.section\t.rodata"
83 #define CONST_SECTION_ASM_OP    \
84   ((TARGET_ELF) ? CONST_SECTION_ASM_OP_ELF : CONST_SECTION_ASM_OP_COFF)
85
86 #undef USE_CONST_SECTION
87 #define USE_CONST_SECTION_ELF           1
88 #define USE_CONST_SECTION_COFF          0
89 #define USE_CONST_SECTION       \
90  ((TARGET_ELF) ? USE_CONST_SECTION_ELF : USE_CONST_SECTION_COFF)
91
92 #undef INIT_SECTION_ASM_OP
93 #define INIT_SECTION_ASM_OP_ELF         "\t.section\t.init"
94 /* Rename these for COFF because crt1.o will try to run them.  */
95 #define INIT_SECTION_ASM_OP_COFF        "\t.section\t.ctor ,\"x\""
96 #define INIT_SECTION_ASM_OP     \
97   ((TARGET_ELF) ? INIT_SECTION_ASM_OP_ELF : INIT_SECTION_ASM_OP_COFF)
98
99 #undef CTORS_SECTION_ASM_OP
100 #define CTORS_SECTION_ASM_OP_ELF        "\t.section\t.ctors,\"aw\""
101 #define CTORS_SECTION_ASM_OP_COFF       INIT_SECTION_ASM_OP_COFF
102 #define CTORS_SECTION_ASM_OP    \
103  ((TARGET_ELF) ? CTORS_SECTION_ASM_OP_ELF : CTORS_SECTION_ASM_OP_COFF)
104
105 #undef DTORS_SECTION_ASM_OP
106 #define DTORS_SECTION_ASM_OP_ELF        "\t.section\t.dtors, \"aw\""
107 #define DTORS_SECTION_ASM_OP_COFF       FINI_SECTION_ASM_OP_COFF
108 #define DTORS_SECTION_ASM_OP    \
109  ((TARGET_ELF) ? DTORS_SECTION_ASM_OP_ELF : DTORS_SECTION_ASM_OP_COFF)
110
111 #undef FINI_SECTION_ASM_OP
112 #define FINI_SECTION_ASM_OP_ELF         "\t.section\t.fini"
113 #define FINI_SECTION_ASM_OP_COFF        "\t.section\t.dtor, \"x\""
114 #define FINI_SECTION_ASM_OP     \
115  ((TARGET_ELF) ? FINI_SECTION_ASM_OP_ELF : FINI_SECTION_ASM_OP_COFF)
116
117 #undef BSS_SECTION_ASM_OP
118 #define BSS_SECTION_ASM_OP              "\t.data"
119
120 #undef TEXT_SECTION_ASM_OP
121 #define TEXT_SECTION_ASM_OP             "\t.text"
122
123 #undef DATA_SECTION_ASM_OP
124 #define DATA_SECTION_ASM_OP             "\t.data"
125
126 #undef TYPE_OPERAND_FMT
127 #define TYPE_OPERAND_FMT                "@%s"
128
129 #undef APPLY_RESULT_SIZE
130 #define APPLY_RESULT_SIZE                                               \
131 (TARGET_ELF) ? size : 116
132
133 #ifndef ASM_DECLARE_RESULT
134 #define ASM_DECLARE_RESULT(FILE, RESULT)
135 #endif
136
137 #define SCO_DEFAULT_ASM_COFF(FILE,NAME)                                 \
138 do {                                                                    \
139       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
140   } while (0)
141
142 #undef ASM_DECLARE_FUNCTION_NAME
143 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
144   do {                                                                  \
145     if (TARGET_ELF) {                                                   \
146       fprintf (FILE, "%s", TYPE_ASM_OP);                                \
147       assemble_name (FILE, NAME);                                       \
148       putc (',', FILE);                                                 \
149       fprintf (FILE, TYPE_OPERAND_FMT, "function");                     \
150       putc ('\n', FILE);                                                \
151       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                    \
152       ASM_OUTPUT_LABEL(FILE, NAME);                                     \
153     } else                                                              \
154       SCO_DEFAULT_ASM_COFF(FILE, NAME);                                 \
155 } while (0)
156
157 #undef ASM_DECLARE_FUNCTION_SIZE
158 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
159   do {                                                                  \
160     if (TARGET_ELF) { if (!flag_inhibit_size_directive)                 \
161       {                                                                 \
162         fprintf (FILE, "%s", SIZE_ASM_OP);                              \
163         assemble_name (FILE, (FNAME));                                  \
164         fprintf (FILE, ",.-");                                          \
165         assemble_name (FILE, (FNAME));                                  \
166         putc ('\n', FILE);                                              \
167       } }                                                               \
168   } while (0)
169
170 #undef ASM_DECLARE_OBJECT_NAME
171 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
172   do {                                                                  \
173     if (TARGET_ELF) {                                                   \
174       fprintf (FILE, "%s", TYPE_ASM_OP);                                \
175       assemble_name (FILE, NAME);                                       \
176       putc (',', FILE);                                                 \
177       fprintf (FILE, TYPE_OPERAND_FMT, "object");                       \
178       putc ('\n', FILE);                                                \
179       size_directive_output = 0;                                        \
180       if (!flag_inhibit_size_directive && DECL_SIZE (DECL))             \
181         {                                                               \
182         size_directive_output = 1;                                      \
183         fprintf (FILE, "%s", SIZE_ASM_OP);                              \
184         assemble_name (FILE, NAME);                                     \
185         fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
186         }                                                               \
187       ASM_OUTPUT_LABEL(FILE, NAME);                                     \
188     } else                                                              \
189       SCO_DEFAULT_ASM_COFF(FILE, NAME);                                 \
190   } while (0)
191
192 #undef ASM_FILE_START_1
193 #define ASM_FILE_START_1(FILE)
194
195 #undef ASM_FILE_START
196 #define ASM_FILE_START(FILE)                                            \
197 do {                                                                    \
198   output_file_directive((FILE),main_input_filename);                    \
199   fprintf ((FILE), "\t.version\t\"01.01\"\n");                          \
200 } while (0)
201
202 #undef ASM_FINISH_DECLARE_OBJECT
203 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
204 do {                                                                     \
205   if (TARGET_ELF) {                                                     \
206      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);             \
207      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)                \
208          && ! AT_END && TOP_LEVEL                                        \
209          && DECL_INITIAL (DECL) == error_mark_node                       \
210          && !size_directive_output)                                      \
211        {                                                                 \
212          size_directive_output = 1;                                      \
213          fprintf (FILE, "%s", SIZE_ASM_OP);                              \
214          assemble_name (FILE, name);                                     \
215          fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
216        }                                                                 \
217     }                                                                    \
218 } while (0)
219
220 #undef ASM_GENERATE_INTERNAL_LABEL
221 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)                 \
222 do {                                                                    \
223   if (TARGET_ELF)                                                       \
224     sprintf (LABEL, "*.%s%ld", (PREFIX), (long)(NUM));                  \
225   else                                                                  \
226     sprintf (LABEL, ".%s%ld", (PREFIX), (long)(NUM));                   \
227 } while (0)
228
229 #undef ASM_OUTPUT_ALIGNED_COMMON
230 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)              \
231 do {                                                                    \
232   fprintf ((FILE), "%s", COMMON_ASM_OP);                                \
233   assemble_name ((FILE), (NAME));                                       \
234   if (TARGET_ELF)                                                       \
235     fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);      \
236   else                                                                  \
237     fprintf ((FILE), ",%u\n", (SIZE));                                  \
238 } while (0)
239
240 #undef ASM_OUTPUT_ALIGNED_LOCAL
241 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
242 do {                                                                    \
243   if (TARGET_ELF) {                                                     \
244     fprintf ((FILE), "%s", LOCAL_ASM_OP);                               \
245     assemble_name ((FILE), (NAME));                                     \
246     fprintf ((FILE), "\n");                                             \
247     ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                \
248   } else {                                                              \
249     int align = exact_log2 (ALIGN);                                     \
250     if (align > 2) align = 2;                                           \
251     if (TARGET_SVR3_SHLIB)                                              \
252       data_section ();                                                  \
253     else                                                                \
254       bss_section ();                                                   \
255     ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align);                 \
256     fprintf ((FILE), "%s\t", "\t.lcomm");                               \
257     assemble_name ((FILE), (NAME));                                     \
258     fprintf ((FILE), ",%u\n", (SIZE));                                  \
259    }                                                                    \
260 } while (0)
261
262 /* A C statement (sans semicolon) to output to the stdio stream
263    FILE the assembler definition of uninitialized global DECL named
264    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
265    Try to use asm_output_aligned_bss to implement this macro.  */
266
267 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
268 asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
269
270 #undef ESCAPES
271 #define ESCAPES \
272 "\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
273 \0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
274 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
275 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
276 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
277 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
278 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
279 \1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
280
281 #undef STRING_LIMIT
282 #define STRING_LIMIT    ((unsigned) 256)
283
284 #undef ASM_OUTPUT_LIMITED_STRING
285 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)                            \
286   do                                                                    \
287     {                                                                   \
288       register const unsigned char *_limited_str =                      \
289         (const unsigned char *) (STR);                                  \
290       register unsigned ch;                                             \
291       fprintf ((FILE), "%s\"", STRING_ASM_OP);                          \
292       for (; (ch = *_limited_str); _limited_str++)                      \
293         {                                                               \
294           register int escape;                                          \
295           switch (escape = ESCAPES[ch])                                 \
296             {                                                           \
297             case 0:                                                     \
298               putc (ch, (FILE));                                        \
299               break;                                                    \
300             case 1:                                                     \
301               fprintf ((FILE), "\\%03o", ch);                           \
302               break;                                                    \
303             default:                                                    \
304               putc ('\\', (FILE));                                      \
305               putc (escape, (FILE));                                    \
306               break;                                                    \
307             }                                                           \
308         }                                                               \
309       fprintf ((FILE), "\"\n");                                         \
310     }                                                                   \
311   while (0)
312
313
314 #undef ASM_OUTPUT_ASCII
315 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)                             \
316 do {                                                                    \
317       register const unsigned char *_ascii_bytes =                      \
318         (const unsigned char *) (STR);                                  \
319       register const unsigned char *limit = _ascii_bytes + (LENGTH);    \
320       register unsigned bytes_in_chunk = 0;                             \
321       for (; _ascii_bytes < limit; _ascii_bytes++)                      \
322         {                                                               \
323           register unsigned const char *p;                              \
324           if (bytes_in_chunk >= 64)                                     \
325             {                                                           \
326               fputc ('\n', (FILE));                                     \
327               bytes_in_chunk = 0;                                       \
328             }                                                           \
329           for (p = _ascii_bytes; p < limit && *p != '\0'; p++)          \
330             continue;                                                   \
331           if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT)   \
332             {                                                           \
333               if (bytes_in_chunk > 0)                                   \
334                 {                                                       \
335                   fputc ('\n', (FILE));                                 \
336                   bytes_in_chunk = 0;                                   \
337                 }                                                       \
338               ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);         \
339               _ascii_bytes = p;                                         \
340             }                                                           \
341           else                                                          \
342             {                                                           \
343               if (bytes_in_chunk == 0)                                  \
344                 fputs ("\t.byte\t", (FILE));                            \
345               else                                                      \
346                 fputc (',', (FILE));                                    \
347               fprintf ((FILE), "0x%02x", *_ascii_bytes);                \
348               bytes_in_chunk += 5;                                      \
349             }                                                           \
350         }                                                               \
351       if (bytes_in_chunk > 0)                                           \
352         fprintf ((FILE), "\n");                                         \
353 } while (0) 
354
355 /* Must use data section for relocatable constants when pic.  */
356 #undef SELECT_RTX_SECTION
357 #define SELECT_RTX_SECTION(MODE,RTX,ALIGN)                              \
358 {                                                                       \
359   if (TARGET_ELF) {                                                     \
360     if (flag_pic && symbolic_operand (RTX, VOIDmode))                   \
361       data_section ();                                                  \
362     else                                                                \
363       const_section ();                                                 \
364   } else                                                                \
365     readonly_data_section();                                            \
366 }
367
368 #undef ASM_OUTPUT_CASE_LABEL
369 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE)                \
370 do {                                                                    \
371   if (TARGET_ELF)                                                       \
372     ASM_OUTPUT_ALIGN ((FILE), 2);                                       \
373   ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM));                     \
374 } while (0)
375
376 #undef ASM_OUTPUT_IDENT
377 #define ASM_OUTPUT_IDENT(FILE, NAME) \
378   fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
379
380 #undef ASM_GLOBALIZE_LABEL
381 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
382   (fprintf ((FILE), "%s", GLOBAL_ASM_OP), assemble_name (FILE, NAME), fputs ("\n", FILE))
383
384 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
385 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)                          \
386   if (TARGET_ELF) ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
387
388 #undef ASM_OUTPUT_INTERNAL_LABEL
389 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)                      \
390   fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
391
392 /* The prefix to add to user-visible assembler symbols.  */
393
394 #undef USER_LABEL_PREFIX
395 #define USER_LABEL_PREFIX ""
396
397 /* 
398  * We rename 'gcc_except_table' to the shorter name in preparation
399  * for the day when we're ready to do DWARF2 eh unwinding under COFF.
400  */
401 /* #define EXCEPTION_SECTION()          named_section (NULL, ".gccexc", 1) */
402
403 /* Switch into a generic section.  */
404 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section 
405
406 #undef ASM_OUTPUT_SKIP
407 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
408 do {                                                                    \
409   if (TARGET_ELF)                                                       \
410     fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE));                      \
411   else                                                                  \
412     fprintf ((FILE), "%s.,.+%u\n", SET_ASM_OP, (SIZE));         \
413 } while (0)
414
415
416 #undef CTOR_LIST_BEGIN
417 #define CTOR_LIST_BEGIN                                                 \
418 do {                                                                    \
419   asm (CTORS_SECTION_ASM_OP);                                           \
420   if (TARGET_ELF)                                                       \
421     STATIC func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) };             \
422   else                                                                  \
423     asm ("pushl $0");                                                   \
424 } while (0)
425
426 #undef CTOR_LIST_END
427 #define CTOR_LIST_END                                                   \
428 do {                                                                    \
429   if (TARGET_ELF) {                                                     \
430     asm (CTORS_SECTION_ASM_OP);                                         \
431     STATIC func_ptr __CTOR_LIST__[1] = { (func_ptr) (0) };              \
432   } else {                                                              \
433     CTOR_LIST_BEGIN;                                                    \
434   }                                                                     \
435 } while (0)
436
437 #undef DBX_BLOCKS_FUNCTION_RELATIVE
438 #define DBX_BLOCKS_FUNCTION_RELATIVE 1
439
440 #undef DBX_FUNCTION_FIRST
441 #define DBX_FUNCTION_FIRST 1
442
443 #undef DBX_REGISTER_NUMBER
444 #define DBX_REGISTER_NUMBER(n) \
445   ((TARGET_ELF) ? svr4_dbx_register_map[n] : dbx_register_map[n])
446
447 #undef DWARF2_DEBUGGING_INFO
448 #undef DWARF_DEBUGGING_INFO
449 #undef SDB_DEBUGGING_INFO
450 #undef DBX_DEBUGGING_INFO
451 #undef PREFERRED_DEBUGGING_TYPE
452
453 #define DWARF2_DEBUGGING_INFO 1
454 #define DWARF_DEBUGGING_INFO 1
455 #define SDB_DEBUGGING_INFO   1
456 #define DBX_DEBUGGING_INFO   1
457 #define PREFERRED_DEBUGGING_TYPE                                        \
458   ((TARGET_ELF) ? DWARF2_DEBUG: SDB_DEBUG)
459
460 #undef EXTRA_SECTIONS
461 #define EXTRA_SECTIONS in_const, in_init, in_fini
462
463 #undef EXTRA_SECTION_FUNCTIONS
464 #define EXTRA_SECTION_FUNCTIONS                                         \
465   CONST_SECTION_FUNCTION                                                \
466   INIT_SECTION_FUNCTION                                                 \
467   FINI_SECTION_FUNCTION
468
469 #undef CONST_SECTION_FUNCTION
470 #define CONST_SECTION_FUNCTION                                          \
471 void                                                                    \
472 const_section ()                                                        \
473 {                                                                       \
474   if (!USE_CONST_SECTION)                                               \
475     text_section();                                                     \
476   else if (in_section != in_const)                                      \
477     {                                                                   \
478       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
479       in_section = in_const;                                            \
480     }                                                                   \
481 }
482
483 #undef FINI_SECTION_FUNCTION
484 #define FINI_SECTION_FUNCTION                                           \
485 void                                                                    \
486 fini_section ()                                                         \
487 {                                                                       \
488   if ((!TARGET_ELF) && in_section != in_fini)                           \
489     {                                                                   \
490       fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP);              \
491       in_section = in_fini;                                             \
492     }                                                                   \
493 }
494
495 #undef INIT_SECTION_FUNCTION
496 #define INIT_SECTION_FUNCTION                                           \
497 void                                                                    \
498 init_section ()                                                         \
499 {                                                                       \
500   if ((!TARGET_ELF) && in_section != in_init)                           \
501     {                                                                   \
502       fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP);              \
503       in_section = in_init;                                             \
504     }                                                                   \
505 }
506
507 #undef SUBTARGET_FRAME_POINTER_REQUIRED
508 #define SUBTARGET_FRAME_POINTER_REQUIRED                                \
509   ((TARGET_ELF) ? 0 :                                                   \
510    (current_function_calls_setjmp || current_function_calls_longjmp))
511
512 #undef LOCAL_LABEL_PREFIX
513 #define LOCAL_LABEL_PREFIX                                              \
514  ((TARGET_ELF) ? "" : ".")
515
516 #undef MD_EXEC_PREFIX
517 #undef MD_STARTFILE_PREFIX
518 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
519 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
520
521 #undef NON_SAVING_SETJMP
522 #define NON_SAVING_SETJMP                                               \
523   ((TARGET_ELF) ? 0 :                                                   \
524    (current_function_calls_setjmp && current_function_calls_longjmp))
525
526 #undef NO_IMPLICIT_EXTERN_C
527 #define NO_IMPLICIT_EXTERN_C 1
528
529 /* JKJ FIXME - examine the ramifications of RETURN_IN_MEMORY and
530    RETURN_POPS_ARGS */
531
532 #undef RETURN_POPS_ARGS
533 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)                          \
534  ((TARGET_ELF) ?                                                        \
535   (ix86_return_pops_args (FUNDECL, FUNTYPE, SIZE)) :                    \
536   (((FUNDECL) && (TREE_CODE (FUNDECL) == IDENTIFIER_NODE)) ? 0          \
537    : (TARGET_RTD                                                        \
538       && (TYPE_ARG_TYPES (FUNTYPE) == 0                                 \
539           || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE)))         \
540               == void_type_node))) ? (SIZE)                             \
541    : 0))
542
543 #undef SELECT_SECTION
544 #define SELECT_SECTION(DECL,RELOC,ALIGN)                                \
545 {                                                                       \
546   if (TARGET_ELF && flag_pic && RELOC)                                  \
547      data_section ();                                                   \
548   else if (TREE_CODE (DECL) == STRING_CST)                              \
549     {                                                                   \
550       if (! flag_writable_strings)                                      \
551         const_section ();                                               \
552       else                                                              \
553         data_section ();                                                \
554     }                                                                   \
555   else if (TREE_CODE (DECL) == VAR_DECL)                                \
556     {                                                                   \
557       if (! DECL_READONLY_SECTION (DECL, RELOC))                        \
558         data_section ();                                                \
559       else                                                              \
560         const_section ();                                               \
561     }                                                                   \
562   else                                                                  \
563     const_section ();                                                   \
564 }
565
566 #undef SWITCH_TAKES_ARG
567 #define SWITCH_TAKES_ARG(CHAR)                                          \
568   (DEFAULT_SWITCH_TAKES_ARG(CHAR)                                       \
569    || (CHAR) == 'h'                                                     \
570    || (CHAR) == 'R'                                                     \
571    || (CHAR) == 'Y'                                                     \
572    || (CHAR) == 'z')
573
574 #undef WORD_SWITCH_TAKES_ARG
575 #define WORD_SWITCH_TAKES_ARG(STR)                                      \
576  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                                   \
577   && strcmp (STR, "Tdata") && strcmp (STR, "Ttext")                     \
578   && strcmp (STR, "Tbss"))
579
580 #undef TARGET_SUBTARGET_DEFAULT
581 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS)
582
583 #undef HANDLE_SYSV_PRAGMA
584 #define HANDLE_SYSV_PRAGMA 1
585
586 /* Though OpenServer supports .weak in COFF, we don't use it.
587  * G++ will frequently emit a symol as .weak and then (in the same .s 
588  * file) declare it global.   The COFF assembler finds this unamusing.
589  */
590 #define SUPPORTS_WEAK (TARGET_ELF)
591 #define ASM_WEAKEN_LABEL(FILE,NAME) \
592   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME);           \
593         fputc ('\n', FILE); } while (0)
594
595 #undef SCCS_DIRECTIVE
596 #define SCCS_DIRECTIVE 1
597
598 /*
599  * Define sizes and types
600  */
601 #undef SIZE_TYPE
602 #undef PTRDIFF_TYPE
603 #undef WCHAR_TYPE
604 #undef WCHAR_TYPE_SIZE
605 #undef LONG_DOUBLE_TYPE_SIZE
606 #define LONG_DOUBLE_TYPE_SIZE   96
607 #define SIZE_TYPE               "unsigned int"
608 #define PTRDIFF_TYPE            "int"
609 #define WCHAR_TYPE              "long int"
610 #define WCHAR_TYPE_SIZE         BITS_PER_WORD
611
612 /*
613  * New for multilib support. Set the default switches for multilib,
614  * which is -melf.
615  */
616 #define MULTILIB_DEFAULTS { "melf" }
617
618 \f
619 /* Please note that these specs may look messy but they are required in
620    order to emulate the SCO Development system as closely as possible.
621    With SCO Open Server 5.0, you now get the linker and assembler free,
622    so that is what these specs are targeted for. These utilities are
623    very argument sensitive: a space in the wrong place breaks everything.
624    So RMS, please forgive this mess. It works.
625
626    Parameters which can be passed to gcc, and their SCO equivalents:
627    GCC Parameter                SCO Equivalent
628    -ansi                        -a ansi
629    -posix                       -a posix
630    -Xpg4                        -a xpg4
631    -Xpg4plus                    -a xpg4plus
632    -Xods30                      -a ods30
633
634    As with SCO, the default is XPG4 plus mode. SCO also allows you to
635    specify a C dialect with -Xt, -Xa, -Xc, -Xk and -Xm. These are passed
636    on to the assembler and linker in the same way that the SCO compiler
637    does.
638
639    SCO also allows you to compile, link and generate either ELF or COFF
640    binaries. With gcc, unlike the SCO compiler, the default is ELF.
641    Specify -mcoff to gcc to produce COFF binaries. -fpic will get the
642    assembler and linker to produce PIC code.
643 */
644
645 /* Set up assembler flags for PIC and ELF compilations */
646 #undef ASM_SPEC
647
648 #if USE_GAS
649   /* Leave ASM_SPEC undefined so we pick up the master copy from gcc.c 
650    * Undef MD_EXEC_PREFIX because we don't know where GAS is, but it's not
651    * likely in /usr/ccs/bin/ 
652    */
653 #undef MD_EXEC_PREFIX 
654 #else
655
656 #define ASM_SPEC \
657    "-b %{!mcoff:elf}%{mcoff:coff \
658      %{static:%e-static not valid with -mcoff} \
659      %{shared:%e-shared not valid with -mcoff} \
660      %{symbolic:%e-symbolic not valid with -mcoff}} \
661     %{Ym,*} %{Yd,*} %{Wa,*:%*} \
662     %{!mcoff:-E%{Xa:a}%{!Xa:%{Xc:c}%{!Xc:%{Xk:k}%{!Xk:%{Xt:t}%{!Xt:a}}}},%{ansi:ansi}%{!ansi:%{posix:posix}%{!posix:%{Xpg4:xpg4}%{!Xpg4:%{Xpg4plus:XPG4PLUS}%{!Xpg4plus:%{Xods30:ods30}%{!Xods30:XPG4PLUS}}}}},ELF %{Qn:} %{!Qy:-Qn}}"
663 #endif
664
665 /* Use crt1.o as a startup file and crtn.o as a closing file.  */
666
667 #undef STARTFILE_SPEC
668 #define STARTFILE_SPEC \
669  "%{shared: %{!mcoff: crti.o%s}} \
670   %{!shared:\
671    %{!symbolic: \
672     %{pg:gcrt.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}} \
673   %{ansi:values-Xc.o%s} \
674   %{!ansi: \
675    %{Xa:values-Xa.o%s} \
676     %{!Xa:%{Xc:values-Xc.o%s} \
677      %{!Xc:%{Xk:values-Xk.o%s} \
678       %{!Xk:%{Xt:values-Xt.o%s} \
679        %{!Xt:values-Xa.o%s}}}}} \
680   %{mcoff:crtbeginS.o%s} %{!mcoff:crtbegin.o%s}"
681
682 #undef ENDFILE_SPEC
683 #define ENDFILE_SPEC \
684  "%{!mcoff:crtend.o%s} \
685   %{mcoff:crtendS.o%s} \
686   %{pg:gcrtn.o%s}%{!pg:crtn.o%s}"
687
688 #undef CPP_PREDEFINES
689 #define CPP_PREDEFINES \
690  "-Asystem=svr3"
691
692 /* You are in a maze of GCC specs ... all alike */
693
694 #undef CPP_SPEC
695 #define CPP_SPEC "%(cpp_cpu) \
696   %{fpic:%{mcoff:%e-fpic is not valid with -mcoff}} \
697   %{fPIC:%{mcoff:%e-fPIC is not valid with -mcoff}} \
698   -D__i386 -D__unix -D_SCO_DS=1 -D_M_I386 -D_M_XENIX -D_M_UNIX \
699   %{!Xods30:-D_STRICT_NAMES} \
700   %{!ansi:%{!posix:%{!Xods30:-D_SCO_XPG_VERS=4}}} \
701   %{ansi:-isystem include/ansi%s -isystem /usr/include/ansi -D_STRICT_ANSI} \
702   %{!ansi: \
703    %{posix:-isystem include/posix%s -isystem /usr/include/posix \
704            -D_POSIX_C_SOURCE=2 -D_POSIX_SOURCE=1} \
705     %{!posix:%{Xpg4:-isystem include/xpg4%s -isystem /usr/include/xpg4 \
706                     -D_XOPEN_SOURCE=1} \
707      %{!Xpg4:-D_M_I86 -D_M_I86SM -D_M_INTERNAT -D_M_SDATA -D_M_STEXT \
708              -D_M_BITFIELDS -D_M_SYS5 -D_M_SYSV -D_M_SYSIII \
709              -D_M_WORDSWAP -Dunix -DM_I386 -DM_UNIX -DM_XENIX \
710              %{Xods30:-isystem include/ods_30_compat%s \
711                       -isystem /usr/include/ods_30_compat \
712                       -D_SCO_ODS_30 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \
713                       -DM_BITFIELDS -DM_SYS5 -DM_SYSV -DM_INTERNAT -DM_SYSIII \
714                       -DM_WORDSWAP}}}} \
715   %{scointl:-DM_INTERNAT -D_M_INTERNAT} \
716   %{!mcoff:-D_SCO_ELF} \
717   %{mcoff:-D_M_COFF -D_SCO_COFF} \
718   %{!mcoff:%{fpic:-D__PIC__ -D__pic__} \
719          %{fPIC:%{!fpic:-D__PIC__ -D__pic__}}} \
720   %{Xa:-D_SCO_C_DIALECT=1} \
721   %{!Xa:%{Xc:-D_SCO_C_DIALECT=3} \
722    %{!Xc:%{Xk:-D_SCO_C_DIALECT=4} \
723     %{!Xk:%{Xt:-D_SCO_C_DIALECT=2} \
724      %{!Xt:-D_SCO_C_DIALECT=1}}}}"
725
726 #undef LINK_SPEC
727 #define LINK_SPEC \
728  "-b %{!mcoff:elf}%{mcoff:coff \
729    %{static:%e-static not valid with -mcoff} \
730    %{shared:%e-shared not valid with -mcoff} \
731    %{symbolic:%e-symbolic not valid with -mcoff} \
732    %{fpic:%e-fpic not valid with -mcoff} \
733    %{fPIC:%e-fPIC not valid with -mcoff}} \
734   -R%{Xa:a}%{!Xa:%{Xc:c}%{!Xc:%{Xk:k}%{!Xk:%{Xt:t}%{!Xt:a}}}},%{ansi:ansi}%{!ansi:%{posix:posix}%{!posix:%{Xpg4:xpg4}%{!Xpg4:%{Xpg4plus:XPG4PLUS}%{!Xpg4plus:%{Xods30:ods30}%{!Xods30:XPG4PLUS}}}}},%{mcoff:COFF}%{!mcoff:ELF} \
735   %{Wl,*%*} %{YP,*} %{YL,*} %{YU,*} \
736   %{!YP,*:%{p:-YP,/usr/ccs/libp:/lib/libp:/usr/lib/libp:/usr/ccs/lib:/lib:/usr/lib} \
737    %{!p:-YP,/usr/ccs/lib:/lib:/usr/lib}} \
738   %{h*} %{static:-dn -Bstatic} %{shared:-G -dy %{!z*:-z text}} \
739   %{symbolic:-Bsymbolic -G -dy %{!z*:-z text}} %{z*} %{R*} %{Y*} \
740   %{G:-G} %{!mcoff:%{Qn:} %{!Qy:-Qn}}"
741
742 /* The SCO COFF linker gets confused on the difference between "-ofoo"
743    and "-o foo".   So we just always force a single space.  */
744
745 #define SWITCHES_NEED_SPACES "o"
746
747 /* Library spec. If we are not building a shared library, provide the
748    standard libraries, as per the SCO compiler.  */
749
750 #undef LIB_SPEC
751 #define LIB_SPEC \
752  "%{shared:pic/libgcc.a%s}%{!shared:%{!symbolic:-lcrypt -lgen -lc}}"
753
754 #undef LIBGCC_SPEC
755 #define LIBGCC_SPEC \
756  "%{!shared:-lgcc}"
757
758 #define MASK_COFF               010000000000    /* Mask for elf generation */
759 #define TARGET_ELF              (1) /* (!(target_flags & MASK_COFF)) */
760
761 #undef SUBTARGET_SWITCHES
762 #define SUBTARGET_SWITCHES                                      \
763         { "elf", -MASK_COFF, N_("Generate ELF output")  },
764
765 #define NO_DOLLAR_IN_LABEL
766
767 /* Implicit library calls should use memcpy, not bcopy, etc.  They are 
768    faster on OpenServer libraries.  */
769
770 #define TARGET_MEM_FUNCTIONS
771
772 /* Biggest alignment supported by the object file format of this
773    machine.  Use this macro to limit the alignment which can be
774    specified using the `__attribute__ ((aligned (N)))' construct.  If
775    not defined, the default value is `BIGGEST_ALIGNMENT'.  */
776
777 #define MAX_OFILE_ALIGNMENT (32768*8)
778
779 /* Define the `__builtin_va_list' type for the ABI.  On OpenServer, this
780    type is `char *'.  */
781 #undef BUILD_VA_LIST_TYPE
782 #define BUILD_VA_LIST_TYPE(VALIST) \
783   (VALIST) = build_pointer_type (char_type_node)
784
785
786 /*
787 Here comes some major hackery to get the crt stuff to compile properly.
788 Since we can (and do) compile for both COFF and ELF environments, we
789 set things up accordingly, based on the pre-processor defines for ELF
790 and COFF. This is insane, but then I guess having one compiler with a
791 single back-end supporting two vastly different file format types is
792 a little insane too. But it is not impossible and we get a useful
793 compiler at the end of the day. Onward we go ...
794 */
795
796 #if defined(CRT_BEGIN) || defined(CRT_END) || defined(IN_LIBGCC2)
797 # undef OBJECT_FORMAT_ELF
798 # undef INIT_SECTION_ASM_OP
799 # undef FINI_SECTION_ASM_OP
800 # undef CTORS_SECTION_ASM_OP
801 # undef DTORS_SECTION_ASM_OP
802 # undef EH_FRAME_SECTION_NAME
803 # undef CTOR_LIST_BEGIN
804 # undef CTOR_LIST_END
805 # undef DO_GLOBAL_CTORS_BODY
806
807 # if defined (_SCO_ELF)
808 #  define OBJECT_FORMAT_ELF
809 #  define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_ELF
810 #  define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_ELF
811 #  define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_ELF
812 #  define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_ELF
813 #  define EH_FRAME_SECTION_NAME EH_FRAME_SECTION_NAME_ELF
814 # else /* ! _SCO_ELF */
815 #  define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_COFF
816 #  define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_COFF
817 #  define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_COFF
818 #  define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_COFF
819 #  define EH_FRAME_SECTION_NAME EH_FRAME_SECTION_NAME_COFF
820 #  define CTOR_LIST_BEGIN asm (INIT_SECTION_ASM_OP); asm ("pushl $0")
821 #  define CTOR_LIST_END CTOR_LIST_BEGIN
822 #  define DO_GLOBAL_CTORS_BODY                                          \
823 do {                                                                    \
824      func_ptr *p, *beg = alloca(0);                                     \
825      for (p = beg; *p;)                                                 \
826       (*p++) ();                                                        \
827 } while (0)
828 # endif /* ! _SCO_ELF */
829 #endif /* CRT_BEGIN !! CRT_END */
830
831 /* Handle special EH pointer encodings.  Absolute, pc-relative, and
832    indirect are handled automatically.  */
833 #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
834   do {                                                                  \
835     if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)         \
836       {                                                                 \
837         fputs (ASM_LONG, FILE);                                         \
838         assemble_name (FILE, XSTR (ADDR, 0));                           \
839         fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
840         goto DONE;                                                      \
841       }                                                                 \
842   } while (0)
843
844 /* Used by crtstuff.c to initialize the base of data-relative relocations.
845    These are GOT relative on x86, so return the pic register.  */
846 #ifdef __PIC__
847 #define CRT_GET_RFIB_DATA(BASE)                 \
848   {                                             \
849     register void *ebx_ __asm__("ebx");         \
850     BASE = ebx_;                                \
851   }
852 #else
853 #define CRT_GET_RFIB_DATA(BASE)                                         \
854   __asm__ ("call\t.LPR%=\n"                                             \
855            ".LPR%=:\n\t"                                                \
856            "popl\t%0\n\t"                                               \
857            /* Due to a GAS bug, this cannot use EAX.  That encodes      \
858               smaller than the traditional EBX, which results in the    \
859               offset being off by one.  */                              \
860            "addl\t$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"                 \
861            : "=d"(BASE))
862 #endif
863
864 /* Select a format to encode pointers in exception handling data.  CODE
865    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
866    true if the symbol may be affected by dynamic relocations.  */
867 #undef ASM_PREFERRED_EH_DATA_FORMAT
868 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)                       \
869   (flag_pic ? (GLOBAL ? DW_EH_PE_indirect : 0) | DW_EH_PE_datarel       \
870    : DW_EH_PE_absptr)