190075Sobrien/* Common configuration file for NetBSD a.out targets.
290075Sobrien   Copyright (C) 2002 Free Software Foundation, Inc.
390075Sobrien   Contributed by Wasabi Systems, Inc.
490075Sobrien
5132718SkanThis file is part of GCC.
690075Sobrien
7132718SkanGCC is free software; you can redistribute it and/or modify
890075Sobrienit under the terms of the GNU General Public License as published by
990075Sobrienthe Free Software Foundation; either version 2, or (at your option)
1090075Sobrienany later version.
1190075Sobrien
12132718SkanGCC is distributed in the hope that it will be useful,
1390075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1490075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1590075SobrienGNU General Public License for more details.
1690075Sobrien
1790075SobrienYou should have received a copy of the GNU General Public License
18132718Skanalong with GCC; see the file COPYING.  If not, write to
19169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20169689SkanBoston, MA 02110-1301, USA.  */
2190075Sobrien
22117395Skan/* TARGET_OS_CPP_BUILTINS() common to all NetBSD a.out targets.  */
23117395Skan#define NETBSD_OS_CPP_BUILTINS_AOUT()		\
24117395Skan  do						\
25117395Skan    {						\
26117395Skan      NETBSD_OS_CPP_BUILTINS_COMMON();		\
27117395Skan    }						\
28117395Skan  while (0)
2990075Sobrien
30117395Skan/* This defines which switch letters take arguments.  */
31117395Skan
3290075Sobrien#undef SWITCH_TAKES_ARG
3390075Sobrien#define SWITCH_TAKES_ARG(CHAR)		\
3490075Sobrien  (DEFAULT_SWITCH_TAKES_ARG(CHAR)	\
3590075Sobrien   || (CHAR) == 'R')
3690075Sobrien
3790075Sobrien
3890075Sobrien/* Provide an ASM_SPEC appropriate for NetBSD.  Currently we only deal
3990075Sobrien   with the options for generating PIC code.  */
4090075Sobrien
4190075Sobrien#undef ASM_SPEC
42132718Skan#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
4390075Sobrien
44132718Skan#define AS_NEEDS_DASH_FOR_PIPED_INPUT
4590075Sobrien
46132718Skan
4790075Sobrien/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out.  Here we
4890075Sobrien   provide support for the special GCC option -static.  */
4990075Sobrien
5090075Sobrien#undef STARTFILE_SPEC
5190075Sobrien#define STARTFILE_SPEC			\
5290075Sobrien  "%{!shared:				\
5390075Sobrien     %{pg:gcrt0%O%s}			\
5490075Sobrien     %{!pg:				\
5590075Sobrien       %{p:mcrt0%O%s}			\
5690075Sobrien       %{!p:				\
5790075Sobrien	 %{!static:crt0%O%s}		\
5890075Sobrien	 %{static:scrt0%O%s}}}}"
5990075Sobrien
6090075Sobrien/* Provide a LINK_SPEC appropriate for NetBSD a.out.  Here we provide
6190075Sobrien   support for the special GCC options -static, -assert, and -nostdlib.  */
6290075Sobrien
63117395Skan#undef NETBSD_LINK_SPEC_AOUT
64117395Skan#define NETBSD_LINK_SPEC_AOUT		\
6590075Sobrien  "%{nostdlib:-nostdlib}		\
6690075Sobrien   %{!shared:				\
6790075Sobrien     %{!nostdlib:			\
6890075Sobrien       %{!r*:				\
6990075Sobrien	 %{!e*:-e start}}}		\
7090075Sobrien     -dc -dp				\
7190075Sobrien     %{static:-Bstatic}}		\
7290075Sobrien   %{shared:-Bshareable}		\
7390075Sobrien   %{R*}				\
7490075Sobrien   %{assert*}"
7590075Sobrien
76117395Skan/* Default LINK_SPEC.  */
77117395Skan#undef LINK_SPEC
78117395Skan#define LINK_SPEC NETBSD_LINK_SPEC_AOUT
7990075Sobrien
8090075Sobrien/* Some imports from svr4.h in support of shared libraries.  */
8190075Sobrien
8290075Sobrien/* Define the strings used for the .type, .size, and .set directives.
8390075Sobrien   These strings generally do not vary from one system running NetBSD
8490075Sobrien   to another, but if a given system needs to use different pseudo-op
8590075Sobrien   names for these, they may be overridden in the file included after
8690075Sobrien   this one.  */
8790075Sobrien
8890075Sobrien#undef TYPE_ASM_OP
8990075Sobrien#undef SIZE_ASM_OP
9090075Sobrien#undef SET_ASM_OP
9190075Sobrien#define TYPE_ASM_OP	"\t.type\t"
9290075Sobrien#define SIZE_ASM_OP	"\t.size\t"
9390075Sobrien#define SET_ASM_OP	"\t.set\t"
9490075Sobrien
9590075Sobrien
9690075Sobrien/* This is how we tell the assembler that a symbol is weak.  */
9790075Sobrien
9890075Sobrien#undef ASM_WEAKEN_LABEL
9990075Sobrien#define ASM_WEAKEN_LABEL(FILE,NAME)					\
10090075Sobrien  do 									\
10190075Sobrien    {									\
10290075Sobrien      fputs ("\t.globl\t", FILE); assemble_name (FILE, NAME);		\
10390075Sobrien      fputc ('\n', FILE);						\
10490075Sobrien      fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME);		\
10590075Sobrien      fputc ('\n', FILE);						\
10690075Sobrien    }									\
10790075Sobrien  while (0)
10890075Sobrien
10990075Sobrien
11090075Sobrien/* The following macro defines the format used to output the second
11190075Sobrien   operand of the .type assembler directive.  Different svr4 assemblers
11290075Sobrien   expect various different forms of this operand.  The one given here
11390075Sobrien   is just a default.  You may need to override it in your machine-
11490075Sobrien   specific tm.h file (depending on the particulars of your assembler).  */
11590075Sobrien
11690075Sobrien#undef TYPE_OPERAND_FMT
11790075Sobrien#define TYPE_OPERAND_FMT	"@%s"
11890075Sobrien
11990075Sobrien
12090075Sobrien/* Write the extra assembler code needed to declare a function's result.
12190075Sobrien   Most svr4 assemblers don't require any special declaration of the
12290075Sobrien   result value, but there are exceptions.  */
12390075Sobrien
12490075Sobrien#ifndef ASM_DECLARE_RESULT
12590075Sobrien#define ASM_DECLARE_RESULT(FILE, RESULT)
12690075Sobrien#endif
12790075Sobrien
12890075Sobrien
12990075Sobrien/* These macros generate the special .type and .size directives which
13090075Sobrien   are used to set the corresponding fields of the linker symbol table
13190075Sobrien   entries in an ELF object file under SVR4 (and a.out on NetBSD).
13290075Sobrien   These macros also output the starting labels for the relevant
13390075Sobrien   functions/objects.  */
13490075Sobrien
13590075Sobrien/* Write the extra assembler code needed to declare a function properly.
13690075Sobrien   Some svr4 assemblers need to also have something extra said about the
13790075Sobrien   function's return value.  We allow for that here.  */
13890075Sobrien
13990075Sobrien#undef ASM_DECLARE_FUNCTION_NAME
14090075Sobrien#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
14190075Sobrien  do									\
14290075Sobrien    {									\
143117395Skan      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");		\
14490075Sobrien      ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));			\
14590075Sobrien      ASM_OUTPUT_LABEL(FILE, NAME);					\
14690075Sobrien    }									\
14790075Sobrien  while (0)
14890075Sobrien
14990075Sobrien
15090075Sobrien/* Write the extra assembler code needed to declare an object properly.  */
15190075Sobrien
152117395Skan#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
153117395Skan  do								\
154117395Skan    {								\
155117395Skan      HOST_WIDE_INT size;					\
156117395Skan								\
157117395Skan      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");		\
158117395Skan								\
159117395Skan      size_directive_output = 0;				\
160117395Skan      if (!flag_inhibit_size_directive				\
161117395Skan	  && (DECL) && DECL_SIZE (DECL))			\
162117395Skan	{							\
163117395Skan	  size_directive_output = 1;				\
164117395Skan	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
165117395Skan	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
166117395Skan	}							\
167117395Skan								\
168117395Skan      ASM_OUTPUT_LABEL (FILE, NAME);				\
169117395Skan    }								\
17090075Sobrien  while (0)
17190075Sobrien
17290075Sobrien/* Output the size directive for a decl in rest_of_decl_compilation
17390075Sobrien   in the case where we did not do so before the initializer.
17490075Sobrien   Once we find the error_mark_node, we know that the value of
17590075Sobrien   size_directive_output was set
17690075Sobrien   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
17790075Sobrien
17890075Sobrien#undef ASM_FINISH_DECLARE_OBJECT
17990075Sobrien#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)	\
18090075Sobrien  do									\
18190075Sobrien    {									\
18290075Sobrien      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);		\
183117395Skan      HOST_WIDE_INT size;						\
18490075Sobrien      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)		\
18590075Sobrien	  && ! AT_END && TOP_LEVEL					\
18690075Sobrien	  && DECL_INITIAL (DECL) == error_mark_node			\
18790075Sobrien	  && !size_directive_output)					\
18890075Sobrien	{								\
18990075Sobrien	  size_directive_output = 1;					\
190117395Skan	  size = int_size_in_bytes (TREE_TYPE (DECL));			\
191117395Skan	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);			\
19290075Sobrien	}								\
19390075Sobrien    }									\
19490075Sobrien  while (0)
19590075Sobrien
19690075Sobrien
19790075Sobrien/* This is how to declare the size of a function.  */
19890075Sobrien
19990075Sobrien#undef ASM_DECLARE_FUNCTION_SIZE
20090075Sobrien#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
20190075Sobrien  do									\
20290075Sobrien    {									\
20390075Sobrien      if (!flag_inhibit_size_directive)					\
204117395Skan	ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);				\
20590075Sobrien    }									\
20690075Sobrien  while (0)
207