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