OSDN Git Service

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