OSDN Git Service

2002-01-16 H.J. Lu <hjl@gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / linux.h
index 7e22c81..70901e7 100644 (file)
@@ -18,6 +18,101 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#include "mips/mips.h"
+#include "mips/abi64.h"
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* If defined, a C expression whose value is a string containing the
+   assembler operation to identify the following data as
+   uninitialized global data.  If not defined, and neither
+   `ASM_OUTPUT_BSS' nor `ASM_OUTPUT_ALIGNED_BSS' are defined,
+   uninitialized global data will be output in the data section if
+   `-fno-common' is passed, otherwise `ASM_OUTPUT_COMMON' will be
+   used.  */
+#define BSS_SECTION_ASM_OP     "\t.section\t.bss"
+
+#define SBSS_SECTION_ASM_OP    "\t.section .sbss"
+
+/* Like `ASM_OUTPUT_BSS' except takes the required alignment as a
+   separate, explicit argument.  If you define this macro, it is used
+   in place of `ASM_OUTPUT_BSS', and gives you more flexibility in
+   handling the required alignment of the variable.  The alignment is
+   specified as the number of bits.
+
+   Try to use function `asm_output_aligned_bss' defined in file
+   `varasm.c' when defining this macro.  */
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)  \
+do {                                                           \
+  ASM_GLOBALIZE_LABEL (FILE, NAME);                            \
+  if (SIZE > 0 && SIZE <= mips_section_threshold)              \
+    sbss_section ();                                           \
+  else                                                         \
+    bss_section ();                                            \
+  ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
+  last_assemble_variable_decl = DECL;                          \
+  ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                  \
+  ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                     \
+} while (0)
+
+/* These macros generate the special .type and .size directives which
+   are used to set the corresponding fields of the linker symbol table
+   entries in an ELF object file under SVR4.  These macros also output
+   the starting labels for the relevant functions/objects.  */
+
+/* Write the extra assembler code needed to declare an object properly.  */
+
+#undef ASM_DECLARE_OBJECT_NAME
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)              \
+  do {                                                         \
+    fprintf (FILE, "%s", TYPE_ASM_OP);                         \
+    assemble_name (FILE, NAME);                                        \
+    putc (',', FILE);                                          \
+    fprintf (FILE, TYPE_OPERAND_FMT, "object");                        \
+    putc ('\n', FILE);                                         \
+    size_directive_output = 0;                                 \
+    if (!flag_inhibit_size_directive && DECL_SIZE (DECL))      \
+      {                                                                \
+       size_directive_output = 1;                              \
+       fprintf (FILE, "%s", SIZE_ASM_OP);                      \
+       assemble_name (FILE, NAME);                             \
+       fprintf (FILE, ",");                                    \
+       fprintf (FILE, HOST_WIDE_INT_PRINT_DEC,                 \
+                int_size_in_bytes (TREE_TYPE (DECL)));         \
+       fprintf (FILE, "\n");                                   \
+      }                                                                \
+    mips_declare_object (FILE, NAME, "", ":\n", 0);            \
+  } while (0)
+
+#undef UNIQUE_SECTION
+#define UNIQUE_SECTION(DECL,RELOC) \
+  mips_unique_section ((DECL), (RELOC))
+
+/* A list of other sections which the compiler might be "in" at any
+   given time.  */
+#undef EXTRA_SECTIONS
+#define EXTRA_SECTIONS in_sdata, in_sbss, in_rdata
+
+#undef EXTRA_SECTION_FUNCTIONS
+#define EXTRA_SECTION_FUNCTIONS                                         \
+  SECTION_FUNCTION_TEMPLATE(sdata_section, in_sdata, SDATA_SECTION_ASM_OP) \
+  SECTION_FUNCTION_TEMPLATE(sbss_section, in_sbss, SBSS_SECTION_ASM_OP) \
+  SECTION_FUNCTION_TEMPLATE(rdata_section, in_rdata, RDATA_SECTION_ASM_OP)
+
+#define SECTION_FUNCTION_TEMPLATE(FN, ENUM, OP)                        \
+void FN ()                                                     \
+{                                                              \
+  if (in_section != ENUM)                                      \
+    {                                                          \
+      fprintf (asm_out_file, "%s\n", OP);                      \
+      in_section = ENUM;                                       \
+    }                                                          \
+}
+
 #undef TARGET_VERSION
 #if TARGET_ENDIAN_DEFAULT == 0
 #define TARGET_VERSION fprintf (stderr, " (MIPSel GNU/Linux with ELF)");
@@ -31,24 +126,10 @@ Boston, MA 02111-1307, USA.  */
 /* Required to keep collect2.c happy */
 #undef OBJECT_FORMAT_COFF
 
-/* If we don't set MASK_ABICALLS, we can't default to PIC. */
+/* If we don't set MASK_ABICALLS, we can't default to PIC.  */
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT (MASK_ABICALLS|MASK_GAS)
 
-
-/* Handle #pragma weak and #pragma pack.  */
-#define HANDLE_SYSV_PRAGMA 1
-
-/* Use more efficient ``thunks'' to implement C++ vtables. */
-#undef DEFAULT_VTABLE_THUNKS
-#define DEFAULT_VTABLE_THUNKS 1
-
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
-
-/* Generate calls to memcpy, etc., not bcopy, etc.  */
-#define TARGET_MEM_FUNCTIONS
-
 /* Specify predefined symbols in preprocessor.  */
 #undef CPP_PREDEFINES
 #if TARGET_ENDIAN_DEFAULT == 0
@@ -108,26 +189,12 @@ Boston, MA 02111-1307, USA.  */
 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
 %{pthread:-D_REENTRANT}"
 
-/* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
-   the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
-   provides part of the support for getting C++ file-scope static
-   object constructed before entering `main'. */
-
-#undef  STARTFILE_SPEC
-#define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
-   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
-   the GNU/Linux magical crtend.o file (see crtstuff.c) which
-   provides part of the support for getting C++ file-scope static
-   object constructed before entering `main', followed by a normal
-   GNU/Linux "finalizer" file, `crtn.o'.  */
-
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
-  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+/* The GNU C++ standard library requires that these macros be defined.  */
+#undef CPLUSPLUS_CPP_SPEC
+#define CPLUSPLUS_CPP_SPEC "\
+-D__LANGUAGE_C_PLUS_PLUS -D_LANGUAGE_C_PLUS_PLUS \
+-D_GNU_SOURCE %(cpp) \
+"
 
 /* From iris5.h */
 /* -G is incompatible with -KPIC which is the default, so only allow objects
@@ -135,13 +202,6 @@ Boston, MA 02111-1307, USA.  */
 #undef MIPS_DEFAULT_GVALUE
 #define MIPS_DEFAULT_GVALUE 0
 
-#undef LIB_SPEC
-/* Taken from sparc/linux.h.  */
-#define LIB_SPEC \
-  "%{shared: -lc} \
-   %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
-     %{profile:-lc_p} %{!profile: -lc}}"
-
 /* Borrowed from sparc/linux.h */
 #undef LINK_SPEC
 #define LINK_SPEC \
@@ -160,3 +220,62 @@ Boston, MA 02111-1307, USA.  */
 %{mabi=64: -64} \
 %{!fno-PIC:%{!fno-pic:-KPIC}} \
 %{fno-PIC:-non_shared} %{fno-pic:-non_shared}"
+
+/* The MIPS assembler has different syntax for .set. We set it to
+   .dummy to trap any errors.  */
+#undef SET_ASM_OP
+#define SET_ASM_OP "\t.dummy\t"
+
+#undef ASM_OUTPUT_DEF
+#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                             \
+ do {                                                                  \
+       fputc ( '\t', FILE);                                            \
+       assemble_name (FILE, LABEL1);                                   \
+       fputs ( " = ", FILE);                                           \
+       assemble_name (FILE, LABEL2);                                   \
+       fputc ( '\n', FILE);                                            \
+ } while (0)
+
+#undef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
+#define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO)            \
+  do {                                                                 \
+       fputc ('\t', FILE);                                             \
+       assemble_name (FILE, SY);                                       \
+       fputc ('=', FILE);                                              \
+       assemble_name (FILE, HI);                                       \
+       fputc ('-', FILE);                                              \
+       assemble_name (FILE, LO);                                       \
+  } while (0)
+
+#undef ASM_DECLARE_FUNCTION_NAME
+#define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL)                  \
+  do {                                                                 \
+    if (!flag_inhibit_size_directive)                                  \
+      {                                                                        \
+       fputs ("\t.ent\t", STREAM);                                     \
+       assemble_name (STREAM, NAME);                                   \
+       putc ('\n', STREAM);                                            \
+      }                                                                        \
+    fprintf (STREAM, "\t%s\t ", TYPE_ASM_OP);                          \
+    assemble_name (STREAM, NAME);                                      \
+    putc (',', STREAM);                                                        \
+    fprintf (STREAM, TYPE_OPERAND_FMT, "function");                    \
+    putc ('\n', STREAM);                                               \
+    assemble_name (STREAM, NAME);                                      \
+    fputs (":\n", STREAM);                                             \
+  } while (0)
+
+#undef ASM_DECLARE_FUNCTION_SIZE
+#define ASM_DECLARE_FUNCTION_SIZE(STREAM, NAME, DECL)                  \
+  do {                                                                 \
+    if (!flag_inhibit_size_directive)                                  \
+      {                                                                        \
+       fputs ("\t.end\t", STREAM);                                     \
+       assemble_name (STREAM, NAME);                                   \
+       putc ('\n', STREAM);                                            \
+      }                                                                        \
+  } while (0)
+
+/* Tell function_prologue in mips.c that we have already output the .ent/.end
+   pseudo-ops.  */
+#define FUNCTION_NAME_ALREADY_DECLARED