1132718Skan/* Target definitions for GCC for Intel 80386 running Solaris 2
2169689Skan   Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
3169689Skan   2004
490075Sobrien   Free Software Foundation, Inc.
550397Sobrien   Contributed by Fred Fish (fnf@cygnus.com).
618334Speter
7132718SkanThis file is part of GCC.
818334Speter
9132718SkanGCC is free software; you can redistribute it and/or modify
1018334Speterit under the terms of the GNU General Public License as published by
1118334Speterthe Free Software Foundation; either version 2, or (at your option)
1218334Speterany later version.
1318334Speter
14132718SkanGCC is distributed in the hope that it will be useful,
1518334Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of
1618334SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1718334SpeterGNU General Public License for more details.
1818334Speter
1918334SpeterYou should have received a copy of the GNU General Public License
20132718Skanalong with GCC; see the file COPYING.  If not, write to
21169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
22169689SkanBoston, MA 02110-1301, USA.  */
2318334Speter
2418334Speter/* The Solaris 2.0 x86 linker botches alignment of code sections.
2518334Speter   It tries to align to a 16 byte boundary by padding with 0x00000090
2618334Speter   ints, rather than 0x90 bytes (nop).  This generates trash in the
2718334Speter   ".init" section since the contribution from crtbegin.o is only 7
2818334Speter   bytes.  The linker pads it to 16 bytes with a single 0x90 byte, and
2918334Speter   two 0x00000090 ints, which generates a segmentation violation when
3018334Speter   executed.  This macro forces the assembler to do the padding, since
3190075Sobrien   it knows what it is doing.  */
3290075Sobrien#define FORCE_CODE_SECTION_ALIGN  asm(ALIGN_ASM_OP "16");
3318334Speter
34169689Skan/* Old versions of the Solaris assembler can not handle the difference of
35169689Skan   labels in different sections, so force DW_EH_PE_datarel.  */
3690075Sobrien#undef ASM_PREFERRED_EH_DATA_FORMAT
3790075Sobrien#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)			\
38169689Skan  (flag_pic ? ((GLOBAL ? DW_EH_PE_indirect : 0)				\
39169689Skan	       | (TARGET_64BIT ? DW_EH_PE_pcrel | DW_EH_PE_sdata4	\
40169689Skan		  : DW_EH_PE_datarel))					\
4190075Sobrien   : DW_EH_PE_absptr)
4218334Speter
43169689Skan/* The Solaris linker will not merge a read-only .eh_frame section
44169689Skan   with a read-write .eh_frame section.  None of the encodings used
45169689Skan   with non-PIC code require runtime relocations.  In 64-bit mode,
46169689Skan   since there is no backwards compatibility issue, we use a read-only
47169689Skan   section for .eh_frame.  In 32-bit mode, we use a writable .eh_frame
48169689Skan   section in order to be compatible with G++ for Solaris x86.  */
49169689Skan#undef EH_TABLES_CAN_BE_READ_ONLY
50169689Skan#define EH_TABLES_CAN_BE_READ_ONLY (TARGET_64BIT)
51169689Skan
5290075Sobrien/* Solaris 2/Intel as chokes on #line directives.  */
5318334Speter#undef CPP_SPEC
54117395Skan#define CPP_SPEC "%{.S:-P} %(cpp_subtarget)"
5518334Speter
56117395Skan/* FIXME: Removed -K PIC from generic Solaris 2 ASM_SPEC: the native assembler
57117395Skan   gives many warnings: R_386_32 relocation is used for symbol ".text".  */
58117395Skan#undef ASM_SPEC
59117395Skan#define ASM_SPEC "\
60117395Skan%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
61117395Skan%(asm_cpu) \
6290075Sobrien"
6390075Sobrien
64117395Skan#define ASM_CPU_SPEC ""
65117395Skan
66117395Skan#undef SUBTARGET_EXTRA_SPECS
67117395Skan#define SUBTARGET_EXTRA_SPECS \
68117395Skan  { "cpp_subtarget",	CPP_SUBTARGET_SPEC },	\
69117395Skan  { "asm_cpu",		ASM_CPU_SPEC },		\
70117395Skan  { "startfile_arch",	STARTFILE_ARCH_SPEC },	\
71117395Skan  { "link_arch",	LINK_ARCH_SPEC }
7218334Speter
7352284Sobrien#undef LOCAL_LABEL_PREFIX
7452284Sobrien#define LOCAL_LABEL_PREFIX "."
7596263Sobrien
76169689Skan/* The 32-bit Solaris assembler does not support .quad.  Do not use it.  */
77169689Skan#ifndef TARGET_BI_ARCH
7896263Sobrien#undef ASM_QUAD
79169689Skan#endif
80132718Skan
81132718Skan/* The Solaris assembler wants a .local for non-exported aliases.  */
82132718Skan#define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET)	\
83132718Skan  do {							\
84132718Skan    const char *declname =				\
85132718Skan      IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));	\
86132718Skan    ASM_OUTPUT_DEF ((FILE), declname,			\
87132718Skan		    IDENTIFIER_POINTER (TARGET));	\
88132718Skan    if (! TREE_PUBLIC (DECL))				\
89132718Skan      {							\
90132718Skan	fprintf ((FILE), "%s", LOCAL_ASM_OP);		\
91132718Skan	assemble_name ((FILE), declname);		\
92132718Skan	fprintf ((FILE), "\n");				\
93132718Skan      }							\
94132718Skan  } while (0)
95169689Skan
96169689Skan/* Solaris-specific #pragmas are implemented on top of attributes.  Hook in
97169689Skan   the bits from config/sol2.c.  */
98169689Skan#define SUBTARGET_INSERT_ATTRIBUTES solaris_insert_attributes
99169689Skan#define SUBTARGET_ATTRIBUTE_TABLE SOLARIS_ATTRIBUTE_TABLE
100169689Skan
101169689Skan/* Output a simple call for .init/.fini.  */
102169689Skan#define ASM_OUTPUT_CALL(FILE, FN)				\
103169689Skan  do								\
104169689Skan    {								\
105169689Skan      fprintf (FILE, "\tcall\t");				\
106169689Skan      print_operand (FILE, XEXP (DECL_RTL (FN), 0), 'P');	\
107169689Skan      fprintf (FILE, "\n");					\
108169689Skan    }								\
109169689Skan  while (0)
110169689Skan
111169689Skan/* We do not need NT_VERSION notes.  */
112169689Skan#undef X86_FILE_START_VERSION_DIRECTIVE
113169689Skan#define X86_FILE_START_VERSION_DIRECTIVE false
114