]> gcc.gnu.org Git - gcc.git/blame - gcc/config/elfos.h
pa-64.h (WCHAR_TYPE, [...]): Define.
[gcc.git] / gcc / config / elfos.h
CommitLineData
d1be3be3
JW
1/* elfos.h -- operating system specific defines to be used when
2 targeting GCC for some generic ELF system
3dbd1134
AO
3 Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001
4 Free Software Foundation, Inc.
d1be3be3
JW
5 Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com).
6
7This file is part of GNU CC.
8
9GNU CC is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GNU CC is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU CC; see the file COPYING. If not, write to
63fdf24a
JL
21the Free Software Foundation, 59 Temple Place - Suite 330,
22Boston, MA 02111-1307, USA. */
d1be3be3 23
f6cad4c9
NC
24/* The prefix to add to user-visible assembler symbols.
25
26 For ELF systems the convention is *not* to prepend a leading
27 underscore onto user-level symbol names. */
28
29#undef USER_LABEL_PREFIX
30#define USER_LABEL_PREFIX ""
31
32/* Biggest alignment supported by the object file format of this
33 machine. Use this macro to limit the alignment which can be
34 specified using the `__attribute__ ((aligned (N)))' construct. If
35 not defined, the default value is `BIGGEST_ALIGNMENT'. */
36#ifndef MAX_OFILE_ALIGNMENT
37#define MAX_OFILE_ALIGNMENT (32768 * 8)
38#endif
39
d1be3be3
JW
40#undef ENDFILE_SPEC
41#define ENDFILE_SPEC "crtend.o%s"
42
43#undef STARTFILE_SPEC
44#define STARTFILE_SPEC "%{!shared: \
45 %{!symbolic: \
46 %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
47 crtbegin.o%s"
48
d1be3be3
JW
49/* Use periods rather than dollar signs in special g++ assembler names. */
50
51#define NO_DOLLAR_IN_LABEL
52
53/* Writing `int' for a bitfield forces int alignment for the structure. */
54
55#define PCC_BITFIELD_TYPE_MATTERS 1
56
57/* Implicit library calls should use memcpy, not bcopy, etc. */
58
59#define TARGET_MEM_FUNCTIONS
60
61/* Handle #pragma weak and #pragma pack. */
62
63#define HANDLE_SYSV_PRAGMA
64
65/* System V Release 4 uses DWARF debugging info. */
66
d1476635
JS
67#ifndef DWARF_DEBUGGING_INFO
68#define DWARF_DEBUGGING_INFO 1
69#endif
d1be3be3
JW
70
71/* All ELF targets can support DWARF-2. */
72
d1476635
JS
73#ifndef DWARF2_DEBUGGING_INFO
74#define DWARF2_DEBUGGING_INFO 1
75#endif
d1be3be3 76
cedcf937 77/* Also allow them to support STABS debugging. */
d1be3be3 78
cedcf937 79#include "dbxelf.h"
d1be3be3
JW
80
81/* The GNU tools operate better with stabs. Since we don't have
82 any native tools to be compatible with, default to stabs. */
83
84#ifndef PREFERRED_DEBUGGING_TYPE
85#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
86#endif
87
f6cad4c9
NC
88/* All SVR4 targets use the ELF object file format. */
89#define OBJECT_FORMAT_ELF
90
91
92/* Output #ident as a .ident. */
93
94#define ASM_OUTPUT_IDENT(FILE, NAME) \
ca13100a 95 fprintf (FILE, "%s\"%s\"\n", IDENT_ASM_OP, NAME);
f6cad4c9
NC
96
97/* Attach a special .ident directive to the end of the file to identify
98 the version of GCC which compiled this code. The format of the
99 .ident string is patterned after the ones produced by native svr4
100 C compilers. */
101
e662a129 102#define IDENT_ASM_OP "\t.ident\t"
f6cad4c9 103
4cf12e7e 104#undef ASM_FILE_END
f6cad4c9
NC
105#define ASM_FILE_END(FILE) \
106 do \
107 { \
108 if (!flag_no_ident) \
ca13100a 109 fprintf ((FILE), "%s\"GCC: (GNU) %s\"\n", \
f6cad4c9
NC
110 IDENT_ASM_OP, version_string); \
111 } \
112 while (0)
113
114#undef ASM_BYTE_OP
e662a129 115#define ASM_BYTE_OP "\t.byte\t"
d1be3be3 116
f6cad4c9 117#undef SET_ASM_OP
e662a129 118#define SET_ASM_OP "\t.set\t"
d1be3be3
JW
119
120/* This is how to begin an assembly language file. Most svr4 assemblers want
121 at least a .file directive to come first, and some want to see a .version
122 directive come right after that. Here we just establish a default
123 which generates only the .file directive. If you need a .version
124 directive for any specific target, you should override this definition
125 in the target-specific file which includes this one. */
126
127#undef ASM_FILE_START
f6cad4c9 128#define ASM_FILE_START(FILE) \
d1be3be3
JW
129 output_file_directive ((FILE), main_input_filename)
130
131/* This is how to allocate empty space in some section. The .zero
132 pseudo-op is used for this on most svr4 assemblers. */
133
e662a129 134#define SKIP_ASM_OP "\t.zero\t"
d1be3be3 135
f6cad4c9
NC
136#undef ASM_OUTPUT_SKIP
137#define ASM_OUTPUT_SKIP(FILE, SIZE) \
ca13100a 138 fprintf (FILE, "%s%u\n", SKIP_ASM_OP, (SIZE))
d1be3be3 139
d1be3be3
JW
140/* This is how to output an internal numbered label where
141 PREFIX is the class of label and NUM is the number within the class.
142
143 For most svr4 systems, the convention is that any symbol which begins
144 with a period is not put into the linker symbol table by the assembler. */
145
f6cad4c9
NC
146#undef ASM_OUTPUT_INTERNAL_LABEL
147#define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
148 do \
149 { \
150 fprintf (FILE, ".%s%d:\n", PREFIX, NUM); \
151 } \
152 while (0)
d1be3be3
JW
153
154/* This is how to store into the string LABEL
155 the symbol_ref name of an internal numbered label where
156 PREFIX is the class of label and NUM is the number within the class.
157 This is suitable for output with `assemble_name'.
158
159 For most svr4 systems, the convention is that any symbol which begins
160 with a period is not put into the linker symbol table by the assembler. */
161
f6cad4c9
NC
162#undef ASM_GENERATE_INTERNAL_LABEL
163#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
164 do \
165 { \
33261b0a 166 sprintf (LABEL, "*.%s%u", PREFIX, (unsigned) (NUM)); \
f6cad4c9
NC
167 } \
168 while (0)
d1be3be3
JW
169
170/* Output the label which precedes a jumptable. Note that for all svr4
171 systems where we actually generate jumptables (which is to say every
172 svr4 target except i386, where we use casesi instead) we put the jump-
173 tables into the .rodata section and since other stuff could have been
174 put into the .rodata section prior to any given jumptable, we have to
175 make sure that the location counter for the .rodata section gets pro-
176 perly re-aligned prior to the actual beginning of the jump table. */
177
e662a129 178#define ALIGN_ASM_OP "\t.align\t"
d1be3be3
JW
179
180#ifndef ASM_OUTPUT_BEFORE_CASE_LABEL
f6cad4c9 181#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \
d1be3be3
JW
182 ASM_OUTPUT_ALIGN ((FILE), 2);
183#endif
184
f6cad4c9
NC
185#undef ASM_OUTPUT_CASE_LABEL
186#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
187 do \
188 { \
189 ASM_OUTPUT_BEFORE_CASE_LABEL (FILE, PREFIX, NUM, JUMPTABLE) \
190 ASM_OUTPUT_INTERNAL_LABEL (FILE, PREFIX, NUM); \
191 } \
192 while (0)
d1be3be3
JW
193
194/* The standard SVR4 assembler seems to require that certain builtin
195 library routines (e.g. .udiv) be explicitly declared as .globl
196 in each assembly file where they are referenced. */
197
f6cad4c9 198#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
d1be3be3
JW
199 ASM_GLOBALIZE_LABEL (FILE, XSTR (FUN, 0))
200
201/* This says how to output assembler code to declare an
202 uninitialized external linkage data object. Under SVR4,
203 the linker seems to want the alignment of data objects
204 to depend on their types. We do exactly that here. */
205
e662a129 206#define COMMON_ASM_OP "\t.comm\t"
d1be3be3 207
f6cad4c9 208#undef ASM_OUTPUT_ALIGNED_COMMON
d1be3be3 209#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
f6cad4c9
NC
210 do \
211 { \
ca13100a 212 fprintf ((FILE), "%s", COMMON_ASM_OP); \
f6cad4c9
NC
213 assemble_name ((FILE), (NAME)); \
214 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
215 } \
216 while (0)
d1be3be3
JW
217
218/* This says how to output assembler code to declare an
219 uninitialized internal linkage data object. Under SVR4,
220 the linker seems to want the alignment of data objects
221 to depend on their types. We do exactly that here. */
222
e662a129 223#define LOCAL_ASM_OP "\t.local\t"
d1be3be3 224
f6cad4c9
NC
225#undef ASM_OUTPUT_ALIGNED_LOCAL
226#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
227 do \
228 { \
ca13100a 229 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
f6cad4c9
NC
230 assemble_name ((FILE), (NAME)); \
231 fprintf ((FILE), "\n"); \
232 ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
233 } \
234 while (0)
d1be3be3 235
3dbd1134
AO
236/* This is the pseudo-op used to generate a reference to a specific
237 symbol in some section. It is only used in machine-specific
238 configuration files, typically only in ASM_OUTPUT_CONSTRUCTOR and
239 ASM_OUTPUT_DESTRUCTOR. This is the same for all known svr4
240 assemblers, except those in targets that don't use 32-bit pointers.
241 Those should override INT_ASM_OP. Yes, the name of the macro is
242 misleading. */
d1be3be3 243
3dbd1134 244#ifndef INT_ASM_OP
e662a129 245#define INT_ASM_OP "\t.long\t"
3dbd1134 246#endif
d1be3be3
JW
247
248/* This is the pseudo-op used to generate a contiguous sequence of byte
249 values from a double-quoted string WITHOUT HAVING A TERMINATING NUL
250 AUTOMATICALLY APPENDED. This is the same for most svr4 assemblers. */
251
f6cad4c9 252#undef ASCII_DATA_ASM_OP
e662a129 253#define ASCII_DATA_ASM_OP "\t.ascii\t"
d1be3be3
JW
254
255/* Support const sections and the ctors and dtors sections for g++.
256 Note that there appears to be two different ways to support const
257 sections at the moment. You can either #define the symbol
258 READONLY_DATA_SECTION (giving it some code which switches to the
259 readonly data section) or else you can #define the symbols
260 EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
261 SELECT_RTX_SECTION. We do both here just to be on the safe side. */
262
263#define USE_CONST_SECTION 1
264
f6cad4c9 265#define CONST_SECTION_ASM_OP "\t.section\t.rodata"
d1be3be3
JW
266
267/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
268
269 Note that we want to give these sections the SHF_WRITE attribute
270 because these sections will actually contain data (i.e. tables of
271 addresses of functions in the current root executable or shared library
272 file) and, in the case of a shared library, the relocatable addresses
273 will have to be properly resolved/relocated (and then written into) by
274 the dynamic linker when it actually attaches the given shared library
275 to the executing process. (Note that on SVR4, you may wish to use the
276 `-z text' option to the ELF linker, when building a shared library, as
277 an additional check that you are doing everything right. But if you do
278 use the `-z text' option when building a shared library, you will get
279 errors unless the .ctors and .dtors sections are marked as writable
280 via the SHF_WRITE attribute.) */
281
f6cad4c9
NC
282#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\""
283#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\""
d1be3be3
JW
284
285/* On svr4, we *do* have support for the .init and .fini sections, and we
286 can put stuff in there to be executed before and after `main'. We let
287 crtstuff.c and other files know this by defining the following symbols.
288 The definitions say how to change sections to the .init and .fini
289 sections. This is the same for all known svr4 assemblers. */
290
f6cad4c9
NC
291#define INIT_SECTION_ASM_OP "\t.section\t.init"
292#define FINI_SECTION_ASM_OP "\t.section\t.fini"
d1be3be3
JW
293
294/* A default list of other sections which we might be "in" at any given
295 time. For targets that use additional sections (e.g. .tdesc) you
296 should override this definition in the target-specific file which
297 includes this file. */
298
f6cad4c9 299#undef EXTRA_SECTIONS
d1be3be3
JW
300#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
301
302/* A default list of extra section function definitions. For targets
303 that use additional sections (e.g. .tdesc) you should override this
304 definition in the target-specific file which includes this file. */
305
f6cad4c9
NC
306#undef EXTRA_SECTION_FUNCTIONS
307#define EXTRA_SECTION_FUNCTIONS \
308 CONST_SECTION_FUNCTION \
309 CTORS_SECTION_FUNCTION \
d1be3be3
JW
310 DTORS_SECTION_FUNCTION
311
312#define READONLY_DATA_SECTION() const_section ()
313
f6cad4c9
NC
314#define CONST_SECTION_FUNCTION \
315void \
316const_section () \
317{ \
318 if (!USE_CONST_SECTION) \
319 text_section (); \
320 else if (in_section != in_const) \
321 { \
ca13100a 322 fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP); \
f6cad4c9
NC
323 in_section = in_const; \
324 } \
d1be3be3
JW
325}
326
f6cad4c9
NC
327#define CTORS_SECTION_FUNCTION \
328void \
329ctors_section () \
330{ \
331 if (in_section != in_ctors) \
332 { \
ca13100a 333 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
f6cad4c9
NC
334 in_section = in_ctors; \
335 } \
d1be3be3
JW
336}
337
f6cad4c9
NC
338#define DTORS_SECTION_FUNCTION \
339void \
340dtors_section () \
341{ \
342 if (in_section != in_dtors) \
343 { \
ca13100a 344 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
f6cad4c9
NC
345 in_section = in_dtors; \
346 } \
d1be3be3
JW
347}
348
f6cad4c9 349#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
d1be3be3 350
f6cad4c9 351#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
d1be3be3 352
f6cad4c9
NC
353#define UNIQUE_SECTION(DECL, RELOC) \
354 do \
d1be3be3 355 { \
f6cad4c9
NC
356 int len; \
357 int sec; \
7bdb32b9 358 const char *name; \
f6cad4c9 359 char *string; \
7bdb32b9 360 const char *prefix; \
e8c3586a 361 static const char *prefixes[/*4*/3][2] = \
f6cad4c9
NC
362 { \
363 { ".text.", ".gnu.linkonce.t." }, \
364 { ".rodata.", ".gnu.linkonce.r." }, \
e8c3586a 365 { ".data.", ".gnu.linkonce.d." } \
f6cad4c9
NC
366 /* Do not generate unique sections for uninitialised \
367 data since we do not have support for this in the \
368 linker scripts yet... \
e8c3586a 369 ,{ ".bss.", ".gnu.linkonce.b." } */ \
f6cad4c9
NC
370 }; \
371 \
d1be3be3 372 if (TREE_CODE (DECL) == FUNCTION_DECL) \
f6cad4c9 373 sec = 0; \
e8c3586a 374 /* else if (DECL_INITIAL (DECL) == 0 \
f6cad4c9 375 || DECL_INITIAL (DECL) == error_mark_node) \
e8c3586a 376 sec = 3; */ \
d1be3be3 377 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
f6cad4c9 378 sec = 1; \
d1be3be3 379 else \
f6cad4c9
NC
380 sec = 2; \
381 \
382 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
c690f089
HPN
383 /* Strip off any encoding in name. */ \
384 STRIP_NAME_ENCODING (name, name); \
f6cad4c9
NC
385 prefix = prefixes[sec][DECL_ONE_ONLY(DECL)]; \
386 len = strlen (name) + strlen (prefix); \
387 string = alloca (len + 1); \
388 \
389 sprintf (string, "%s%s", prefix, name); \
390 \
391 DECL_SECTION_NAME (DECL) = build_string (len, string); \
d1be3be3 392 } \
f6cad4c9
NC
393 while (0)
394
395/* A C statement (sans semicolon) to output an
396 element in the table of global constructors. */
397#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
398 do \
399 { \
400 ctors_section (); \
ca13100a 401 fprintf (FILE, "%s", INT_ASM_OP); \
f6cad4c9
NC
402 assemble_name (FILE, NAME); \
403 fprintf (FILE, "\n"); \
404 } \
405 while (0)
d1be3be3 406
f6cad4c9
NC
407/* A C statement (sans semicolon) to output an
408 element in the table of global destructors. */
409#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
410 do \
411 { \
412 dtors_section (); \
ca13100a 413 fprintf (FILE, "%s", INT_ASM_OP); \
f6cad4c9
NC
414 assemble_name (FILE, NAME); \
415 fprintf (FILE, "\n"); \
416 } \
417 while (0)
d1be3be3 418
f6cad4c9
NC
419/* Switch into a generic section.
420
421 We make the section read-only and executable for a function decl,
422 read-only for a const data decl, and writable for a non-const data decl.
423
424 If the section has already been defined, we must not
425 emit the attributes here. The SVR4 assembler does not
426 recognize section redefinitions.
427 If DECL is NULL, no attributes are emitted. */
428
429#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
430 do \
d1be3be3 431 { \
231db5f4
MM
432 static htab_t htab; \
433 \
434 struct section_info \
f6cad4c9 435 { \
f6cad4c9 436 enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
231db5f4
MM
437 }; \
438 \
f6cad4c9
NC
439 struct section_info *s; \
440 const char *mode; \
231db5f4
MM
441 enum sect_enum type; \
442 PTR* slot; \
443 \
444 /* The names we put in the hashtable will always be the unique \
445 versions gived to us by the stringtable, so we can just use \
446 their addresses as the keys. */ \
447 if (!htab) \
448 htab = htab_create (31, \
449 htab_hash_pointer, \
450 htab_eq_pointer, \
451 NULL); \
452 \
f6cad4c9
NC
453 if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
454 type = SECT_EXEC, mode = "ax"; \
455 else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
456 type = SECT_RO, mode = "a"; \
d1be3be3 457 else \
f6cad4c9
NC
458 type = SECT_RW, mode = "aw"; \
459 \
231db5f4
MM
460 \
461 /* See if we already have an entry for this section. */ \
462 slot = htab_find_slot (htab, NAME, INSERT); \
463 if (!*slot) \
464 { \
f6cad4c9 465 s = (struct section_info *) xmalloc (sizeof (* s)); \
f6cad4c9 466 s->type = type; \
231db5f4 467 *slot = s; \
f6cad4c9
NC
468 fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \
469 NAME, mode); \
470 } \
d1be3be3 471 else \
f6cad4c9 472 { \
231db5f4 473 s = (struct section_info *) *slot; \
f6cad4c9 474 if (DECL && s->type != type) \
231db5f4
MM
475 error_with_decl (DECL, \
476 "%s causes a section type conflict"); \
f6cad4c9
NC
477 \
478 fprintf (FILE, "\t.section\t%s\n", NAME); \
479 } \
d1be3be3 480 } \
f6cad4c9 481 while (0)
d1be3be3
JW
482
483/* A C statement or statements to switch to the appropriate
484 section for output of RTX in mode MODE. RTX is some kind
485 of constant in RTL. The argument MODE is redundant except
486 in the case of a `const_int' rtx. Currently, these always
487 go into the const section. */
488
f6cad4c9
NC
489#undef SELECT_RTX_SECTION
490#define SELECT_RTX_SECTION(MODE, RTX) const_section ()
491
492/* A C statement or statements to switch to the appropriate
493 section for output of DECL. DECL is either a `VAR_DECL' node
494 or a constant of some sort. RELOC indicates whether forming
495 the initial value of DECL requires link-time relocations. */
496
497#define SELECT_SECTION(DECL, RELOC) \
498{ \
499 if (TREE_CODE (DECL) == STRING_CST) \
500 { \
501 if (! flag_writable_strings) \
502 const_section (); \
503 else \
504 data_section (); \
505 } \
f2b33981 506 else if (TREE_CODE (DECL) == VAR_DECL) \
f6cad4c9
NC
507 { \
508 if ((flag_pic && RELOC) \
509 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
510 || !DECL_INITIAL (DECL) \
511 || (DECL_INITIAL (DECL) != error_mark_node \
512 && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \
513 data_section (); \
514 else \
515 const_section (); \
516 } \
f2b33981
RK
517 else if (TREE_CODE (DECL) == CONSTRUCTOR) \
518 { \
519 if ((flag_pic && RELOC) \
520 || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \
521 || ! TREE_CONSTANT (DECL)) \
522 data_section (); \
523 else \
524 const_section (); \
525 } \
f6cad4c9
NC
526 else \
527 const_section (); \
528}
d1be3be3
JW
529
530/* Define the strings used for the special svr4 .type and .size directives.
531 These strings generally do not vary from one system running svr4 to
532 another, but if a given system (e.g. m88k running svr) needs to use
533 different pseudo-op names for these, they may be overridden in the
534 file which includes this one. */
535
e662a129
HPN
536#define TYPE_ASM_OP "\t.type\t"
537#define SIZE_ASM_OP "\t.size\t"
d1be3be3
JW
538
539/* This is how we tell the assembler that a symbol is weak. */
540
f6cad4c9
NC
541#define ASM_WEAKEN_LABEL(FILE, NAME) \
542 do \
543 { \
544 fputs ("\t.weak\t", (FILE)); \
545 assemble_name ((FILE), (NAME)); \
546 fputc ('\n', (FILE)); \
547 } \
548 while (0)
d1be3be3
JW
549
550/* The following macro defines the format used to output the second
551 operand of the .type assembler directive. Different svr4 assemblers
552 expect various different forms for this operand. The one given here
553 is just a default. You may need to override it in your machine-
554 specific tm.h file (depending upon the particulars of your assembler). */
555
556#define TYPE_OPERAND_FMT "@%s"
557
558/* Write the extra assembler code needed to declare a function's result.
559 Most svr4 assemblers don't require any special declaration of the
560 result value, but there are exceptions. */
561
562#ifndef ASM_DECLARE_RESULT
563#define ASM_DECLARE_RESULT(FILE, RESULT)
564#endif
565
566/* These macros generate the special .type and .size directives which
567 are used to set the corresponding fields of the linker symbol table
568 entries in an ELF object file under SVR4. These macros also output
569 the starting labels for the relevant functions/objects. */
570
571/* Write the extra assembler code needed to declare a function properly.
572 Some svr4 assemblers need to also have something extra said about the
573 function's return value. We allow for that here. */
574
8d170590 575#ifndef ASM_DECLARE_FUNCTION_NAME
f6cad4c9
NC
576#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
577 do \
578 { \
ca13100a 579 fprintf (FILE, "%s", TYPE_ASM_OP); \
f6cad4c9
NC
580 assemble_name (FILE, NAME); \
581 putc (',', FILE); \
582 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
583 putc ('\n', FILE); \
584 \
585 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
586 ASM_OUTPUT_LABEL(FILE, NAME); \
587 } \
588 while (0)
8d170590 589#endif
f6cad4c9 590
d1be3be3
JW
591/* Write the extra assembler code needed to declare an object properly. */
592
f6cad4c9
NC
593#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
594 do \
595 { \
ca13100a 596 fprintf (FILE, "%s", TYPE_ASM_OP); \
f6cad4c9
NC
597 assemble_name (FILE, NAME); \
598 putc (',', FILE); \
599 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
600 putc ('\n', FILE); \
601 \
602 size_directive_output = 0; \
603 \
0577bad8
RH
604 if (!flag_inhibit_size_directive \
605 && (DECL) && DECL_SIZE (DECL)) \
f6cad4c9
NC
606 { \
607 size_directive_output = 1; \
ca13100a 608 fprintf (FILE, "%s", SIZE_ASM_OP); \
f6cad4c9
NC
609 assemble_name (FILE, NAME); \
610 putc (',', FILE); \
611 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
612 int_size_in_bytes (TREE_TYPE (DECL))); \
613 fputc ('\n', FILE); \
614 } \
615 \
616 ASM_OUTPUT_LABEL (FILE, NAME); \
617 } \
618 while (0)
d1be3be3
JW
619
620/* Output the size directive for a decl in rest_of_decl_compilation
621 in the case where we did not do so before the initializer.
622 Once we find the error_mark_node, we know that the value of
623 size_directive_output was set
624 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
625
f6cad4c9
NC
626#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)\
627 do \
628 { \
629 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
630 \
631 if (!flag_inhibit_size_directive \
632 && DECL_SIZE (DECL) \
633 && ! AT_END && TOP_LEVEL \
634 && DECL_INITIAL (DECL) == error_mark_node \
635 && !size_directive_output) \
636 { \
637 size_directive_output = 1; \
ca13100a 638 fprintf (FILE, "%s", SIZE_ASM_OP); \
f6cad4c9
NC
639 assemble_name (FILE, name); \
640 putc (',', FILE); \
641 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
642 int_size_in_bytes (TREE_TYPE (DECL))); \
643 fputc ('\n', FILE); \
644 } \
645 } \
646 while (0)
d1be3be3
JW
647
648/* This is how to declare the size of a function. */
8d170590 649#ifndef ASM_DECLARE_FUNCTION_SIZE
f6cad4c9
NC
650#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
651 do \
652 { \
653 if (!flag_inhibit_size_directive) \
654 { \
655 char label[256]; \
656 static int labelno; \
657 \
658 labelno++; \
659 \
660 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
661 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
662 \
ca13100a 663 fprintf (FILE, "%s", SIZE_ASM_OP); \
f6cad4c9
NC
664 assemble_name (FILE, (FNAME)); \
665 fprintf (FILE, ","); \
666 assemble_name (FILE, label); \
667 fprintf (FILE, "-"); \
668 assemble_name (FILE, (FNAME)); \
669 putc ('\n', FILE); \
670 } \
671 } \
672 while (0)
8d170590 673#endif
d1be3be3
JW
674
675/* A table of bytes codes used by the ASM_OUTPUT_ASCII and
676 ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table
677 corresponds to a particular byte value [0..255]. For any
678 given byte value, if the value in the corresponding table
679 position is zero, the given character can be output directly.
680 If the table value is 1, the byte must be output as a \ooo
681 octal escape. If the tables value is anything else, then the
682 byte value should be output as a \ followed by the value
683 in the table. Note that we can use standard UN*X escape
684 sequences for many control characters, but we don't use
685 \a to represent BEL because some svr4 assemblers (e.g. on
686 the i386) don't know about that. Also, we don't use \v
687 since some versions of gas, such as 2.2 did not accept it. */
688
689#define ESCAPES \
690"\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\
691\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\
692\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\
693\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\
694\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\
695\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\
696\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\
697\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"
698
699/* Some svr4 assemblers have a limit on the number of characters which
700 can appear in the operand of a .string directive. If your assembler
701 has such a limitation, you should define STRING_LIMIT to reflect that
702 limit. Note that at least some svr4 assemblers have a limit on the
703 actual number of bytes in the double-quoted string, and that they
704 count each character in an escape sequence as one byte. Thus, an
705 escape sequence like \377 would count as four bytes.
706
707 If your target assembler doesn't support the .string directive, you
708 should define this to zero.
709*/
710
711#define STRING_LIMIT ((unsigned) 256)
712
e662a129 713#define STRING_ASM_OP "\t.string\t"
d1be3be3
JW
714
715/* The routine used to output NUL terminated strings. We use a special
716 version of this for most svr4 targets because doing so makes the
717 generated assembly code more compact (and thus faster to assemble)
718 as well as more readable, especially for targets like the i386
719 (where the only alternative is to output character sequences as
720 comma separated lists of numbers). */
721
f6cad4c9
NC
722#define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
723 do \
724 { \
725 register const unsigned char *_limited_str = \
726 (const unsigned char *) (STR); \
727 register unsigned ch; \
728 \
ca13100a 729 fprintf ((FILE), "%s\"", STRING_ASM_OP); \
f6cad4c9 730 \
0ce8a59c 731 for (; (ch = *_limited_str); _limited_str++) \
f6cad4c9
NC
732 { \
733 register int escape; \
734 \
735 switch (escape = ESCAPES[ch]) \
736 { \
737 case 0: \
738 putc (ch, (FILE)); \
739 break; \
740 case 1: \
741 fprintf ((FILE), "\\%03o", ch); \
742 break; \
743 default: \
744 putc ('\\', (FILE)); \
745 putc (escape, (FILE)); \
746 break; \
747 } \
748 } \
749 \
750 fprintf ((FILE), "\"\n"); \
751 } \
d1be3be3
JW
752 while (0)
753
754/* The routine used to output sequences of byte values. We use a special
755 version of this for most svr4 targets because doing so makes the
756 generated assembly code more compact (and thus faster to assemble)
757 as well as more readable. Note that if we find subparts of the
758 character sequence which end with NUL (and which are shorter than
759 STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */
760
f6cad4c9 761#undef ASM_OUTPUT_ASCII
d1be3be3
JW
762#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \
763 do \
764 { \
f6cad4c9
NC
765 register const unsigned char *_ascii_bytes = \
766 (const unsigned char *) (STR); \
767 register const unsigned char *limit = _ascii_bytes + (LENGTH); \
d1be3be3 768 register unsigned bytes_in_chunk = 0; \
f6cad4c9 769 \
d1be3be3
JW
770 for (; _ascii_bytes < limit; _ascii_bytes++) \
771 { \
f6cad4c9
NC
772 register const unsigned char *p; \
773 \
d1be3be3
JW
774 if (bytes_in_chunk >= 60) \
775 { \
776 fprintf ((FILE), "\"\n"); \
777 bytes_in_chunk = 0; \
778 } \
f6cad4c9 779 \
d1be3be3
JW
780 for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \
781 continue; \
f6cad4c9
NC
782 \
783 if (p < limit && (p - _ascii_bytes) <= (long)STRING_LIMIT) \
d1be3be3
JW
784 { \
785 if (bytes_in_chunk > 0) \
786 { \
787 fprintf ((FILE), "\"\n"); \
788 bytes_in_chunk = 0; \
789 } \
f6cad4c9 790 \
d1be3be3
JW
791 ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes); \
792 _ascii_bytes = p; \
793 } \
794 else \
795 { \
796 register int escape; \
797 register unsigned ch; \
f6cad4c9 798 \
d1be3be3 799 if (bytes_in_chunk == 0) \
ca13100a 800 fprintf ((FILE), "%s\"", ASCII_DATA_ASM_OP); \
f6cad4c9 801 \
d1be3be3
JW
802 switch (escape = ESCAPES[ch = *_ascii_bytes]) \
803 { \
804 case 0: \
805 putc (ch, (FILE)); \
806 bytes_in_chunk++; \
807 break; \
808 case 1: \
809 fprintf ((FILE), "\\%03o", ch); \
810 bytes_in_chunk += 4; \
811 break; \
812 default: \
813 putc ('\\', (FILE)); \
814 putc (escape, (FILE)); \
815 bytes_in_chunk += 2; \
816 break; \
817 } \
818 } \
819 } \
f6cad4c9 820 \
d1be3be3
JW
821 if (bytes_in_chunk > 0) \
822 fprintf ((FILE), "\"\n"); \
823 } \
824 while (0)
This page took 0.526964 seconds and 5 git commands to generate.