OSDN Git Service

7efa984d08b2abd154f578ae6243c20aa9ae604a
[pf3gnuchains/gcc-fork.git] / gcc / xcoffout.h
1 /* XCOFF definitions.  These are needed in dbxout.c, final.c,
2    and xcoffout.h.  */
3
4 #define ASM_STABS_OP ".stabx"
5
6 /* Tags and typedefs are C_DECL in XCOFF, not C_LSYM.  */
7
8 #define DBX_TYPE_DECL_STABS_CODE N_DECL
9
10 /* Use the XCOFF predefined type numbers.  */
11
12 /* ??? According to metin, typedef stabx must go in text control section,
13    but he did not make this changes everywhere where such typedef stabx
14    can be emitted, so it is really needed or not?  */
15
16 #define DBX_OUTPUT_STANDARD_TYPES(SYMS)         \
17 {                                               \
18   text_section ();                              \
19   xcoff_output_standard_types (SYMS);           \
20 }
21
22 /* Any type with a negative type index has already been output.  */
23
24 #define DBX_TYPE_DEFINED(TYPE) (TYPE_SYMTAB_ADDRESS (TYPE) < 0)
25
26 /* Must use N_STSYM for static const variables (those in the text section)
27    instead of N_FUN.  */
28
29 #define DBX_STATIC_CONST_VAR_CODE N_STSYM
30
31 /* For static variables, output code to define the start of a static block.
32
33    ??? The IBM rs6000/AIX assembler has a bug that causes bss block debug
34    info to be occasionally lost.  A simple example is this:
35         int a; static int b;
36    The commands `gcc -g -c tmp.c; dump -t tmp.o' gives
37 [10]    m   0x00000016         1     0    0x8f  0x0000            .bs
38 [11]    m   0x00000000         1     0    0x90  0x0000            .es
39 ...
40 [21]    m   0x00000000        -2     0    0x85  0x0000            b:S-1
41    which is wrong.  The `b:S-1' must be between the `.bs' and `.es'.
42    We can apparently work around the problem by forcing the text section
43    (even if we are already in the text section) immediately before outputting
44    the `.bs'.  This should be fixed in the next major AIX release (3.3?).  */
45
46 #define DBX_STATIC_BLOCK_START(ASMFILE,CODE)                            \
47 {                                                                       \
48   if ((CODE) == N_STSYM)                                                \
49     fprintf ((ASMFILE), "\t.bs\t%s[RW]\n", xcoff_private_data_section_name);\
50   else if ((CODE) == N_LCSYM)                                           \
51     {                                                                   \
52       fprintf ((ASMFILE), "%s\n", TEXT_SECTION_ASM_OP);                 \
53       fprintf ((ASMFILE), "\t.bs\t%s\n", xcoff_bss_section_name);       \
54     }                                                                   \
55 }
56
57 /* For static variables, output code to define the end of a static block.  */
58
59 #define DBX_STATIC_BLOCK_END(ASMFILE,CODE)                              \
60 {                                                                       \
61   if (current_sym_code == N_STSYM || current_sym_code == N_LCSYM)       \
62     fprintf (asmfile, "\t.es\n");                                       \
63 }
64
65 /* We must use N_RPYSM instead of N_RSYM for register parameters.  */
66
67 #define DBX_REGPARM_STABS_CODE N_RPSYM
68
69 /* We must use 'R' instead of 'P' for register parameters.  */
70
71 #define DBX_REGPARM_STABS_LETTER 'R'
72
73 /* Define our own finish symbol function, since xcoff stabs have their
74    own different format.  */
75
76 #define DBX_FINISH_SYMBOL(SYM)                                  \
77 {                                                               \
78   if (current_sym_addr && current_sym_code == N_FUN)            \
79     fprintf (asmfile, "\",.");                                  \
80   else                                                          \
81     fprintf (asmfile, "\",");                                   \
82   /* If we are writing a function name, we must ensure that     \
83      there is no storage-class suffix on the name.  */          \
84   if (current_sym_addr && current_sym_code == N_FUN             \
85       && GET_CODE (current_sym_addr) == SYMBOL_REF)             \
86     {                                                           \
87       char *_p;                                                 \
88       for (_p = XSTR (current_sym_addr, 0); *_p != '[' && *_p; _p++) \
89         fprintf (asmfile, "%c", *_p);                           \
90     }                                                           \
91   else if (current_sym_addr)                                    \
92     output_addr_const (asmfile, current_sym_addr);              \
93   else if (current_sym_code == N_GSYM)                          \
94     fprintf (asmfile, "%s", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (SYM))); \
95   else                                                          \
96     fprintf (asmfile, "%d", current_sym_value);                 \
97   fprintf (asmfile, ",%d,0\n", stab_to_sclass (current_sym_code)); \
98 }
99
100 /* These are IBM XCOFF extensions we need to reference in dbxout.c
101    and xcoffout.c.  */
102
103 /* AIX XCOFF uses this for typedefs.  This can have any value, since it is
104    only used for translation into a C_DECL storage class.  */
105 #ifndef N_DECL
106 #define N_DECL 0x8c
107 #endif
108 /* AIX XCOFF uses this for parameters passed in registers.  This can have
109    any value, since it is only used for translation into a C_RPSYM storage
110    class.  */
111 #ifndef N_RPSYM
112 #define N_RPSYM 0x8e
113 #endif
114
115 /* The line number of the beginning of the current function.
116    xcoffout.c needs this so that it can output relative linenumbers.  */
117
118 extern int xcoff_begin_function_line;
119
120 /* Name of the current include file.  */
121
122 extern char *xcoff_current_include_file;
123
124 /* Name of the current function file.  This is the file the `.bf' is
125    emitted from.  In case a line is emitted from a different file,
126    (by including that file of course), then the line number will be
127    absolute.  */
128
129 extern char *xcoff_current_function_file;
130
131 /* Names of bss and data sections.  These should be unique names for each
132    compilation unit.  */
133
134 extern char *xcoff_bss_section_name;
135 extern char *xcoff_private_data_section_name;
136 extern char *xcoff_read_only_section_name;
137
138 /* Don't write out path name for main source file.  */
139 #define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE,FILENAME)
140
141 /* Write out main source file name using ".file" rather than ".stabs".  */
142 #define DBX_OUTPUT_MAIN_SOURCE_FILENAME(FILE,FILENAME) \
143   do {                                          \
144     fprintf (FILE, "\t.file\t", FILENAME);      \
145     output_quoted_string (FILE, FILENAME);      \
146     fprintf (FILE, "\n");                       \
147   } while (0)
148
149 #define ABS_OR_RELATIVE_LINENO(LINENO)          \
150 ((xcoff_current_include_file                    \
151   && xcoff_current_include_file != xcoff_current_function_file) \
152  ? (LINENO) : (LINENO) - xcoff_begin_function_line)
153
154 /* Output source line numbers via ".line" rather than ".stabd".  */
155 #define ASM_OUTPUT_SOURCE_LINE(FILE,LINENUM) \
156   do {                                          \
157     if (xcoff_begin_function_line >= 0)         \
158       fprintf (FILE, "\t.line\t%d\n", ABS_OR_RELATIVE_LINENO (LINENUM)); \
159   } while (0)
160
161 /* We don't want to emit source file names in dbx style. */
162 #define DBX_OUTPUT_SOURCE_FILENAME(FILE, FILENAME)      \
163 {                                                       \
164   if (xcoff_current_include_file)                       \
165     {                                                   \
166       fprintf (FILE, "\t.ei\t");                        \
167       output_quoted_string (FILE, xcoff_current_include_file);  \
168       fprintf (FILE, "\n");                             \
169     }                                                   \
170   if (strcmp (main_input_filename, FILENAME))           \
171     {                                                   \
172       fprintf (FILE, "\t.bi\t");                        \
173       output_quoted_string (FILE, FILENAME);            \
174       fprintf (FILE, "\n");                             \
175       xcoff_current_include_file = FILENAME;            \
176     }                                                   \
177   else                                                  \
178     xcoff_current_include_file = NULL;                  \
179 }
180
181 /* If we are still in an include file, its end must be marked.  */
182 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
183 {                                                       \
184   if (xcoff_current_include_file)                       \
185     {                                                   \
186       fprintf (FILE, "\t.ei\t");                        \
187       output_quoted_string (FILE, xcoff_current_include_file);  \
188       fprintf (FILE, "\n");                             \
189       xcoff_current_include_file = NULL;                \
190     }                                                   \
191 }
192
193 /* Do not break .stabs pseudos into continuations.  */
194 #define DBX_CONTIN_LENGTH 0
195
196 /* Don't try to use the `x' type-cross-reference character in DBX data.
197    Also has the consequence of putting each struct, union or enum
198    into a separate .stabs, containing only cross-refs to the others.  */
199 #define DBX_NO_XREFS
200
201 /* We must put stabs in the text section.  If we don't the assembler
202    won't handle them correctly; it will sometimes put stabs where gdb
203    can't find them.  */
204
205 #define DEBUG_SYMS_TEXT