sco5.h revision 50397
1/* Definitions for Intel 386 running SCO Unix System V 3.2 Version 5.
2   Copyright (C) 1992, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3   Contributed by Kean Johnston (hug@netcom.com)
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING.  If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, 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)					\
147do {									\
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)						\
206do {									\
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)						\
213do {									\
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)	 \
220do {									 \
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)			\
238do {									\
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, BODY, VALUE, REL) \
247do {									\
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)		\
256do {									\
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)		\
267do {									\
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/* A C statement (sans semicolon) to output to the stdio stream
288   FILE the assembler definition of uninitialized global DECL named
289   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
290   Try to use asm_output_aligned_bss to implement this macro.  */
291
292#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
293asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
294
295#undef ESCAPES
296#define ESCAPES \
297"\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\
298\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\
299\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\
300\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\
301\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\
302\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\
303\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\
304\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"
305
306#undef STRING_LIMIT
307#define STRING_LIMIT	((unsigned) 256)
308
309#undef ASM_OUTPUT_LIMITED_STRING
310#define ASM_OUTPUT_LIMITED_STRING(FILE, STR)				\
311  do									\
312    {									\
313      register unsigned char *_limited_str = (unsigned char *) (STR);	\
314      register unsigned ch;						\
315      fprintf ((FILE), "%s\t\"", STRING_ASM_OP);			\
316      for (; (ch = *_limited_str); _limited_str++)			\
317        {								\
318	  register int escape;						\
319	  switch (escape = ESCAPES[ch])					\
320	    {								\
321	    case 0:							\
322	      putc (ch, (FILE));					\
323	      break;							\
324	    case 1:							\
325	      fprintf ((FILE), "\\%03o", ch);				\
326	      break;							\
327	    default:							\
328	      putc ('\\', (FILE));					\
329	      putc (escape, (FILE));					\
330	      break;							\
331	    }								\
332        }								\
333      fprintf ((FILE), "\"\n");						\
334    }									\
335  while (0)
336
337
338#undef ASM_OUTPUT_ASCII
339#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)				\
340do {									\
341      register unsigned char *_ascii_bytes = (unsigned char *) (STR);	\
342      register unsigned char *limit = _ascii_bytes + (LENGTH);		\
343      register unsigned bytes_in_chunk = 0;				\
344      for (; _ascii_bytes < limit; _ascii_bytes++)			\
345        {								\
346	  register unsigned char *p;					\
347	  if (bytes_in_chunk >= 64)					\
348	    {								\
349	      fputc ('\n', (FILE));					\
350	      bytes_in_chunk = 0;					\
351	    }								\
352	  for (p = _ascii_bytes; p < limit && *p != '\0'; p++)		\
353	    continue;							\
354	  if (p < limit && (p - _ascii_bytes) <= STRING_LIMIT)		\
355	    {								\
356	      if (bytes_in_chunk > 0)					\
357		{							\
358		  fputc ('\n', (FILE));					\
359		  bytes_in_chunk = 0;					\
360		}							\
361	      ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);		\
362	      _ascii_bytes = p;						\
363	    }								\
364	  else								\
365	    {								\
366	      if (bytes_in_chunk == 0)					\
367		fprintf ((FILE), "%s\t", ASM_BYTE_OP);			\
368	      else							\
369		fputc (',', (FILE));					\
370	      fprintf ((FILE), "0x%02x", *_ascii_bytes);		\
371	      bytes_in_chunk += 5;					\
372	    }								\
373	}								\
374      if (bytes_in_chunk > 0)						\
375        fprintf ((FILE), "\n");						\
376} while (0)
377
378/* Must use data section for relocatable constants when pic.  */
379#undef SELECT_RTX_SECTION
380#define SELECT_RTX_SECTION(MODE,RTX)					\
381{									\
382  if (TARGET_ELF) {							\
383    if (flag_pic && symbolic_operand (RTX))				\
384      data_section ();							\
385    else								\
386      const_section ();							\
387  } else								\
388    readonly_data_section();						\
389}
390
391#undef ASM_OUTPUT_CASE_LABEL
392#define ASM_OUTPUT_CASE_LABEL(FILE,PREFIX,NUM,JUMPTABLE)		\
393do {									\
394  if (TARGET_ELF)							\
395    ASM_OUTPUT_ALIGN ((FILE), 2);					\
396  ASM_OUTPUT_INTERNAL_LABEL((FILE),(PREFIX),(NUM));			\
397} while (0)
398
399
400#undef ASM_OUTPUT_CONSTRUCTOR
401#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)				\
402do {									\
403  if (TARGET_ELF) {							\
404     ctors_section ();							\
405     fprintf (FILE, "%s\t ", INT_ASM_OP);				\
406     assemble_name (FILE, NAME);					\
407     fprintf (FILE, "\n");						\
408  } else {								\
409    init_section ();							\
410    fprintf (FILE, "\tpushl $");					\
411    assemble_name (FILE, NAME);						\
412    fprintf (FILE, "\n"); }						\
413  } while (0)
414
415#undef ASM_OUTPUT_DESTRUCTOR
416#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)				\
417do {									\
418  if (TARGET_ELF) {							\
419    dtors_section ();                   				\
420    fprintf (FILE, "%s\t ", INT_ASM_OP);				\
421    assemble_name (FILE, NAME);              				\
422    fprintf (FILE, "\n");						\
423  } else {								\
424    fini_section ();                   					\
425    fprintf (FILE, "%s\t ", ASM_LONG);					\
426    assemble_name (FILE, NAME);              				\
427    fprintf (FILE, "\n"); }						\
428  } while (0)
429
430
431#undef ASM_OUTPUT_IDENT
432#define ASM_OUTPUT_IDENT(FILE, NAME) \
433  fprintf (FILE, "%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
434
435#undef ASM_GLOBALIZE_LABEL
436#define ASM_GLOBALIZE_LABEL(FILE,NAME)	\
437  (fprintf ((FILE), "%s ", GLOBAL_ASM_OP), assemble_name (FILE, NAME), fputs ("\n", FILE))
438
439#undef ASM_OUTPUT_EXTERNAL_LIBCALL
440#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)				\
441  if (TARGET_ELF) ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
442
443#undef ASM_OUTPUT_INTERNAL_LABEL
444#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)			\
445  fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
446
447/* The prefix to add to user-visible assembler symbols. */
448
449#undef USER_LABEL_PREFIX
450#define USER_LABEL_PREFIX ""
451
452/*
453 * Compensate for the difference between ELF and COFF assembler syntax.
454 * Otherwise, this is cribbed from ../svr4.h.
455 * We rename 'gcc_except_table' to the shorter name in preparation
456 * for the day when we're ready to do DWARF2 eh unwinding under COFF
457 */
458#undef ASM_OUTPUT_SECTION_NAME
459#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
460do {									\
461  static struct section_info                                            \
462    {                                                                   \
463      struct section_info *next;                                        \
464      char *name;                                                       \
465      enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type;                \
466    } *sections;                                                        \
467  struct section_info *s;                                               \
468  char *mode;                                                           \
469  enum sect_enum type;                                                  \
470  char *sname = NAME ;							\
471  if (strcmp(NAME, ".gcc_except_table") == 0) sname = ".gccexc" ;	\
472                                                                        \
473  for (s = sections; s; s = s->next)                                    \
474    if (!strcmp (NAME, s->name))                                        \
475      break;                                                            \
476                                                                        \
477  if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                        \
478    type = SECT_EXEC, mode = (TARGET_ELF) ? "ax" : "x" ;                \
479  else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))                 \
480    type = SECT_RO, mode = "a";                                         \
481  else                                                                  \
482    type = SECT_RW, mode = (TARGET_ELF) ? "aw" : "w" ;                  \
483                                                                        \
484  if (s == 0)                                                           \
485    {                                                                   \
486      s = (struct section_info *) xmalloc (sizeof (struct section_info));  \
487      s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME));         \
488      strcpy (s->name, NAME);                                           \
489      s->type = type;                                                   \
490      s->next = sections;                                               \
491      sections = s;                                                     \
492      fprintf (FILE, ".section\t%s,\"%s\"%s\n", sname, mode,		\
493		(TARGET_ELF) ? ",@progbits" : "" );    			\
494    }                                                                   \
495  else                                                                  \
496    {                                                                   \
497      if (DECL && s->type != type)                                      \
498        error_with_decl (DECL, "%s causes a section type conflict");    \
499                                                                        \
500      fprintf (FILE, ".section\t%s\n", sname);                          \
501    }                                                                   \
502} while (0)
503
504#undef ASM_OUTPUT_SKIP
505#define ASM_OUTPUT_SKIP(FILE,SIZE) \
506do {									\
507  if (TARGET_ELF)							\
508    fprintf (FILE, "%s\t%u\n", SKIP_ASM_OP, (SIZE));			\
509  else									\
510    fprintf ((FILE), "%s\t.,.+%u\n", SET_ASM_OP, (SIZE));		\
511} while (0)
512
513
514#undef CTOR_LIST_BEGIN
515#define CTOR_LIST_BEGIN							\
516do {									\
517  asm (CTORS_SECTION_ASM_OP);						\
518  if (TARGET_ELF)							\
519    STATIC func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) };		\
520  else									\
521    asm ("pushl $0");							\
522} while (0)
523
524#undef CTOR_LIST_END
525#define CTOR_LIST_END							\
526do {									\
527  if (TARGET_ELF) {							\
528    asm (CTORS_SECTION_ASM_OP);						\
529    STATIC func_ptr __CTOR_LIST__[1] = { (func_ptr) (0) };		\
530  } else {								\
531    CTOR_LIST_BEGIN;							\
532  }									\
533} while (0)
534
535#undef DBX_BLOCKS_FUNCTION_RELATIVE
536#define DBX_BLOCKS_FUNCTION_RELATIVE 1
537
538#undef DBX_FUNCTION_FIRST
539#define DBX_FUNCTION_FIRST 1
540
541#undef DBX_REGISTER_NUMBER
542#define DBX_REGISTER_NUMBER(n)						\
543((TARGET_ELF) ?								\
544 ((n) == 0 ? 0 								\
545  : (n) == 1 ? 2 							\
546  : (n) == 2 ? 1 							\
547  : (n) == 3 ? 3 							\
548  : (n) == 4 ? 6 							\
549  : (n) == 5 ? 7 							\
550  : (n) == 6 ? 5 							\
551  : (n) == 7 ? 4 							\
552  : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 		\
553  : (-1))								\
554 :									\
555 ((n) == 0 ? 0 : 							\
556  (n) == 1 ? 2 : 							\
557  (n) == 2 ? 1 : 							\
558  (n) == 3 ? 3 : 							\
559  (n) == 4 ? 6 : 							\
560  (n) == 5 ? 7 : 							\
561  (n) == 6 ? 4 : 							\
562  (n) == 7 ? 5 : 							\
563  (n) + 4))
564
565#undef DWARF_DEBUGGING_INFO
566#undef SDB_DEBUGGING_INFO
567#undef DBX_DEBUGGING_INFO
568#undef PREFERRED_DEBUGGING_TYPE
569
570#define DWARF_DEBUGGING_INFO 1
571#define SDB_DEBUGGING_INFO   1
572#define DBX_DEBUGGING_INFO   1
573#define PREFERRED_DEBUGGING_TYPE					\
574  ((TARGET_ELF) ? DWARF_DEBUG: SDB_DEBUG)
575
576#undef EXTRA_SECTIONS
577#define EXTRA_SECTIONS in_const, in_init, in_fini, in_ctors, in_dtors
578
579#undef EXTRA_SECTION_FUNCTIONS
580#define EXTRA_SECTION_FUNCTIONS						\
581  CONST_SECTION_FUNCTION						\
582  INIT_SECTION_FUNCTION							\
583  FINI_SECTION_FUNCTION							\
584  CTORS_SECTION_FUNCTION						\
585  DTORS_SECTION_FUNCTION
586
587#undef CONST_SECTION_FUNCTION
588#define CONST_SECTION_FUNCTION						\
589void									\
590const_section ()							\
591{									\
592  extern void text_section();						\
593  if (!USE_CONST_SECTION)						\
594    text_section();							\
595  else if (in_section != in_const)					\
596    {									\
597      fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);		\
598      in_section = in_const;						\
599    }									\
600}
601
602#undef FINI_SECTION_FUNCTION
603#define FINI_SECTION_FUNCTION						\
604void									\
605fini_section ()								\
606{									\
607  if ((!TARGET_ELF) && in_section != in_fini)				\
608    {									\
609      fprintf (asm_out_file, "%s\n", FINI_SECTION_ASM_OP);		\
610      in_section = in_fini;						\
611    }									\
612}
613
614#undef INIT_SECTION_FUNCTION
615#define INIT_SECTION_FUNCTION						\
616void									\
617init_section ()								\
618{									\
619  if ((!TARGET_ELF) && in_section != in_init)				\
620    {									\
621      fprintf (asm_out_file, "%s\n", INIT_SECTION_ASM_OP);		\
622      in_section = in_init;						\
623    }									\
624}
625
626#undef CTORS_SECTION_FUNCTION
627#define CTORS_SECTION_FUNCTION						\
628void									\
629ctors_section ()							\
630{									\
631  if (in_section != in_ctors)						\
632    {									\
633      fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);		\
634      in_section = in_ctors;						\
635    }									\
636}
637
638#undef DTORS_SECTION_FUNCTION
639#define DTORS_SECTION_FUNCTION						\
640void									\
641dtors_section ()							\
642{									\
643  if (in_section != in_dtors)						\
644    {									\
645      fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);		\
646      in_section = in_dtors;						\
647    }									\
648}
649
650#undef FRAME_POINTER_REQUIRED
651#define FRAME_POINTER_REQUIRED						\
652  ((TARGET_ELF) ? 0 : 							\
653   (current_function_calls_setjmp || current_function_calls_longjmp))
654
655#undef JUMP_TABLES_IN_TEXT_SECTION
656#define JUMP_TABLES_IN_TEXT_SECTION (TARGET_ELF && flag_pic)
657
658#undef LOCAL_LABEL_PREFIX
659#define LOCAL_LABEL_PREFIX						\
660 ((TARGET_ELF) ? "" : ".")
661
662#undef MD_EXEC_PREFIX
663#undef MD_STARTFILE_PREFIX
664#define MD_EXEC_PREFIX "/usr/ccs/bin/"
665#define MD_STARTFILE_PREFIX "/usr/ccs/lib/"
666
667#undef NON_SAVING_SETJMP
668#define NON_SAVING_SETJMP						\
669  ((TARGET_ELF) ? 0 : 							\
670   (current_function_calls_setjmp && current_function_calls_longjmp))
671
672#undef NO_IMPLICIT_EXTERN_C
673#define NO_IMPLICIT_EXTERN_C 1
674
675/* JKJ FIXME - examine the ramifications of RETURN_IN_MEMORY and
676   RETURN_POPS_ARGS */
677
678#undef RETURN_POPS_ARGS
679#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 				\
680 ((TARGET_ELF) ?							\
681  (i386_return_pops_args (FUNDECL, FUNTYPE, SIZE)) : 			\
682  (((FUNDECL) && (TREE_CODE (FUNDECL) == IDENTIFIER_NODE)) ? 0		\
683   : (TARGET_RTD							\
684      && (TYPE_ARG_TYPES (FUNTYPE) == 0					\
685	  || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE)))		\
686	      == void_type_node))) ? (SIZE)				\
687   : 0))
688
689#undef SELECT_SECTION
690#define SELECT_SECTION(DECL,RELOC)					\
691{									\
692  if (TREE_CODE (DECL) == STRING_CST)					\
693    {									\
694      if (! flag_writable_strings)					\
695	const_section ();						\
696      else								\
697	data_section ();						\
698    }									\
699  else if (TREE_CODE (DECL) == VAR_DECL)				\
700    {									\
701      if ((TARGET_ELF && flag_pic && RELOC)				\
702	  || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)		\
703	  || !DECL_INITIAL (DECL)					\
704	  || (DECL_INITIAL (DECL) != error_mark_node			\
705	      && !TREE_CONSTANT (DECL_INITIAL (DECL))))			\
706	data_section ();						\
707      else								\
708	const_section ();						\
709    }									\
710  else									\
711    const_section ();							\
712}
713
714#undef SWITCH_TAKES_ARG
715#define SWITCH_TAKES_ARG(CHAR) 						\
716  (DEFAULT_SWITCH_TAKES_ARG(CHAR)					\
717   || (CHAR) == 'h' 							\
718   || (CHAR) == 'R' 							\
719   || (CHAR) == 'Y' 							\
720   || (CHAR) == 'z')
721
722#undef WORD_SWITCH_TAKES_ARG
723#define WORD_SWITCH_TAKES_ARG(STR)					\
724 (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
725  && strcmp (STR, "Tdata") && strcmp (STR, "Ttext")			\
726  && strcmp (STR, "Tbss"))
727
728#undef TARGET_DEFAULT
729#define TARGET_DEFAULT 0301
730
731#undef HANDLE_SYSV_PRAGMA
732#define HANDLE_SYSV_PRAGMA 1
733
734#undef SCCS_DIRECTIVE
735#define SCCS_DIRECTIVE 1
736
737/*
738 * Define sizes and types
739 */
740#undef SIZE_TYPE
741#undef PTRDIFF_TYPE
742#undef WCHAR_TYPE
743#undef WCHAR_TYPE_SIZE
744#undef LONG_DOUBLE_TYPE_SIZE
745#define LONG_DOUBLE_TYPE_SIZE 	96
746#define SIZE_TYPE		"unsigned int"
747#define PTRDIFF_TYPE		"int"
748#define WCHAR_TYPE		"long int"
749#define WCHAR_TYPE_SIZE		BITS_PER_WORD
750
751/*
752 * New for multilib support. Set the default switches for multilib,
753 * which is -melf.
754 */
755#define MULTILIB_DEFAULTS { "melf" }
756
757
758/* Please note that these specs may look messy but they are required in
759   order to emulate the SCO Development system as closely as possible.
760   With SCO Open Server 5.0, you now get the linker and assembler free,
761   so that is what these specs are targeted for. These utilities are
762   very argument sensitive: a space in the wrong place breaks everything.
763   So RMS, please forgive this mess. It works.
764
765   Parameters which can be passed to gcc, and their SCO equivalents:
766   GCC Parameter                SCO Equivalent
767   -ansi                        -a ansi
768   -posix                       -a posix
769   -Xpg4                        -a xpg4
770   -Xpg4plus                    -a xpg4plus
771   -Xods30                      -a ods30
772
773   As with SCO, the default is XPG4 plus mode. SCO also allows you to
774   specify a C dialect with -Xt, -Xa, -Xc, -Xk and -Xm. These are passed
775   on to the assembler and linker in the same way that the SCO compiler
776   does.
777
778   SCO also allows you to compile, link and generate either ELF or COFF
779   binaries. With gcc, unlike the SCO compiler, the default is ELF.
780   Specify -mcoff to gcc to produce COFF binaries. -fpic will get the
781   assembler and linker to produce PIC code.
782*/
783
784/* Set up assembler flags for PIC and ELF compilations */
785#undef ASM_SPEC
786
787#if USE_GAS
788  /* Leave ASM_SPEC undefined so we pick up the master copy from gcc.c
789   * Undef MD_EXEC_PREFIX becuase we don't know where GAS is, but it's not
790   * likely in /usr/ccs/bin/
791   */
792#undef MD_EXEC_PREFIX
793#else
794
795#define ASM_SPEC \
796   "-b %{!mcoff:elf}%{mcoff:coff \
797     %{static:%e-static not valid with -mcoff} \
798     %{shared:%e-shared not valid with -mcoff} \
799     %{symbolic:%e-symbolic not valid with -mcoff}} \
800    %{Ym,*} %{Yd,*} %{Wa,*:%*} \
801    %{!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}}"
802#endif
803
804/* Use crt1.o as a startup file and crtn.o as a closing file.  */
805
806#undef STARTFILE_SPEC
807#define STARTFILE_SPEC \
808 "%{shared: %{!mcoff: crti.o%s}} \
809  %{!shared:\
810   %{!symbolic: \
811    %{pg:gcrt.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}} \
812  %{ansi:values-Xc.o%s} \
813  %{!ansi: \
814   %{traditional:values-Xt.o%s} \
815    %{!traditional: \
816     %{Xa:values-Xa.o%s} \
817      %{!Xa:%{Xc:values-Xc.o%s} \
818       %{!Xc:%{Xk:values-Xk.o%s} \
819        %{!Xk:%{Xt:values-Xt.o%s} \
820         %{!Xt:values-Xa.o%s}}}}}} \
821  %{mcoff:crtbeginS.o%s} %{!mcoff:crtbegin.o%s}"
822
823#undef ENDFILE_SPEC
824#define ENDFILE_SPEC \
825 "%{!mcoff:crtend.o%s} \
826  %{mcoff:crtendS.o%s} \
827  %{pg:gcrtn.o%s}%{!pg:crtn.o%s}"
828
829#undef CPP_PREDEFINES
830#define CPP_PREDEFINES \
831 "-Asystem(svr3)"
832
833/* You are in a maze of GCC specs ... all alike */
834
835#undef CPP_SPEC
836#define CPP_SPEC "%(cpp_cpu) \
837  %{fpic:%{mcoff:%e-fpic is not valid with -mcoff}} \
838  %{fPIC:%{mcoff:%e-fPIC is not valid with -mcoff}} \
839  -D__i386 -D__unix -D_SCO_DS=1 -D_M_I386 -D_M_XENIX -D_M_UNIX \
840  %{!Xods30:-D_STRICT_NAMES} \
841  %{!ansi:%{!posix:%{!Xods30:-D_SCO_XPG_VERS=4}}} \
842  %{ansi:-isystem include/ansi%s -isystem /usr/include/ansi -D_STRICT_ANSI} \
843  %{!ansi: \
844   %{posix:-isystem include/posix%s -isystem /usr/include/posix \
845           -D_POSIX_C_SOURCE=2 -D_POSIX_SOURCE=1} \
846    %{!posix:%{Xpg4:-isystem include/xpg4%s -isystem /usr/include/xpg4 \
847                    -D_XOPEN_SOURCE=1} \
848     %{!Xpg4:-D_M_I86 -D_M_I86SM -D_M_INTERNAT -D_M_SDATA -D_M_STEXT \
849             -D_M_BITFIELDS -D_M_SYS5 -D_M_SYSV -D_M_SYSIII \
850             -D_M_WORDSWAP -Dunix -DM_I386 -DM_UNIX -DM_XENIX \
851             %{Xods30:-isystem include/ods_30_compat%s \
852                      -isystem /usr/include/ods_30_compat \
853                      -D_SCO_ODS_30 -DM_I86 -DM_I86SM -DM_SDATA -DM_STEXT \
854                      -DM_BITFIELDS -DM_SYS5 -DM_SYSV -DM_INTERNAT -DM_SYSIII \
855                      -DM_WORDSWAP}}}} \
856  %{scointl:-DM_INTERNAT -D_M_INTERNAT} \
857  %{traditional:-D_KR -D_SVID -D_NO_PROTOTYPE} \
858  %{!mcoff:-D_SCO_ELF} \
859  %{mcoff:-D_M_COFF -D_SCO_COFF} \
860  %{!mcoff:%{fpic:-D__PIC__ -D__pic__} \
861         %{fPIC:%{!fpic:-D__PIC__ -D__pic__}}} \
862  %{Xa:-D_SCO_C_DIALECT=1} \
863  %{!Xa:%{Xc:-D_SCO_C_DIALECT=3} \
864   %{!Xc:%{Xk:-D_SCO_C_DIALECT=4} \
865    %{!Xk:%{Xt:-D_SCO_C_DIALECT=2} \
866     %{!Xt:-D_SCO_C_DIALECT=1}}}} \
867  %{traditional:-traditional -D_KR -D_NO_PROTOTYPE}"
868
869#undef LINK_SPEC
870#define LINK_SPEC \
871 "-b %{!mcoff:elf}%{mcoff:coff \
872   %{static:%e-static not valid with -mcoff} \
873   %{shared:%e-shared not valid with -mcoff} \
874   %{symbolic:%e-symbolic not valid with -mcoff} \
875   %{fpic:%e-fpic not valid with -mcoff} \
876   %{fPIC:%e-fPIC not valid with -mcoff}} \
877  -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} \
878  %{Wl,*%*} %{YP,*} %{YL,*} %{YU,*} \
879  %{!YP,*:%{p:-YP,/usr/ccs/libp:/lib/libp:/usr/lib/libp:/usr/ccs/lib:/lib:/usr/lib} \
880   %{!p:-YP,/usr/ccs/lib:/lib:/usr/lib}} \
881  %{h*} %{static:-dn -Bstatic} %{shared:-G -dy %{!z*:-z text}} \
882  %{symbolic:-Bsymbolic -G -dy %{!z*:-z text}} %{z*} %{R*} %{Y*} \
883  %{G:-G} %{!mcoff:%{Qn:} %{!Qy:-Qn}}"
884
885/* The SCO COFF linker gets confused on the difference between "-ofoo"
886   and "-o foo".   So we just always force a single space. */
887
888#define SWITCHES_NEED_SPACES "o"
889
890/* Library spec. If we are not building a shared library, provide the
891   standard libraries, as per the SCO compiler.  */
892
893#undef LIB_SPEC
894#define LIB_SPEC \
895 "%{shared:pic/libgcc.a%s}%{!shared:%{!symbolic:-lcrypt -lgen -lc}}"
896
897#undef LIBGCC_SPEC
898#define LIBGCC_SPEC \
899 "%{!shared:-lgcc}"
900
901#define MASK_COFF     		010000000000	/* Mask for elf generation */
902#define TARGET_COFF             (target_flags & MASK_COFF)
903#define TARGET_ELF              (!(target_flags & MASK_COFF))
904
905#undef SUBTARGET_SWITCHES
906#define SUBTARGET_SWITCHES 		\
907	{ "coff", MASK_COFF }, 		\
908	{ "elf", -MASK_COFF },
909
910#define NO_DOLLAR_IN_LABEL
911
912/*
913Here comes some major hackery to get the crt stuff to compile properly.
914Since we can (and do) compile for both COFF and ELF environments, we
915set things up accordingly, based on the pre-processor defines for ELF
916and COFF. This is insane, but then I guess having one compiler with a
917single back-end supporting two vastly different file format types is
918a little insane too. But it is not impossible and we get a useful
919compiler at the end of the day. Onward we go ...
920*/
921
922#if defined(CRT_BEGIN) || defined(CRT_END) || defined(IN_LIBGCC2)
923# undef OBJECT_FORMAT_ELF
924# undef HAVE_ATEXIT
925# undef INIT_SECTION_ASM_OP
926# undef FINI_SECTION_ASM_OP
927# undef CTORS_SECTION_ASM_OP
928# undef DTORS_SECTION_ASM_OP
929# undef EH_FRAME_SECTION_ASM_OP
930# undef CTOR_LIST_BEGIN
931# undef CTOR_LIST_END
932# undef DO_GLOBAL_CTORS_BODY
933
934# if defined (_SCO_ELF)
935#  define OBJECT_FORMAT_ELF
936#  define HAVE_ATEXIT 1
937#  define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_ELF
938#  define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_ELF
939#  define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_ELF
940#  define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_ELF
941#  define EH_FRAME_SECTION_ASM_OP EH_FRAME_SECTION_ASM_OP_ELF
942# else /* ! _SCO_ELF */
943#  define INIT_SECTION_ASM_OP INIT_SECTION_ASM_OP_COFF
944#  define FINI_SECTION_ASM_OP FINI_SECTION_ASM_OP_COFF
945#  define DTORS_SECTION_ASM_OP DTORS_SECTION_ASM_OP_COFF
946#  define CTORS_SECTION_ASM_OP CTORS_SECTION_ASM_OP_COFF
947#  define EH_FRAME_SECTION_ASM_OP ""
948#  define CTOR_LIST_BEGIN asm (INIT_SECTION_ASM_OP); asm ("pushl $0")
949#  define CTOR_LIST_END CTOR_LIST_BEGIN
950#  define DO_GLOBAL_CTORS_BODY						\
951do {									\
952     func_ptr *p, *beg = alloca(0);					\
953     for (p = beg; *p;)							\
954      (*p++) ();							\
955} while (0)
956# endif /* ! _SCO_ELF */
957#endif /* CRT_BEGIN !! CRT_END */
958