OSDN Git Service

a074914fa140882f6305ecf319f04275ba4534a3
[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 Free Software Foundation, Inc.
3    Contributed by Kean Johnston (hug@netcom.com)
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 #include "i386/i386.h"  /* Base i386 target definitions */
23 #include "i386/att.h"   /* Use AT&T i386 assembler syntax */
24
25 #undef TARGET_VERSION
26 #define TARGET_VERSION fprintf (stderr, " (i386, SCO OpenServer 5 Syntax)");
27
28 #undef LPREFIX
29 #define LPREFIX                         ".L"
30
31 #undef ALIGN_ASM_OP
32 #define ALIGN_ASM_OP                    "\t.align"
33
34 #undef ASCII_DATA_ASM_OP
35 #define ASCII_DATA_ASM_OP               "\t.ascii"
36
37 #undef ASM_BYTE_OP
38 #define ASM_BYTE_OP                     "\t.byte"
39
40 #undef IDENT_ASM_OP
41 #define IDENT_ASM_OP                    "\t.ident"
42
43 #undef COMMON_ASM_OP
44 #define COMMON_ASM_OP                   "\t.comm"
45
46 #undef SET_ASM_OP
47 #define SET_ASM_OP                      "\t.set"
48
49 #undef LOCAL_ASM_OP
50 #define LOCAL_ASM_OP                    "\t.local"
51
52 #undef INT_ASM_OP
53 #define INT_ASM_OP                      "\t.long"
54
55 #undef ASM_SHORT
56 #define ASM_SHORT                       "\t.value"
57
58 #undef ASM_LONG
59 #define ASM_LONG                        "\t.long"
60
61 #undef ASM_DOUBLE
62 #define ASM_DOUBLE                      "\t.double"
63
64 #undef TYPE_ASM_OP
65 #define TYPE_ASM_OP                     "\t.type"
66
67 #undef SIZE_ASM_OP
68 #define SIZE_ASM_OP                     "\t.size"
69
70 #undef STRING_ASM_OP
71 #define STRING_ASM_OP                   "\t.string"
72
73 #undef SKIP_ASM_OP
74 #define SKIP_ASM_OP                     "\t.zero"
75
76 #undef GLOBAL_ASM_OP
77 #define GLOBAL_ASM_OP                   "\t.globl"
78
79 #undef EH_FRAME_SECTION_ASM_OP
80 #define EH_FRAME_SECTION_ASM_OP_COFF    "\t.section\t.ehfram, \"x\""
81 #define EH_FRAME_SECTION_ASM_OP_ELF     "\t.section\t.eh_frame, \"aw\""
82 #define EH_FRAME_SECTION_ASM_OP \
83   ((TARGET_ELF) ? EH_FRAME_SECTION_ASM_OP_ELF : EH_FRAME_SECTION_ASM_OP_COFF)
84
85 /* Avoid problems (long sectino names, forward assembler refs) with DWARF
86    exception unwinding when we're generating COFF */
87 #define DWARF2_UNWIND_INFO      \
88   ((TARGET_ELF) ? 1 : 0 )  
89
90 #undef CONST_SECTION_ASM_OP
91 #define CONST_SECTION_ASM_OP_COFF       "\t.section\t.rodata, \"x\""
92 #define CONST_SECTION_ASM_OP_ELF        "\t.section\t.rodata"
93 #define CONST_SECTION_ASM_OP    \
94   ((TARGET_ELF) ? CONST_SECTION_ASM_OP_ELF : CONST_SECTION_ASM_OP_COFF)
95
96 #undef USE_CONST_SECTION
97 #define USE_CONST_SECTION_ELF           1
98 #define USE_CONST_SECTION_COFF          0
99 #define USE_CONST_SECTION       \
100  ((TARGET_ELF) ? USE_CONST_SECTION_ELF : USE_CONST_SECTION_COFF)
101
102 #undef INIT_SECTION_ASM_OP
103 #define INIT_SECTION_ASM_OP_ELF         "\t.section\t.init"
104 #define INIT_SECTION_ASM_OP_COFF        "\t.section\t.init ,\"x\""
105 #define INIT_SECTION_ASM_OP     \
106   ((TARGET_ELF) ? INIT_SECTION_ASM_OP_ELF : INIT_SECTION_ASM_OP_COFF)
107
108 #undef CTORS_SECTION_ASM_OP
109 #define CTORS_SECTION_ASM_OP_ELF        "\t.section\t.ctors,\"aw\""
110 #define CTORS_SECTION_ASM_OP_COFF       INIT_SECTION_ASM_OP_COFF
111 #define CTORS_SECTION_ASM_OP    \
112  ((TARGET_ELF) ? CTORS_SECTION_ASM_OP_ELF : CTORS_SECTION_ASM_OP_COFF)
113
114 #undef DTORS_SECTION_ASM_OP
115 #define DTORS_SECTION_ASM_OP_ELF        "\t.section\t.dtors, \"aw\""
116 #define DTORS_SECTION_ASM_OP_COFF       FINI_SECTION_ASM_OP_COFF
117 #define DTORS_SECTION_ASM_OP    \
118  ((TARGET_ELF) ? DTORS_SECTION_ASM_OP_ELF : DTORS_SECTION_ASM_OP_COFF)
119
120 #undef FINI_SECTION_ASM_OP
121 #define FINI_SECTION_ASM_OP_ELF         "\t.section\t.fini"
122 #define FINI_SECTION_ASM_OP_COFF        "\t.section\t.fini, \"x\""
123 #define FINI_SECTION_ASM_OP     \
124  ((TARGET_ELF) ? FINI_SECTION_ASM_OP_ELF : FINI_SECTION_ASM_OP_COFF)
125
126 #undef BSS_SECTION_ASM_OP
127 #define BSS_SECTION_ASM_OP              "\t.data"
128
129 #undef TEXT_SECTION_ASM_OP
130 #define TEXT_SECTION_ASM_OP             "\t.text"
131
132 #undef DATA_SECTION_ASM_OP
133 #define DATA_SECTION_ASM_OP             "\t.data"
134
135 #undef TYPE_OPERAND_FMT
136 #define TYPE_OPERAND_FMT                "@%s"
137
138 #undef APPLY_RESULT_SIZE
139 #define APPLY_RESULT_SIZE                                               \
140 (TARGET_ELF) ? size : 116
141
142 #ifndef ASM_DECLARE_RESULT
143 #define ASM_DECLARE_RESULT(FILE, RESULT)
144 #endif
145
146 #define SCO_DEFAULT_ASM_COFF(FILE,NAME)                                 \
147 do {                                                                    \
148       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
149   } while (0)
150
151 #undef ASM_DECLARE_FUNCTION_NAME
152 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
153   do {                                                                  \
154     if (TARGET_ELF) {                                                   \
155       fprintf (FILE, "%s\t ", TYPE_ASM_OP);                             \
156       assemble_name (FILE, NAME);                                       \
157       putc (',', FILE);                                                 \
158       fprintf (FILE, TYPE_OPERAND_FMT, "function");                     \
159       putc ('\n', FILE);                                                \
160       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                    \
161       ASM_OUTPUT_LABEL(FILE, NAME);                                     \
162     } else                                                              \
163       SCO_DEFAULT_ASM_COFF(FILE, NAME);                                 \
164 } while (0)
165
166 #undef ASM_DECLARE_FUNCTION_SIZE
167 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
168   do {                                                                  \
169     if (TARGET_ELF) { if (!flag_inhibit_size_directive)                 \
170       {                                                                 \
171         fprintf (FILE, "%s\t ", SIZE_ASM_OP);                           \
172         assemble_name (FILE, (FNAME));                                  \
173         fprintf (FILE, ",.-");                                          \
174         assemble_name (FILE, (FNAME));                                  \
175         putc ('\n', FILE);                                              \
176       } }                                                               \
177   } while (0)
178
179 #undef ASM_DECLARE_OBJECT_NAME
180 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
181   do {                                                                  \
182     if (TARGET_ELF) {                                                   \
183       fprintf (FILE, "%s\t ", TYPE_ASM_OP);                             \
184       assemble_name (FILE, NAME);                                       \
185       putc (',', FILE);                                                 \
186       fprintf (FILE, TYPE_OPERAND_FMT, "object");                       \
187       putc ('\n', FILE);                                                \
188       size_directive_output = 0;                                        \
189       if (!flag_inhibit_size_directive && DECL_SIZE (DECL))             \
190         {                                                               \
191         size_directive_output = 1;                                      \
192         fprintf (FILE, "%s\t ", SIZE_ASM_OP);                           \
193         assemble_name (FILE, NAME);                                     \
194         fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
195         }                                                               \
196       ASM_OUTPUT_LABEL(FILE, NAME);                                     \
197     } else                                                              \
198       SCO_DEFAULT_ASM_COFF(FILE, NAME);                                 \
199   } while (0)
200
201 #undef ASM_FILE_START_1
202 #define ASM_FILE_START_1(FILE)
203
204 #undef ASM_FILE_START
205 #define ASM_FILE_START(FILE)                                            \
206 do {                                                                    \
207   output_file_directive((FILE),main_input_filename);                    \
208   fprintf ((FILE), "\t.version\t\"01.01\"\n");                          \
209 } while (0)
210
211 #undef ASM_FILE_END
212 #define ASM_FILE_END(FILE)                                              \
213 do {                                                                    \
214   fprintf ((FILE), "%s\t\"GCC: (GNU) %s\"\n",                           \
215     IDENT_ASM_OP, version_string);                                      \
216 } while (0)
217
218 #undef ASM_FINISH_DECLARE_OBJECT
219 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
220 do {                                                                     \
221   if (TARGET_ELF) {                                                     \
222      char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);                   \
223      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)                \
224          && ! AT_END && TOP_LEVEL                                        \
225          && DECL_INITIAL (DECL) == error_mark_node                       \
226          && !size_directive_output)                                      \
227        {                                                                 \
228          size_directive_output = 1;                                      \
229          fprintf (FILE, "%s\t ", SIZE_ASM_OP);                           \
230          assemble_name (FILE, name);                                     \
231          fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
232        }                                                                 \
233     }                                                                    \
234 } while (0)
235
236 #undef ASM_GENERATE_INTERNAL_LABEL
237 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)                 \
238 do {                                                                    \
239   if (TARGET_ELF)                                                       \
240     sprintf (LABEL, "*.%s%d", (PREFIX), (NUM));                         \
241   else                                                                  \
242     sprintf (LABEL, ".%s%d", (PREFIX), (NUM));                          \
243 } while (0)
244
245 #undef ASM_OUTPUT_ADDR_DIFF_ELT
246 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, VALUE, REL) \
247 do {                                                                    \
248   if (TARGET_ELF)                                                       \
249     fprintf (FILE, "%s _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", ASM_LONG, LPREFIX, VALUE); \
250   else                                                                  \
251     fprintf (FILE, "\t.word %s%d-%s%d\n", LPREFIX,VALUE,LPREFIX,REL);   \
252 } while (0)
253
254 #undef ASM_OUTPUT_ALIGNED_COMMON
255 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)              \
256 do {                                                                    \
257   fprintf ((FILE), "%s\t", COMMON_ASM_OP);                              \
258   assemble_name ((FILE), (NAME));                                       \
259   if (TARGET_ELF)                                                       \
260     fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT);      \
261   else                                                                  \
262     fprintf ((FILE), ",%u\n", (SIZE));                                  \
263 } while (0)
264
265 #undef ASM_OUTPUT_ALIGNED_LOCAL
266 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)               \
267 do {                                                                    \
268   if (TARGET_ELF) {                                                     \
269     fprintf ((FILE), "%s\t", LOCAL_ASM_OP);                             \
270     assemble_name ((FILE), (NAME));                                     \
271     fprintf ((FILE), "\n");                                             \
272     ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN);                \
273   } else {                                                              \
274     int align = exact_log2 (ALIGN);                                     \
275     if (align > 2) align = 2;                                           \
276     if (TARGET_SVR3_SHLIB)                                              \
277       data_section ();                                                  \
278     else                                                                \
279       bss_section ();                                                   \
280     ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align);                 \
281     fprintf ((FILE), "%s\t", "\t.lcomm");                               \
282     assemble_name ((FILE), (NAME));                                     \
283     fprintf ((FILE), ",%u\n", (SIZE));                                  \
284    }                                                                    \
285 } while (0)
286
287 #undef ESCAPES
288 #define ESCAPES \
289 "\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\
290 \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\
291 \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\
292 \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\
293 \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\
294 \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\
295 \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\
296 \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"
297
298 #undef STRING_LIMIT
299 #define STRING_LIMIT    ((unsigned) 256)
300
301 #undef ASM_OUTPUT_LIMITED_STRING
302 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR)                            \
303   do                                                                    \
304     {                                                                   \
305       register unsigned char *_limited_str = (unsigned char *) (STR);   \
306       register unsigned ch;                                             \
307       fprintf ((FILE), "%s\t\"", STRING_ASM_OP);                        \
308       for (; ch = *_limited_str; _limited_str++)                        \
309         {                                                               \
310           register int escape;                                          \
311           switch (escape = ESCAPES[ch])                                 \
312             {                                                           \
313             case 0:                                                     \
314               putc (ch, (FILE));                                        \
315               break;                                                    \
316             case 1:                                                     \
317               fprintf ((FILE), "\\%03o", ch);                           \
318               break;                                                    \
319             default:                                                    \
320               putc ('\\', (FILE));                                      \
321               putc (escape, (FILE));                                    \
322               break;                                                    \
323             }                                                           \
324         }                                                               \
325       fprintf ((FILE), "\"\n");                                         \
326     }                                                                   \
327   while (0)
328
329
330 #undef ASM_OUTPUT_ASCII
331 #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)                             \
332 do {                                                                    \
333       register unsigned char *_ascii_bytes = (unsigned char *) (STR);   \
334       register unsigned char *limit = _ascii_bytes + (LENGTH);          \
335       register unsigned bytes_in_chunk = 0;                             \
336       for (; _ascii_bytes < limit; _ascii_bytes++)                      \
337         {                                                               \
338           register unsigned char *p;                                    \
339           if (bytes_in_chunk >= 64)                                     \
340             {                                                           \
341               fputc ('\n', (FILE));                                     \
342               bytes_in_chunk = 0;                                       \
343             }                                                           \
344           for (p = _ascii_bytes; p < limit && *p != '\0'; p++)          \
345             continue;                                                   \
346           if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT)          \
347             {                                                           \
348               if (bytes_in_chunk > 0)                                   \
349                 {                                                       \
350                   fputc ('\n', (FILE));                                 \
351                   bytes_in_chunk = 0;                                   \
352                 }                                                       \
353               ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);         \
354               _ascii_bytes = p;                                         \
355             }                                                           \
356           else                                                          \
357             {                                                           \
358               if (bytes_in_chunk == 0)                                  \
359                 fprintf ((FILE), "%s\t", ASM_BYTE_OP);                  \
360               else                                                      \
361                 fputc (',', (FILE));                                    \
362               fprintf ((FILE), "0x%02x", *_ascii_bytes);                \
363               bytes_in_chunk += 5;                                      \
364             }                                                           \
365         }                                                               \
366       if (bytes_in_chunk > 0)                                           \
367         fprintf ((FILE), "\n");                                         \
368 } while (0) 
369
370 #undef ASM_OUTPUT_CASE_LABEL
371 #define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE)                \
372 do {                                                                    \
373   if (TARGET_ELF)                                                       \
374     ASM_OUTPUT_ALIGN ((FILE), 2);                                       \
375   ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM));                     \
376 } while (0)
377
378
379 #undef ASM_OUTPUT_CONSTRUCTOR
380 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)                               \
381 do {                                                                    \
382   if (TARGET_ELF) {                                                     \
383      ctors_section ();                                                  \
384      fprintf (FILE, "%s\t ", INT_ASM_OP);                               \
385      assemble_name (FILE, NAME);                                        \
386      fprintf (FILE, "\n");                                              \
387   } else {                                                              \
388     init_section ();                                                    \
389     fprintf (FILE, "\tpushl $");                                        \
390     assemble_name (FILE, NAME);                                         \
391     fprintf (FILE, "\n"); }                                             \
392   } while (0)
393
394 #undef ASM_OUTPUT_DESTRUCTOR
395 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                                \
396 do {                                                                    \
397   if (TARGET_ELF) {                                                     \
398     dtors_section ();                                                   \
399     fprintf (FILE, "%s\t ", INT_ASM_OP);                                \
400     assemble_name (FILE, NAME);                                         \
401     fprintf (FILE, "\n");                                               \
402   } else {                                                              \
403     fini_section ();                                                    \
404     fprintf (FILE, "%s\t ", ASM_LONG);                                  \
405     assemble_name (FILE, NAME);                                         \
406     fprintf (FILE, "\n"); }                                             \
407   } while (0)
408
409
410 #undef ASM_OUTPUT_DOUBLE
411 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                                   \
412 do {                                                                    \
413   long value[2];                                                        \
414   REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), value);                         \
415   if (TARGET_ELF) {                                                     \
416      if (sizeof (int) == sizeof (long))                                 \
417        {                                                                \
418          fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[0]);             \
419          fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value[1]);             \
420        }                                                                \
421      else                                                               \
422        {                                                                \
423          fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[0]);            \
424          fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value[1]);            \
425        }                                                                \
426   } else {                                                              \
427      if (sizeof (int) == sizeof (long))                                 \
428        fprintf (FILE, "%s 0x%x,0x%x\n", ASM_LONG, value[0], value[1]);  \
429      else                                                               \
430        fprintf (FILE, "%s 0x%lx,0x%lx\n", ASM_LONG,value[0],value[1]);} \
431 } while (0)
432
433 #undef ASM_OUTPUT_FLOAT
434 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                                    \
435 do {                                                                    \
436   long value;                                                           \
437   REAL_VALUE_TO_TARGET_SINGLE ((VALUE), value);                         \
438   if (sizeof (int) == sizeof (long))                                    \
439      fprintf((FILE), "%s\t0x%x\n", ASM_LONG, value);                    \
440   else                                                                  \
441      fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, value);                   \
442 } while (0)
443
444 #undef ASM_OUTPUT_LONG_DOUBLE
445 #define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE)                              \
446 do {                                                                    \
447   long l[3];                                                            \
448   REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), l);                        \
449   if (TARGET_ELF) {                                                     \
450      if (sizeof (int) == sizeof (long))                                 \
451        {                                                                \
452          fprintf((FILE), "%s\t0x%x\n", ASM_LONG, l[0]);                 \
453          fprintf((FILE), "%s\t0x%x\n", ASM_LONG, l[1]);                 \
454          fprintf((FILE), "%s\t0x%x\n", ASM_LONG, l[2]);                 \
455        }                                                                \
456      else                                                               \
457        {                                                                \
458          fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, l[0]);                \
459          fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, l[1]);                \
460          fprintf((FILE), "%s\t0x%lx\n", ASM_LONG, l[2]);                \
461        }                                                                \
462   } else {                                                              \
463      if (sizeof (int) == sizeof (long))                                 \
464        fprintf (FILE, "%s 0x%x,0x%x,0x%x\n", ASM_LONG, l[0], l[1], l[2]); \
465      else                                                               \
466        fprintf (FILE, "%s 0x%lx,0x%lx,0x%lx\n", ASM_LONG,l[0],l[1],l[2]);} \
467 } while (0)
468
469 #undef ASM_OUTPUT_IDENT
470 #define ASM_OUTPUT_IDENT(FILE, NAME) \
471   fprintf (FILE, "%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
472
473 #undef ASM_GLOBALIZE_LABEL
474 #define ASM_GLOBALIZE_LABEL(FILE,NAME)  \
475   (fprintf ((FILE), "%s ", GLOBAL_ASM_OP), assemble_name (FILE, NAME), fputs ("\n", FILE))
476
477 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
478 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)                          \
479   if (TARGET_ELF) ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
480
481 #undef ASM_OUTPUT_INTERNAL_LABEL
482 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)                      \
483   fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
484
485 /* The prefix to add to user-visible assembler symbols. */
486
487 #undef USER_LABEL_PREFIX
488 #define USER_LABEL_PREFIX ""
489
490 #undef ASM_OUTPUT_SECTION_NAME
491 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
492 do {                                                                    \
493   char *snam = NAME ;                                                   \
494   if (strcmp(NAME, ".gcc_except_table") == 0) snam = ".gccexc" ;        \
495   if (TARGET_ELF)                                                       \
496     fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME,             \
497            (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" :         \
498            (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw"); \
499   else                                                                  \
500     fprintf (FILE, ".section\t%s,\"%s\"\n", snam,                       \
501         (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "x" :             \
502         (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "w");     \
503 } while (0)
504
505 #undef ASM_OUTPUT_SKIP
506 #define ASM_OUTPUT_SKIP(FILE,SIZE) \
507 do {                                                                    \
508   if (TARGET_ELF)                                                       \
509     fprintf (FILE, "%s\t%u\n", SKIP_ASM_OP, (SIZE));                    \
510   else                                                                  \
511     fprintf ((FILE), "%s\t.,.+%u\n", SET_ASM_OP, (SIZE));               \
512 } while (0)
513
514
515 #undef CTOR_LIST_BEGIN
516 #define CTOR_LIST_BEGIN                                                 \
517 do {                                                                    \
518   asm (CTORS_SECTION_ASM_OP);                                           \
519   if (TARGET_ELF)                                                       \
520     STATIC func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) };             \
521   else                                                                  \
522     asm ("pushl $0");                                                   \
523 } while (0)
524
525 #undef CTOR_LIST_END
526 #define CTOR_LIST_END                                                   \
527 do {                                                                    \
528   if (TARGET_ELF) {                                                     \
529     asm (CTORS_SECTION_ASM_OP);                                         \
530     STATIC func_ptr __CTOR_LIST__[1] = { (func_ptr) (0) };              \
531   } else {                                                              \
532     CTOR_LIST_BEGIN;                                                    \
533   }                                                                     \
534 } while (0)
535
536 #undef DBX_BLOCKS_FUNCTION_RELATIVE
537 #define DBX_BLOCKS_FUNCTION_RELATIVE 1
538
539 #undef DBX_FUNCTION_FIRST
540 #define DBX_FUNCTION_FIRST 1
541
542 #undef DBX_REGISTER_NUMBER
543 #define DBX_REGISTER_NUMBER(n)                                          \
544 ((TARGET_ELF) ?                                                         \
545  ((n) == 0 ? 0                                                          \
546   : (n) == 1 ? 2                                                        \
547   : (n) == 2 ? 1                                                        \
548   : (n) == 3 ? 3                                                        \
549   : (n) == 4 ? 6                                                        \
550   : (n) == 5 ? 7                                                        \
551   : (n) == 6 ? 5                                                        \
552   : (n) == 7 ? 4                                                        \
553   : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3           \
554   : (-1))                                                               \
555  :                                                                      \
556  ((n) == 0 ? 0 :                                                        \
557   (n) == 1 ? 2 :                                                        \
558   (n) == 2 ? 1 :                                                        \
559   (n) == 3 ? 3 :                                                        \
560   (n) == 4 ? 6 :                                                        \
561   (n) == 5 ? 7 :                                                        \
562   (n) == 6 ? 4 :                                                        \
563   (n) == 7 ? 5 :                                                        \
564   (n) + 4))
565
566 #undef DWARF_DEBUGGING_INFO
567 #undef SDB_DEBUGGING_INFO
568 #undef DBX_DEBUGGING_INFO
569 #undef PREFERRED_DEBUGGING_TYPE
570
571 #define DWARF_DEBUGGING_INFO 1
572 #define SDB_DEBUGGING_INFO   1
573 #define DBX_DEBUGGING_INFO   1
574 #define PREFERRED_DEBUGGING_TYPE                                        \
575   ((TARGET_ELF) ? DWARF_DEBUG: SDB_DEBUG)
576
577 #undef EXTRA_SECTIONS
578 #define EXTRA_SECTIONS in_const, in_init, in_fini, in_ctors, in_dtors
579
580 #undef EXTRA_SECTION_FUNCTIONS
581 #define EXTRA_SECTION_FUNCTIONS                                         \
582   CONST_SECTION_FUNCTION                                                \
583   INIT_SECTION_FUNCTION                                                 \
584   FINI_SECTION_FUNCTION                                                 \
585   CTORS_SECTION_FUNCTION                                                \
586   DTORS_SECTION_FUNCTION
587
588 #undef CONST_SECTION_FUNCTION
589 #define CONST_SECTION_FUNCTION                                          \
590 void                                                                    \
591 const_section ()                                                        \
592 {                                                                       \
593   extern void text_section();                                           \
594   if (!USE_CONST_SECTION)                                               \
595     text_section();                                                     \
596   else if (in_section != in_const)                                      \
597     {                                                                   \
598       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);             \
599       in_section = in_const;                                            \
600     }                                                                   \
601 }
602
603 #undef FINI_SECTION_FUNCTION
604 #define FINI_SECTION_FUNCTION                                           \
605 void                                                                    \
606 fini_section ()                                                         \
607 {                                                                       \
608   if ((!TARGET_ELF) && in_section != in_fini)                           \
609     {                                                                   \
610       fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP);              \
611       in_section = in_fini;                                             \
612     }                                                                   \
613 }
614
615 #undef INIT_SECTION_FUNCTION
616 #define INIT_SECTION_FUNCTION                                           \
617 void                                                                    \
618 init_section ()                                                         \
619 {                                                                       \
620   if ((!TARGET_ELF) && in_section != in_init)                           \
621     {                                                                   \
622       fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP);              \
623       in_section = in_init;                                             \
624     }                                                                   \
625 }
626
627 #undef CTORS_SECTION_FUNCTION
628 #define CTORS_SECTION_FUNCTION                                          \
629 void                                                                    \
630 ctors_section ()                                                        \
631 {                                                                       \
632   if (in_section != in_ctors)                                           \
633     {                                                                   \
634       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);             \
635       in_section = in_ctors;                                            \
636     }                                                                   \
637 }
638
639 #undef DTORS_SECTION_FUNCTION
640 #define DTORS_SECTION_FUNCTION                                          \
641 void                                                                    \
642 dtors_section ()                                                        \
643 {                                                                       \
644   if (in_section != in_dtors)                                           \
645     {                                                                   \
646       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);             \
647       in_section = in_dtors;                                            \
648     }                                                                   \
649 }
650
651 #undef FRAME_POINTER_REQUIRED
652 #define FRAME_POINTER_REQUIRED                                          \
653   ((TARGET_ELF) ? 0 :                                                   \
654    (current_function_calls_setjmp || current_function_calls_longjmp))
655
656 #undef JUMP_TABLES_IN_TEXT_SECTION
657 #define JUMP_TABLES_IN_TEXT_SECTION 1
658
659 #undef LOCAL_LABEL_PREFIX
660 #define LOCAL_LABEL_PREFIX                                              \
661  ((TARGET_ELF) ? "" : ".")
662
663 #undef MD_EXEC_PREFIX
664 #undef MD_STARTFILE_PREFIX
665 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
666 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
667
668 #undef NON_SAVING_SETJMP
669 #define NON_SAVING_SETJMP                                               \
670   ((TARGET_ELF) ? 0 :                                                   \
671    (current_function_calls_setjmp && current_function_calls_longjmp))
672
673 #undef NO_IMPLICIT_EXTERN_C
674 #define NO_IMPLICIT_EXTERN_C 1
675
676 /* JKJ FIXME - examine the rammifications of RETURN_IN_MEMORY and
677    RETURN_POPS_ARGS */
678
679 #undef RETURN_POPS_ARGS
680 #define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE)                          \
681  ((TARGET_ELF) ?                                                        \
682   (i386_return_pops_args (FUNDECL, FUNTYPE, SIZE)) :                    \
683   (((FUNDECL) && (TREE_CODE (FUNDECL) == IDENTIFIER_NODE)) ? 0          \
684    : (TARGET_RTD                                                        \
685       && (TYPE_ARG_TYPES (FUNTYPE) == 0                                 \
686           || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE)))         \
687               == void_type_node))) ? (SIZE)                             \
688    : 0))
689
690 #undef SELECT_SECTION
691 #define SELECT_SECTION(DECL,RELOC)                                      \
692 {                                                                       \
693   if (TREE_CODE (DECL) == STRING_CST)                                   \
694     {                                                                   \
695       if (! flag_writable_strings)                                      \
696         const_section ();                                               \
697       else                                                              \
698         data_section ();                                                \
699     }                                                                   \
700   else if (TREE_CODE (DECL) == VAR_DECL)                                \
701     {                                                                   \
702       if ((TARGET_ELF && flag_pic && RELOC)                             \
703           || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)          \
704           || !DECL_INITIAL (DECL)                                       \
705           || (DECL_INITIAL (DECL) != error_mark_node                    \
706               && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
707         data_section ();                                                \
708       else                                                              \
709         const_section ();                                               \
710     }                                                                   \
711   else                                                                  \
712     const_section ();                                                   \
713 }
714
715 #undef SWITCH_TAKES_ARG
716 #define SWITCH_TAKES_ARG(CHAR)                                          \
717   (DEFAULT_SWITCH_TAKES_ARG(CHAR)                                       \
718    || (CHAR) == 'h'                                                     \
719    || (CHAR) == 'R'                                                     \
720    || (CHAR) == 'Y'                                                     \
721    || (CHAR) == 'z')
722
723 #undef WORD_SWITCH_TAKES_ARG
724 #define WORD_SWITCH_TAKES_ARG(STR)                                      \
725  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)                                   \
726   && strcmp (STR, "Tdata") && strcmp (STR, "Ttext")                     \
727   && strcmp (STR, "Tbss"))
728
729 #undef TARGET_DEFAULT
730 #define TARGET_DEFAULT 0301
731
732 #undef HANDLE_SYSV_PRAGMA
733 #define HANDLE_SYSV_PRAGMA 1
734
735 #undef SCCS_DIRECTIVE
736 #define SCCS_DIRECTIVE 1
737
738 /*
739  * Define sizes and types
740  */
741 #undef SIZE_TYPE
742 #undef PTRDIFF_TYPE
743 #undef WCHAR_TYPE
744 #undef WCHAR_TYPE_SIZE
745 #undef LONG_DOUBLE_TYPE_SIZE
746 #define LONG_DOUBLE_TYPE_SIZE   96
747 #define SIZE_TYPE               "unsigned int"
748 #define PTRDIFF_TYPE            "int"
749 #define WCHAR_TYPE              "long int"
750 #define WCHAR_TYPE_SIZE         BITS_PER_WORD
751
752 /*
753  * New for multilib support. Set the default switches for multilib,
754  * which is -melf.
755  */
756 #define MULTILIB_DEFAULTS { "melf" }
757
758 \f
759 /* Please note that these specs may look messy but they are required in
760    order to emulate the SCO Development system as closely as possible.
761    With SCO Open Server 5.0, you now get the linker and assembler free,
762    so that is what these specs are targeted for. These utilities are
763    very argument sensitive: a space in the wrong place breaks everything.
764    So RMS, please forgive this mess. It works.
765
766    Parameters which can be passed to gcc, and their SCO equivalents:
767    GCC Parameter                SCO Equivalent
768    -ansi                        -a ansi
769    -posix                       -a posix
770    -Xpg4                        -a xpg4
771    -Xpg4plus                    -a xpg4plus
772    -Xods30                      -a ods30
773
774    As with SCO, the default is XPG4 plus mode. SCO also allows you to
775    specify a C dialect with -Xt, -Xa, -Xc, -Xk and -Xm. These are passed
776    on to the assembler and linker in the same way that the SCO compiler
777    does.
778
779    SCO also allows you to compile, link and generate either ELF or COFF
780    binaries. With gcc, unlike the SCO compiler, the default is ELF.
781    Specify -mcoff to gcc to produce elf binaries. -fpic will get the
782    assembler and linker to produce PIC code.
783 */
784
785 /* Set up assembler flags for PIC and ELF compilations */
786 #undef ASM_SPEC
787 #define ASM_SPEC \
788  "-b %{!mcoff:elf}%{mcoff:coff \
789    %{static:%e-static not valid with -mcoff} \
790    %{shared:%e-shared not valid with -mcoff} \
791    %{symbolic:%e-symbolic not valid with -mcoff}} \
792   %{Ym,*} %{Yd,*} %{Wa,*:%*} \
793   %{!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}}"
794
795 /* Use crt1.o as a startup file and crtn.o as a closing file.  */
796
797 #undef STARTFILE_SPEC
798 #define STARTFILE_SPEC \
799  "%{!shared:\
800    %{!symbolic: \
801     %{pg:gcrt.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}} \
802   %{ansi:values-Xc.o%s} \
803   %{!ansi: \
804    %{traditional:values-Xt.o%s} \
805     %{!traditional: \
806      %{Xa:values-Xa.o%s} \
807       %{!Xa:%{Xc:values-Xc.o%s} \
808        %{!Xc:%{Xk:values-Xk.o%s} \
809         %{!Xk:%{Xt:values-Xt.o%s} \
810          %{!Xt:values-Xa.o%s}}}}}} \
811   %{mcoff:crtbeginS.o%s} \
812   %{!mcoff:%{!static:crtbegin.o%s}%{static:crtbeginS.o%s}}"
813
814 #undef ENDFILE_SPEC
815 #define ENDFILE_SPEC \
816  "%{!mcoff:%{!static:crtend.o%s}%{static:crtendS.o%s}} \
817   %{mcoff:crtendS.o%s} \
818   %{pg:gcrtn.o%s}%{!pg:crtn.o%s}"
819
820 #undef CPP_PREDEFINES
821 #define CPP_PREDEFINES \
822  "-Asystem(svr3)"
823
824 /* You are in a maze of GCC specs ... all alike */
825
826 #undef CPP_SPEC
827 #define CPP_SPEC "%(cpp_cpu) %[cpp_cpu] \
828   %{fpic:%{mcoff:%e-fpic is not valid with -mcoff}} \
829   %{fPIC:%{mcoff:%e-fPIC is not valid with -mcoff}} \
830   -D__i386 -D__unix -D_SCO_DS=1 -D_M_I386 -D_M_XENIX -D_M_UNIX \
831   %{!Xods30:-D_STRICT_NAMES} \
832   %{!ansi:%{!posix:%{!Xods30:-D_SCO_XPG_VERS=4}}} \
833   %{ansi:-isystem include/ansi%s -isystem /usr/include/ansi -D_STRICT_ANSI} \
834   %{!ansi: \
835    %{posix:-isystem include/posix%s -isystem /usr/include/posix \
836            -D_POSIX_C_SOURCE=2 -D_POSIX_SOURCE=1} \
837     %{!posix:%{Xpg4:-isystem include/xpg4%s -isystem /usr/include/xpg4 \
838                     -D_XOPEN_SOURCE=1} \
839      %{!Xpg4:-D_M_I86 -D_M_I86SM -D_M_INTERNAT -D_M_SDATA -D_M_STEXT \
840              -D_M_BITFIELDS -D_M_SYS5 -D_M_SYSV -D_M_SYSIII \
841              -D_M_WORDSWAP -Dunix -DM_I386 -DM_UNIX -DM_XENIX \
842              %{Xods30:-isystem include/ods_30_compat%s \
843                       -isystem /usr/include/ods_30_compat \
844                       -D_SCO_ODS_30 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \
845                       -DM_BITFIELDS -DM_SYS5 -DM_SYSV -DM_INTERNAT -DM_SYSIII \
846                       -DM_WORDSWAP}}}} \
847   %{scointl:-DM_INTERNAT -D_M_INTERNAT} \
848   %{traditional:-D_KR -D_SVID -D_NO_PROTOTYPE} \
849   %{!mcoff:-D_SCO_ELF} \
850   %{mcoff:-D_M_COFF -D_SCO_COFF} \
851   %{!mcoff:%{fpic:-D__PIC__ -D__pic__} \
852          %{fPIC:%{!fpic:-D__PIC__ -D__pic__}}} \
853   %{Xa:-D_SCO_C_DIALECT=1} \
854   %{!Xa:%{Xc:-D_SCO_C_DIALECT=3} \
855    %{!Xc:%{Xk:-D_SCO_C_DIALECT=4} \
856     %{!Xk:%{Xt:-D_SCO_C_DIALECT=2} \
857      %{!Xt:-D_SCO_C_DIALECT=1}}}} \
858   %{traditional:-traditional -D_KR -D_NO_PROTOTYPE}"
859
860 #undef LINK_SPEC
861 #define LINK_SPEC \
862  "-b %{!mcoff:elf}%{mcoff:coff \
863    %{static:%e-static not valid with -mcoff} \
864    %{shared:%e-shared not valid with -mcoff} \
865    %{symbolic:%e-symbolic not valid with -mcoff} \
866    %{fpic:%e-fpic not valid with -mcoff} \
867    %{fPIC:%e-fPIC not valid with -mcoff}} \
868   -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} \
869   %{Wl,*%*} %{YP,*} %{YL,*} %{YU,*} \
870   %{!YP,*:%{p:-YP,/usr/ccs/libp:/lib/libp:/usr/lib/libp:/usr/ccs/lib:/lib:/usr/lib} \
871    %{!p:-YP,/usr/ccs/lib:/lib:/usr/lib}} \
872   %{h*} %{static:-dn -Bstatic} %{shared:-G -dy %{!z*:-z text}} \
873   %{symbolic:-Bsymbolic -G -dy %{!z*:-z text}} %{z*} %{R*} %{Y*} \
874   %{G:-G} %{!mcoff:%{Qn:} %{!Qy:-Qn}}"
875
876 /* The SCO COFF linker gets confused on the difference between "-ofoo"
877    and "-o foo".   So we just always force a single space. */
878
879 #define SWITCHES_NEED_SPACES "o"
880
881 /* Library spec. If we are not building a shared library, provide the
882    standard libraries, as per the SCO compiler.  */
883
884 #undef LIB_SPEC
885 #define LIB_SPEC \
886  "%{!shared:%{!symbolic:-lcrypt -lgen -lc}}"
887
888 #define MASK_COFF               010000000000    /* Mask for elf generation */
889 #define TARGET_COFF             (target_flags & MASK_COFF)
890 #define TARGET_ELF              (!(target_flags & MASK_COFF))
891
892 #undef SUBTARGET_SWITCHES
893 #define SUBTARGET_SWITCHES              \
894         { "coff", MASK_COFF },          \
895         { "elf", -MASK_COFF },
896
897 #define NO_DOLLAR_IN_LABEL
898
899 /*
900 Here comes some major hackery to get the crt stuff to compile properly.
901 Since we can (and do) compile for both COFF and ELF environments, we
902 set things up accordingly, based on the pre-processor defines for ELF
903 and COFF. This is insane, but then I guess having one compiler with a
904 single back-end supporting two vastly different file format types is
905 a little insane too. But it is not impossible and we get a useful
906 compiler at the end of the day. Onward we go ...
907 */
908
909 #if defined(CRT_BEGIN) || defined(CRT_END) || defined(IN_LIBGCC2)
910 # undef OBJECT_FORMAT_ELF
911 # undef HAVE_ATEXIT
912 # undef INIT_SECTION_ASM_OP
913 # undef FINI_SECTION_ASM_OP
914 # undef CTORS_SECTION_ASM_OP
915 # undef DTORS_SECTION_ASM_OP
916 # undef EH_FRAME_SECTION_ASM_OP
917 # undef CTOR_LIST_BEGIN
918 # undef CTOR_LIST_END
919 # undef DO_GLOBAL_CTORS_BODY
920
921 # if defined (_SCO_ELF)
922 #  define OBJECT_FORMAT_ELF
923 #  define HAVE_ATEXIT
924 #  define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_ELF
925 #  define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_ELF
926 #  define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_ELF
927 #  define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_ELF
928 #  define EH_FRAME_SECTION_ASM_OP EH_FRAME_SECTION_ASM_OP_ELF
929 # else /* ! _SCO_ELF */
930 #  define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_COFF
931 #  define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_COFF
932 #  define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_COFF
933 #  define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_COFF
934 #  define EH_FRAME_SECTION_ASM_OP ""
935 #  define CTOR_LIST_BEGIN asm (INIT_SECTION_ASM_OP); asm ("pushl $0")
936 #  define CTOR_LIST_END CTOR_LIST_BEGIN
937 #  define DO_GLOBAL_CTORS_BODY                                          \
938 do {                                                                    \
939      func_ptr *p, *beg = alloca(0);                                     \
940      for (p = beg; *p;)                                                 \
941       (*p++) ();                                                        \
942 } while (0)
943 # endif /* ! _SCO_ELF */
944 #endif /* CRT_BEGIN !! CRT_END */