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