1 /* Definitions for Intel 386 running FreeBSD with either a.out or ELF format
2 Copyright (C) 1996, 2000, 2002 Free Software Foundation, Inc.
3 Contributed by Eric Youngdale.
4 Modified for stabs-in-ELF by H.J. Lu.
5 Adapted from GNU/Linux version by John Polstra.
6 Added support for generating "old a.out gas" on the fly by Peter Wemm.
7 Continued development by David O'Brien <obrien@freebsd.org>
9 This file is part of GNU CC.
11 GNU CC is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 GNU CC is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GNU CC; see the file COPYING. If not, write to
23 the Free Software Foundation, 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. */
26 /* $FreeBSD: src/contrib/gcc/config/i386/freebsd.h,v 1.34.2.5 2002/06/20 23:12:37 obrien Exp $ */
29 #define CPP_PREDEFINES \
30 "-Di386 -Acpu(i386) -Amachine(i386)" \
35 %{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \
36 %{maout: %{!mno-underscores: %{!munderscores: -munderscores }}}"
39 #define ASM_SPEC "%{v*: -v} %{maout: %{fpic:-k} %{fPIC:-k}}"
42 #define ASM_FINAL_SPEC "%|"
44 /* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support
45 for the special GCC options -static and -shared, which allow us to
46 link things in one of these three modes by applying the appropriate
47 combinations of options at link-time. We like to support here for
48 as many of the other GNU linker options as possible. But I don't
49 have the time to search for those flags. I am sure how to add
50 support for -soname shared_object_name. H.J.
52 When the -shared link option is used a final link is not being
57 %{p:%e`-p' not supported; use `-pg' and gprof(1)} \
58 %{maout: %{shared:-Bshareable} \
59 %{!shared:%{!nostdlib:%{!r:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} \
60 %{pg:-Bstatic} %{Z}} \
65 %{assert*} %{R*} %{rpath*} %{defsym*} \
66 %{shared:-Bshareable %{h*} %{soname*}} \
69 %{rdynamic: -export-dynamic} \
70 %{!dynamic-linker: -dynamic-linker /usr/libexec/ld-elf.so.1}} \
72 %{symbolic:-Bsymbolic}}"
74 /* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add the magical
75 crtbegin.o file (see crtstuff.c) which provides part of the support for
76 getting C++ file-scope static object constructed before entering `main'. */
79 #define STARTFILE_SPEC "\
80 %{maout: %{shared:c++rt0.o%s} \
82 %{pg:gcrt0.o%s}%{!pg: \
84 %{!static:crt0.o%s}}}} \
92 %{!shared:crtbegin.o%s} \
93 %{shared:crtbeginS.o%s}}"
95 /* Provide an ENDFILE_SPEC appropriate for FreeBSD/i386. Here we tack on our
96 own magical crtend.o file (see crtstuff.c) which provides part of the
97 support for getting C++ file-scope static object constructed before
98 entering `main', followed by the normal "finalizer" file, `crtn.o'. */
101 #define ENDFILE_SPEC "\
103 %{!shared:crtend.o%s} \
104 %{shared:crtendS.o%s} crtn.o%s}"
107 /************************[ Target stuff ]***********************************/
109 /* Define the actual types of some ANSI-mandated types.
110 Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c,
111 c-common.c, and config/<arch>/<arch>.h. */
114 #define SIZE_TYPE "unsigned int"
117 #define PTRDIFF_TYPE "int"
119 #undef WCHAR_TYPE_SIZE
120 #define WCHAR_TYPE_SIZE BITS_PER_WORD
122 /* This is the pseudo-op used to generate a 32-bit word of data with a
123 specific value in some section. */
126 #define INT_ASM_OP ".long"
128 /* Biggest alignment supported by the object file format of this
129 machine. Use this macro to limit the alignment which can be
130 specified using the `__attribute__ ((aligned (N)))' construct. If
131 not defined, the default value is `BIGGEST_ALIGNMENT'. */
133 #define MAX_OFILE_ALIGNMENT (32768*8)
135 #undef TARGET_VERSION
136 #define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)");
138 #define MASK_PROFILER_EPILOGUE 010000000000
139 #define MASK_AOUT 004000000000 /* a.out not elf */
140 #define MASK_UNDERSCORES 002000000000 /* use leading _ */
142 #define TARGET_PROFILER_EPILOGUE (target_flags & MASK_PROFILER_EPILOGUE)
143 #define TARGET_AOUT (target_flags & MASK_AOUT)
144 #define TARGET_ELF ((target_flags & MASK_AOUT) == 0)
145 #define TARGET_UNDERSCORES ((target_flags & MASK_UNDERSCORES) != 0)
147 #undef SUBTARGET_SWITCHES
148 #define SUBTARGET_SWITCHES \
149 { "profiler-epilogue", MASK_PROFILER_EPILOGUE, "Function profiler epilogue"}, \
150 { "no-profiler-epilogue", -MASK_PROFILER_EPILOGUE, "No function profiler epilogue"}, \
151 { "aout", MASK_AOUT, "Generate an a.out (vs. ELF) binary"}, \
152 { "no-aout", -MASK_AOUT, "Do not generate an a.out binary"}, \
153 { "underscores", MASK_UNDERSCORES, "Add leading underscores to symbols"}, \
154 { "no-underscores", -MASK_UNDERSCORES, "Do not add leading underscores to symbols"},
156 /* This goes away when the math emulator is fixed. */
157 #undef TARGET_DEFAULT
158 #define TARGET_DEFAULT \
159 (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
161 /* Don't default to pcc-struct-return, we want to retain compatibility with
162 older gcc versions AND pcc-struct-return is nonreentrant.
163 (even though the SVR4 ABI for the i386 says that records and unions are
164 returned in memory). */
166 #undef DEFAULT_PCC_STRUCT_RETURN
167 #define DEFAULT_PCC_STRUCT_RETURN 0
169 /* The a.out tools do not support "linkonce" sections. */
170 #undef SUPPORTS_ONE_ONLY
171 #define SUPPORTS_ONE_ONLY TARGET_ELF
173 /* Prefix for internally generated assembler labels. If we aren't using
174 underscores, we are using prefix `.'s to identify labels that should
175 be ignored, as in `i386/gas.h' --karl@cs.umb.edu */
177 #define LPREFIX ((TARGET_UNDERSCORES) ? "L" : ".L")
179 /* supply our own hook for calling __main() from main() */
182 #undef GEN_CALL__MAIN
183 #define GEN_CALL__MAIN \
186 emit_library_call (gen_rtx (SYMBOL_REF, Pmode, NAME__MAIN), 0, \
190 /* Indicate that jump tables go in the text section. This is
191 necessary when compiling PIC code. */
192 #undef JUMP_TABLES_IN_TEXT_SECTION
193 #define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
195 /* override the exception table positioning */
196 #undef EXCEPTION_SECTION
197 #define EXCEPTION_SECTION() \
201 named_section (NULL_TREE, ".gcc_except_table", 0); \
208 readonly_data_section (); \
212 /* Tell final.c that we don't need a label passed to mcount. */
213 #undef NO_PROFILE_COUNTERS
214 #define NO_PROFILE_COUNTERS
216 /* Output assembler code to FILE to begin profiling of the current function.
217 LABELNO is an optional label. */
219 #undef FUNCTION_PROFILER
220 #define FUNCTION_PROFILER(FILE, LABELNO) \
222 char *_name = TARGET_AOUT ? "mcount" : ".mcount"; \
224 fprintf ((FILE), "\tcall *%s@GOT(%%ebx)\n", _name); \
226 fprintf ((FILE), "\tcall %s\n", _name); \
229 /* Output assembler code to FILE to end profiling of the current function. */
231 #undef FUNCTION_PROFILER_EPILOGUE
232 #define FUNCTION_PROFILER_EPILOGUE(FILE, DO_RTL) \
234 if (TARGET_PROFILER_EPILOGUE) \
238 /* ".mexitcount" is specially handled in \
239 ASM_HACK_SYMBOLREF () so that we don't need to handle \
240 flag_pic or TARGET_AOUT here. */ \
242 xop = gen_rtx_MEM (FUNCTION_MODE, \
243 gen_rtx_SYMBOL_REF (Pmode, ".mexitcount")); \
244 emit_call_insn (gen_rtx (CALL, VOIDmode, xop, const0_rtx)); \
248 /* XXX this !DO_RTL case is broken but not actually used. */ \
249 char *_name = TARGET_AOUT ? "mcount" : ".mcount"; \
251 fprintf (FILE, "\tcall *%s@GOT(%%ebx)\n", _name); \
253 fprintf (FILE, "\tcall %s\n", _name); \
259 /************************[ Assembler stuff ]********************************/
261 /* Override the default comment-starter of "/" from unix.h. */
262 #undef ASM_COMMENT_START
263 #define ASM_COMMENT_START "#"
266 #define ASM_APP_ON "#APP\n"
269 #define ASM_APP_OFF "#NO_APP\n"
271 /* Enable alias attribute support. */
273 #define SET_ASM_OP ".set"
275 /* This is how to begin an assembly language file.
276 The .file command should always begin the output.
277 ELF also needs a .version. */
279 #undef ASM_FILE_START
280 #define ASM_FILE_START(FILE) \
282 output_file_directive ((FILE), main_input_filename); \
284 fprintf ((FILE), "\t.version\t\"01.01\"\n"); \
287 /* This is how to store into the string BUF
288 the symbol_ref name of an internal numbered label where
289 PREFIX is the class of label and NUM is the number within the class.
290 This is suitable for output with `assemble_name'. */
291 #undef ASM_GENERATE_INTERNAL_LABEL
292 #define ASM_GENERATE_INTERNAL_LABEL(BUF, PREFIX, NUMBER) \
293 sprintf ((BUF), "*%s%s%d", (TARGET_UNDERSCORES) ? "" : ".", \
296 /* This is how to output an internal numbered label where
297 PREFIX is the class of label and NUM is the number within the class.
298 For most svr4/ELF systems, the convention is that any symbol which begins
299 with a period is not put into the linker symbol table by the assembler. */
300 #undef ASM_OUTPUT_INTERNAL_LABEL
301 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
302 fprintf ((FILE), "%s%s%d:\n", (TARGET_UNDERSCORES) ? "" : ".", \
305 /* This is how to output a reference to a user-level label named NAME. */
306 #undef ASM_OUTPUT_LABELREF
307 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
309 char *_name = (NAME); \
310 /* Hack to avoid writing lots of rtl in \
311 FUNCTION_PROFILER_EPILOGUE (). */ \
312 if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0) \
317 fprintf ((FILE), "*%s@GOT(%%ebx)", _name); \
319 fprintf ((FILE), "%s", _name); \
322 fprintf (FILE, "%s%s", TARGET_UNDERSCORES ? "_" : "", _name); \
325 /* This is how to hack on the symbol code of certain relcalcitrant
326 symbols to modify their output in output_pic_addr_const (). */
328 #undef ASM_HACK_SYMBOLREF_CODE
329 #define ASM_HACK_SYMBOLREF_CODE(NAME, CODE) \
331 /* Part of hack to avoid writing lots of rtl in \
332 FUNCTION_PROFILER_EPILOGUE (). */ \
333 char *_name = (NAME); \
334 if (*_name == '.' && strcmp(_name + 1, "mexitcount") == 0) \
338 /* This is how to output an element of a case-vector that is relative.
339 This is only used for PIC code. See comments by the `casesi' insn in
340 i386.md for an explanation of the expression this outputs. */
341 #undef ASM_OUTPUT_ADDR_DIFF_ELT
342 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
343 fprintf ((FILE), "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, (VALUE))
345 #undef ASM_OUTPUT_ALIGN
346 #define ASM_OUTPUT_ALIGN(FILE, LOG) \
348 if (in_text_section()) \
349 fprintf ((FILE), "\t.p2align %d,0x90\n", (LOG)); \
351 fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
354 #undef ASM_OUTPUT_ALIGNED_COMMON
355 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
359 fprintf ((FILE), "%s", COMMON_ASM_OP); \
360 assemble_name ((FILE), (NAME)); \
361 fprintf ((FILE), ",%u,%u\n", (SIZE), (ALIGN) / BITS_PER_UNIT); \
365 int rounded = (SIZE); \
366 if (rounded == 0) rounded = 1; \
367 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1; \
368 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) \
369 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); \
370 fprintf ((FILE), "%s ", COMMON_ASM_OP); \
371 assemble_name ((FILE), (NAME)); \
372 fprintf ((FILE), ",%u\n", (rounded)); \
376 /* This says how to output assembler code to declare an
377 uninitialized internal linkage data object. Under SVR4,
378 the linker seems to want the alignment of data objects
379 to depend on their types. We do exactly that here. */
381 #undef ASM_OUTPUT_ALIGNED_LOCAL
382 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
386 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
387 assemble_name ((FILE), (NAME)); \
388 fprintf ((FILE), "\n"); \
389 ASM_OUTPUT_ALIGNED_COMMON ((FILE), (NAME), (SIZE), (ALIGN)); \
393 int rounded = (SIZE); \
394 if (rounded == 0) rounded = 1; \
395 rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1; \
396 rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT) \
397 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT)); \
398 fputs ("\t.lcomm\t", (FILE)); \
399 assemble_name ((FILE), (NAME)); \
400 fprintf ((FILE), ",%u\n", (rounded)); \
404 /* How to output some space. The rules are different depending on the
406 #undef ASM_OUTPUT_SKIP
407 #define ASM_OUTPUT_SKIP(FILE, SIZE) \
411 fprintf ((FILE), "%s%u\n", SKIP_ASM_OP, (SIZE)); \
415 fprintf ((FILE), "\t.space\t%u\n", (SIZE)); \
419 #undef ASM_OUTPUT_SOURCE_LINE
420 #define ASM_OUTPUT_SOURCE_LINE(FILE, LINE) \
422 static int sym_lineno = 1; \
425 fprintf ((FILE), ".stabn 68,0,%d,.LM%d-", (LINE), sym_lineno); \
426 assemble_name ((FILE), \
427 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
428 fprintf ((FILE), "\n.LM%d:\n", sym_lineno); \
433 fprintf ((FILE), "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, \
438 /* These macros generate the special .type and .size directives which
439 are used to set the corresponding fields of the linker symbol table
440 entries in an ELF object file under SVR4. These macros also output
441 the starting labels for the relevant functions/objects. */
443 /* Write the extra assembler code needed to declare a function properly.
444 Some svr4 assemblers need to also have something extra said about the
445 function's return value. We allow for that here. */
447 #undef ASM_DECLARE_FUNCTION_NAME
448 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
450 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
451 assemble_name (FILE, NAME); \
453 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
455 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
456 ASM_OUTPUT_LABEL(FILE, NAME); \
459 /* This is how to declare the size of a function. */
461 #undef ASM_DECLARE_FUNCTION_SIZE
462 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
464 if (!flag_inhibit_size_directive) \
467 static int labelno; \
469 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
470 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
471 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
472 assemble_name (FILE, (FNAME)); \
473 fprintf (FILE, ","); \
474 assemble_name (FILE, label); \
475 fprintf (FILE, "-"); \
476 assemble_name (FILE, (FNAME)); \
482 /* The routine used to output NUL terminated strings. We use a special
483 version of this for most svr4 targets because doing so makes the
484 generated assembly code more compact (and thus faster to assemble)
485 as well as more readable, especially for targets like the i386
486 (where the only alternative is to output character sequences as
487 comma separated lists of numbers). */
489 #undef ASM_OUTPUT_LIMITED_STRING
490 #define ASM_OUTPUT_LIMITED_STRING(FILE, STR) \
492 register unsigned char *_limited_str = (unsigned char *) (STR); \
493 register unsigned ch; \
494 fprintf ((FILE), "\t%s\t\"", STRING_ASM_OP); \
495 for (; (ch = *_limited_str); _limited_str++) \
497 register int escape; \
498 switch (escape = ESCAPES[ch]) \
504 fprintf ((FILE), "\\%03o", ch); \
507 putc ('\\', (FILE)); \
508 putc (escape, (FILE)); \
512 fprintf ((FILE), "\"\n"); \
515 /* Switch into a generic section.
517 We make the section read-only and executable for a function decl,
518 read-only for a const data decl, and writable for a non-const data decl.
520 If the section has already been defined, we must not
521 emit the attributes here. The SVR4 assembler does not
522 recognize section redefinitions.
523 If DECL is NULL, no attributes are emitted. */
525 #undef ASM_OUTPUT_SECTION_NAME
526 #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
528 static struct section_info \
530 struct section_info *next; \
532 enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \
534 struct section_info *s; \
536 enum sect_enum type; \
538 for (s = sections; s; s = s->next) \
539 if (!strcmp (NAME, s->name)) \
542 if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \
543 type = SECT_EXEC, mode = "ax"; \
544 else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \
545 type = SECT_RO, mode = "a"; \
547 type = SECT_RW, mode = "aw"; \
551 s = (struct section_info *) xmalloc (sizeof (struct section_info)); \
552 s->name = xmalloc ((strlen (NAME) + 1) * sizeof (*NAME)); \
553 strcpy (s->name, NAME); \
555 s->next = sections; \
557 fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, mode); \
561 if (DECL && s->type != type) \
562 error_with_decl (DECL, "%s causes a section type conflict"); \
564 fprintf (FILE, ".section\t%s\n", NAME); \
568 #undef MAKE_DECL_ONE_ONLY
569 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
570 #undef UNIQUE_SECTION_P
571 #define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
572 #undef UNIQUE_SECTION
573 #define UNIQUE_SECTION(DECL,RELOC) \
576 char *name, *string, *prefix; \
578 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
580 if (! DECL_ONE_ONLY (DECL)) \
583 if (TREE_CODE (DECL) == FUNCTION_DECL) \
585 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
586 prefix = ".rodata."; \
590 else if (TREE_CODE (DECL) == FUNCTION_DECL) \
591 prefix = ".gnu.linkonce.t."; \
592 else if (DECL_READONLY_SECTION (DECL, RELOC)) \
593 prefix = ".gnu.linkonce.r."; \
595 prefix = ".gnu.linkonce.d."; \
597 len = strlen (name) + strlen (prefix); \
598 string = alloca (len + 1); \
599 sprintf (string, "%s%s", prefix, name); \
601 DECL_SECTION_NAME (DECL) = build_string (len, string); \
604 /* A C statement or statements to switch to the appropriate
605 section for output of DECL. DECL is either a `VAR_DECL' node
606 or a constant of some sort. RELOC indicates whether forming
607 the initial value of DECL requires link-time relocations. */
609 #undef SELECT_SECTION
610 #define SELECT_SECTION(DECL,RELOC) \
612 if (flag_pic && RELOC) \
614 else if (TREE_CODE (DECL) == STRING_CST) \
616 if (! flag_writable_strings) \
621 else if (TREE_CODE (DECL) == VAR_DECL) \
623 if (! DECL_READONLY_SECTION (DECL, RELOC)) \
632 /* A C statement (sans semicolon) to output an element in the table of
633 global constructors. */
634 #undef ASM_OUTPUT_CONSTRUCTOR
635 #define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME) \
640 fprintf ((FILE), "%s ", INT_ASM_OP); \
641 assemble_name ((FILE), (NAME)); \
642 fprintf ((FILE), "\n"); \
646 fprintf (asm_out_file, "%s \"%s__CTOR_LIST__\",22,0,0,", \
647 ASM_STABS_OP, (TARGET_UNDERSCORES) ? "_" : ""); \
648 assemble_name (asm_out_file, name); \
649 fputc ('\n', asm_out_file); \
653 /* A C statement (sans semicolon) to output an element in the table of
654 global destructors. */
655 #undef ASM_OUTPUT_DESTRUCTOR
656 #define ASM_OUTPUT_DESTRUCTOR(FILE, NAME) \
661 fprintf ((FILE), "%s ", INT_ASM_OP); \
662 assemble_name ((FILE), (NAME)); \
663 fprintf ((FILE), "\n"); \
667 fprintf (asm_out_file, "%s \"%s__DTOR_LIST__\",22,0,0,", \
668 ASM_STABS_OP, (TARGET_UNDERSCORES) ? "_" : ""); \
669 assemble_name (asm_out_file, name); \
670 fputc ('\n', asm_out_file); \
674 /* Define macro used to output shift-double opcodes when the shift
675 count is in %cl. Some assemblers require %cl as an argument;
678 *OLD* GAS requires the %cl argument, so override i386/unix.h. */
680 #undef AS3_SHIFT_DOUBLE
681 #define AS3_SHIFT_DOUBLE(a,b,c,d) AS3 (a,b,c,d)
684 /************************[ Debugger stuff ]*********************************/
686 /* The a.out tools do not support "Lscope" .stabs symbols. */
687 #undef NO_DBX_FUNCTION_END
688 #define NO_DBX_FUNCTION_END TARGET_AOUT
690 /* In ELF, the function stabs come first, before the relative offsets. */
691 #undef DBX_FUNCTION_FIRST
692 #define DBX_CHECK_FUNCTION_FIRST TARGET_ELF
694 /* Copy this from the svr4 specifications... */
695 /* Define the register numbers to be used in Dwarf debugging information.
696 The SVR4 reference port C compiler uses the following register numbers
697 in its Dwarf output code:
698 0 for %eax (gnu regno = 0)
699 1 for %ecx (gnu regno = 2)
700 2 for %edx (gnu regno = 1)
701 3 for %ebx (gnu regno = 3)
702 4 for %esp (gnu regno = 7)
703 5 for %ebp (gnu regno = 6)
704 6 for %esi (gnu regno = 4)
705 7 for %edi (gnu regno = 5)
706 The following three DWARF register numbers are never generated by
707 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
708 believes these numbers have these meanings.
709 8 for %eip (no gnu equivalent)
710 9 for %eflags (no gnu equivalent)
711 10 for %trapno (no gnu equivalent)
712 It is not at all clear how we should number the FP stack registers
713 for the x86 architecture. If the version of SDB on x86/svr4 were
714 a bit less brain dead with respect to floating-point then we would
715 have a precedent to follow with respect to DWARF register numbers
716 for x86 FP registers, but the SDB on x86/svr4 is so completely
717 broken with respect to FP registers that it is hardly worth thinking
718 of it as something to strive for compatibility with.
719 The version of x86/svr4 SDB I have at the moment does (partially)
720 seem to believe that DWARF register number 11 is associated with
721 the x86 register %st(0), but that's about all. Higher DWARF
722 register numbers don't seem to be associated with anything in
723 particular, and even for DWARF regno 11, SDB only seems to under-
724 stand that it should say that a variable lives in %st(0) (when
725 asked via an `=' command) if we said it was in DWARF regno 11,
726 but SDB still prints garbage when asked for the value of the
727 variable in question (via a `/' command).
728 (Also note that the labels SDB prints for various FP stack regs
729 when doing an `x' command are all wrong.)
730 Note that these problems generally don't affect the native SVR4
731 C compiler because it doesn't allow the use of -O with -g and
732 because when it is *not* optimizing, it allocates a memory
733 location for each floating-point variable, and the memory
734 location is what gets described in the DWARF AT_location
735 attribute for the variable in question.
736 Regardless of the severe mental illness of the x86/svr4 SDB, we
737 do something sensible here and we use the following DWARF
738 register numbers. Note that these are all stack-top-relative
740 11 for %st(0) (gnu regno = 8)
741 12 for %st(1) (gnu regno = 9)
742 13 for %st(2) (gnu regno = 10)
743 14 for %st(3) (gnu regno = 11)
744 15 for %st(4) (gnu regno = 12)
745 16 for %st(5) (gnu regno = 13)
746 17 for %st(6) (gnu regno = 14)
747 18 for %st(7) (gnu regno = 15)
749 #undef DWARF_DBX_REGISTER_NUMBER
750 #define DWARF_DBX_REGISTER_NUMBER(n) \
759 : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \
762 /* Now what stabs expects in the register. */
763 #undef STABS_DBX_REGISTER_NUMBER
764 #define STABS_DBX_REGISTER_NUMBER(n) \
775 #undef DBX_REGISTER_NUMBER
776 #define DBX_REGISTER_NUMBER(n) ((write_symbols == DWARF2_DEBUG \
777 || write_symbols == DWARF_DEBUG) \
778 ? DWARF_DBX_REGISTER_NUMBER(n) \
779 : STABS_DBX_REGISTER_NUMBER(n))
781 /* tag end of file in elf mode */
782 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
783 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
786 fprintf ((FILE), "\t.text\n\t.stabs \"\",%d,0,0,.Letext\n.Letext:\n", \
791 /* stabs-in-elf has offsets relative to function beginning */
792 #undef DBX_OUTPUT_LBRAC
793 #define DBX_OUTPUT_LBRAC(FILE, NAME) \
795 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC); \
796 assemble_name (asmfile, buf); \
799 fputc ('-', asmfile); \
800 assemble_name (asmfile, \
801 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
803 fprintf (asmfile, "\n"); \
806 #undef DBX_OUTPUT_RBRAC
807 #define DBX_OUTPUT_RBRAC(FILE, NAME) \
809 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC); \
810 assemble_name (asmfile, buf); \
813 fputc ('-', asmfile); \
814 assemble_name (asmfile, \
815 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
817 fprintf (asmfile, "\n"); \