OSDN Git Service

Shared library support.
[pf3gnuchains/gcc-fork.git] / gcc / config / i860 / sysv4.h
1 /* Target definitions for GNU compiler for Intel 80860 running System V.4
2    Copyright (C) 1991 Free Software Foundation, Inc.
3
4    Written by Ron Guilmette (rfg@netcom.com).
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
21
22 #include "i860/i860.h"
23 #include "svr4.h"
24
25 #undef TARGET_VERSION
26 #define TARGET_VERSION fprintf (stderr, " (i860 System V Release 4)");
27
28 /* Provide a set of pre-definitions and pre-assertions appropriate for
29    the i860 running svr4.  Note that the symbol `__svr4__' MUST BE
30    DEFINED!  It is needed so that the va_list struct in va-i860.h
31    will get correctly defined for the svr4 (ABI compliant) case rather
32    than for the previous (svr3, svr2, ...) case.  It also needs to be
33    defined so that the correct (svr4) version of __builtin_saveregs
34    will be selected when we are building gnulib2.c.
35    __svr4__ is our extension.  */
36
37 #define CPP_PREDEFINES \
38   "-Di860 -Dunix -DSVR4 -D__svr4__ -Asystem(unix) -Asystem(svr4) -Acpu(i860) -Amachine(i860)"
39
40 /* The prefix to be used in assembler output for all names of registers.
41    This string gets prepended to all i860 register names (svr4 only).  */
42
43 #define I860_REG_PREFIX "%"
44
45 #define ASM_COMMENT_START "#"
46
47 #undef TYPE_OPERAND_FMT
48 #define TYPE_OPERAND_FMT      "\"%s\""
49
50 #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
51
52 /* The following macro definition overrides the one in i860.h
53    because the svr4 i860 assembler requires a different syntax
54    for getting parts of constant/relocatable values.  */
55
56 #undef PRINT_OPERAND_PART
57 #define PRINT_OPERAND_PART(FILE, X, PART_CODE)                          \
58   do { fprintf (FILE, "[");                                             \
59         output_address (X);                                             \
60         fprintf (FILE, "]@%s", PART_CODE);                              \
61   } while (0)
62
63 /* If the host and target formats match, output the floats as hex.  */
64 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
65 #if defined (HOST_WORDS_BIG_ENDIAN) == WORDS_BIG_ENDIAN
66
67 /* This is how to output an assembler line defining a `double' constant.
68    Note that the native i860/svr4 ELF assembler can't properly handle
69    infinity.  It generates an incorrect (non-infinity) value when given
70    `.double 99e9999' and it doesn't grok `inf' at all.  It also mishandles
71    NaNs and -0.0.  */
72
73 #undef ASM_OUTPUT_DOUBLE
74 #define ASM_OUTPUT_DOUBLE(FILE,VALUE)                                   \
75   {                                                                     \
76     if (REAL_VALUE_ISINF (VALUE)                                        \
77         || REAL_VALUE_ISNAN (VALUE)                                     \
78         || REAL_VALUE_MINUS_ZERO (VALUE))                               \
79       {                                                                 \
80         long t[2];                                                      \
81         REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t);                       \
82         fprintf (FILE, "\t.word 0x%lx\n\t.word 0x%lx\n", t[0], t[1]);   \
83       }                                                                 \
84     else                                                                \
85       fprintf (FILE, "\t.double %.20e\n", VALUE);                       \
86   }
87
88 /* This is how to output an assembler line defining a `float' constant.
89    Note that the native i860/svr4 ELF assembler can't properly handle
90    infinity.  It actually generates an assembly time error when given
91    `.float 99e9999' and it doesn't grok `inf' at all.  It also mishandles
92    NaNs and -0.0.  */
93
94 #undef ASM_OUTPUT_FLOAT
95 #define ASM_OUTPUT_FLOAT(FILE,VALUE)                                    \
96   {                                                                     \
97     if (REAL_VALUE_ISINF (VALUE)                                        \
98         || REAL_VALUE_ISNAN (VALUE)                                     \
99         || REAL_VALUE_MINUS_ZERO (VALUE))                               \
100       {                                                                 \
101         long t;                                                         \
102         REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t);                       \
103         fprintf (FILE, "\t.word 0x%lx\n", t);                           \
104       }                                                                 \
105     else                                                                \
106       fprintf (FILE, "\t.float %.12e\n", VALUE);                        \
107   }
108
109 #endif /* word order matches */
110 #endif /* HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT */
111
112 #undef ASM_FILE_START
113 #define ASM_FILE_START(FILE)                                            \
114   do {  output_file_directive (FILE, main_input_filename);              \
115         fprintf (FILE, "\t.version\t\"01.01\"\n");                      \
116   } while (0)
117
118 /* Output the special word the svr4 SDB wants to see just before
119    the first word of each function's prologue code.  */
120
121 extern char *current_function_original_name;
122
123 /* This special macro is used to output a magic word just before the
124    first word of each function.  On some versions of UNIX running on
125    the i860, this word can be any word that looks like a NOP, however
126    under svr4, this neds to be an `shr r0,r0,r0' instruction in which
127    the normally unused low-order bits contain the length of the function
128    prologue code (in bytes).  This is needed to make the svr4 SDB debugger
129    happy.  */
130
131 #undef ASM_OUTPUT_FUNCTION_PREFIX
132 #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, FNNAME)                        \
133   do {  ASM_OUTPUT_ALIGN (FILE, 2);                                     \
134         fprintf ((FILE), "\t.long\t.ep.");                              \
135         assemble_name (FILE, FNNAME);                                   \
136         fprintf (FILE, "-");                                            \
137         assemble_name (FILE, FNNAME);                                   \
138         fprintf (FILE, "+0xc8000000\n");                                \
139         current_function_original_name = (FNNAME);                      \
140   } while (0)
141
142 /* Output the special label that must go just after each function's
143    prologue code to support svr4 SDB.  */
144
145 #define ASM_OUTPUT_PROLOGUE_SUFFIX(FILE)                                \
146   do {  fprintf (FILE, ".ep.");                                         \
147         assemble_name (FILE, current_function_original_name);           \
148         fprintf (FILE, ":\n");                                          \
149   } while (0)
150
151 /* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
152  
153    Note that we want to give these sections the SHF_WRITE attribute
154    because these sections will actually contain data (i.e. tables of
155    addresses of functions in the current root executable or shared library
156    file) and, in the case of a shared library, the relocatable addresses
157    will have to be properly resolved/relocated (and then written into) by
158    the dynamic linker when it actually attaches the given shared library
159    to the executing process.  (Note that on SVR4, you may wish to use the
160    `-z text' option to the ELF linker, when building a shared library, as
161    an additional check that you are doing everything right.  But if you do
162    use the `-z text' option when building a shared library, you will get
163    errors unless the .ctors and .dtors sections are marked as writable
164    via the SHF_WRITE attribute.)  */
165  
166 #undef CTORS_SECTION_ASM_OP
167 #define CTORS_SECTION_ASM_OP    ".section\t.ctors,\"aw\""
168 #undef DTORS_SECTION_ASM_OP
169 #define DTORS_SECTION_ASM_OP    ".section\t.dtors,\"aw\""
170
171 /* Add definitions to support the .tdesc section as specified in the svr4
172    ABI for the i860.  */
173
174 #define TDESC_SECTION_ASM_OP    ".section\t.tdesc"
175
176 #undef EXTRA_SECTIONS
177 #define EXTRA_SECTIONS in_const, in_ctors, in_dtors, in_tdesc
178
179 #undef EXTRA_SECTION_FUNCTIONS
180 #define EXTRA_SECTION_FUNCTIONS                                         \
181   CONST_SECTION_FUNCTION                                                \
182   CTORS_SECTION_FUNCTION                                                \
183   DTORS_SECTION_FUNCTION                                                \
184   TDESC_SECTION_FUNCTION
185
186 #define TDESC_SECTION_FUNCTION                                          \
187 void                                                                    \
188 tdesc_section ()                                                        \
189 {                                                                       \
190   if (in_section != in_tdesc)                                           \
191     {                                                                   \
192       fprintf (asm_out_file, "%s\n", TDESC_SECTION_ASM_OP);             \
193       in_section = in_tdesc;                                            \
194     }                                                                   \
195 }
196
197 #ifdef OUTPUT_TDESC
198 #undef ASM_FILE_END
199 #define ASM_FILE_END(FILE)                                      \
200 do {                                                            \
201      if (current_function_original_name != NULL) {              \
202        tdesc_section();                                         \
203        fprintf ((FILE), "%s __ETEXT\n", ASM_LONG);              \
204        fprintf ((FILE), "%s 0\n", ASM_LONG);                    \
205        text_section();                                          \
206        fputs("__ETEXT:\n", (FILE));                             \
207      }                                                          \
208      fprintf ((FILE), "\t.ident\t\"GCC: (GNU) %s\"\n",          \
209               version_string);                                  \
210    } while (0)
211 #endif