netbsd-aout.h revision 132718
1149487Stjr/* Common configuration file for NetBSD a.out targets.
260786Sps   Copyright (C) 2002 Free Software Foundation, Inc.
3170259Sdelphij   Contributed by Wasabi Systems, Inc.
460786Sps
560786SpsThis file is part of GCC.
660786Sps
760786SpsGCC is free software; you can redistribute it and/or modify
860786Spsit under the terms of the GNU General Public License as published by
960786Spsthe Free Software Foundation; either version 2, or (at your option)
1060786Spsany later version.
1160786Sps
1260786SpsGCC is distributed in the hope that it will be useful,
1360786Spsbut WITHOUT ANY WARRANTY; without even the implied warranty of
1460786SpsMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1560786SpsGNU General Public License for more details.
1660786Sps
1760786SpsYou should have received a copy of the GNU General Public License
1860786Spsalong with GCC; see the file COPYING.  If not, write to
1960786Spsthe Free Software Foundation, 59 Temple Place - Suite 330,
20161478SdelphijBoston, MA 02111-1307, USA.  */
2160786Sps
22161478Sdelphij/* TARGET_OS_CPP_BUILTINS() common to all NetBSD a.out targets.  */
2389019Sps#define NETBSD_OS_CPP_BUILTINS_AOUT()		\
2489019Sps  do						\
2560786Sps    {						\
26161478Sdelphij      NETBSD_OS_CPP_BUILTINS_COMMON();		\
2760786Sps    }						\
2889019Sps  while (0)
2989019Sps
3089019Sps/* This defines which switch letters take arguments.  */
3160786Sps
3260786Sps#undef SWITCH_TAKES_ARG
3360786Sps#define SWITCH_TAKES_ARG(CHAR)		\
3460786Sps  (DEFAULT_SWITCH_TAKES_ARG(CHAR)	\
3560786Sps   || (CHAR) == 'R')
36128345Stjr
3760786Sps
3863128Sps/* Provide an ASM_SPEC appropriate for NetBSD.  Currently we only deal
39161478Sdelphij   with the options for generating PIC code.  */
4060786Sps
4160786Sps#undef ASM_SPEC
4260786Sps#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
43161478Sdelphij
4460786Sps#define AS_NEEDS_DASH_FOR_PIPED_INPUT
45161478Sdelphij
46161478Sdelphij
4760786Sps/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out.  Here we
4860786Sps   provide support for the special GCC option -static.  */
49161478Sdelphij
5060786Sps#undef STARTFILE_SPEC
5160786Sps#define STARTFILE_SPEC			\
5260786Sps  "%{!shared:				\
5360786Sps     %{pg:gcrt0%O%s}			\
5460786Sps     %{!pg:				\
5563128Sps       %{p:mcrt0%O%s}			\
5660786Sps       %{!p:				\
5760786Sps	 %{!static:crt0%O%s}		\
5860786Sps	 %{static:scrt0%O%s}}}}"
5960786Sps
6060786Sps/* Provide a LINK_SPEC appropriate for NetBSD a.out.  Here we provide
6160786Sps   support for the special GCC options -static, -assert, and -nostdlib.  */
6260786Sps
63170259Sdelphij#undef NETBSD_LINK_SPEC_AOUT
6463128Sps#define NETBSD_LINK_SPEC_AOUT		\
6563128Sps  "%{nostdlib:-nostdlib}		\
6660786Sps   %{!shared:				\
67161478Sdelphij     %{!nostdlib:			\
68161478Sdelphij       %{!r*:				\
69161478Sdelphij	 %{!e*:-e start}}}		\
70161478Sdelphij     -dc -dp				\
71161478Sdelphij     %{static:-Bstatic}}		\
7260786Sps   %{shared:-Bshareable}		\
7360786Sps   %{R*}				\
7460786Sps   %{assert*}"
7560786Sps
7660786Sps/* Default LINK_SPEC.  */
7760786Sps#undef LINK_SPEC
7860786Sps#define LINK_SPEC NETBSD_LINK_SPEC_AOUT
7960786Sps
8060786Sps/* Some imports from svr4.h in support of shared libraries.  */
81161478Sdelphij
82161478Sdelphij/* Define the strings used for the .type, .size, and .set directives.
83161478Sdelphij   These strings generally do not vary from one system running NetBSD
84161478Sdelphij   to another, but if a given system needs to use different pseudo-op
85161478Sdelphij   names for these, they may be overridden in the file included after
8689019Sps   this one.  */
8789019Sps
8889019Sps#undef TYPE_ASM_OP
8960786Sps#undef SIZE_ASM_OP
9060786Sps#undef SET_ASM_OP
9160786Sps#define TYPE_ASM_OP	"\t.type\t"
9289019Sps#define SIZE_ASM_OP	"\t.size\t"
9389019Sps#define SET_ASM_OP	"\t.set\t"
94161478Sdelphij
9589019Sps
9689019Sps/* This is how we tell the assembler that a symbol is weak.  */
97161478Sdelphij
98161478Sdelphij#undef ASM_WEAKEN_LABEL
99161478Sdelphij#define ASM_WEAKEN_LABEL(FILE,NAME)					\
100161478Sdelphij  do 									\
101161478Sdelphij    {									\
102161478Sdelphij      fputs ("\t.globl\t", FILE); assemble_name (FILE, NAME);		\
103161478Sdelphij      fputc ('\n', FILE);						\
104161478Sdelphij      fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME);		\
10589019Sps      fputc ('\n', FILE);						\
10689019Sps    }									\
107161478Sdelphij  while (0)
10889019Sps
10989019Sps
11089019Sps/* The following macro defines the format used to output the second
11189019Sps   operand of the .type assembler directive.  Different svr4 assemblers
11289019Sps   expect various different forms of this operand.  The one given here
11389019Sps   is just a default.  You may need to override it in your machine-
11489019Sps   specific tm.h file (depending on the particulars of your assembler).  */
11589019Sps
116161478Sdelphij#undef TYPE_OPERAND_FMT
117161478Sdelphij#define TYPE_OPERAND_FMT	"@%s"
118161478Sdelphij
119161478Sdelphij
120161478Sdelphij/* Write the extra assembler code needed to declare a function's result.
121161478Sdelphij   Most svr4 assemblers don't require any special declaration of the
122161478Sdelphij   result value, but there are exceptions.  */
123161478Sdelphij
124161478Sdelphij#ifndef ASM_DECLARE_RESULT
125161478Sdelphij#define ASM_DECLARE_RESULT(FILE, RESULT)
126161478Sdelphij#endif
127161478Sdelphij
12889019Sps
12989019Sps/* These macros generate the special .type and .size directives which
130128345Stjr   are used to set the corresponding fields of the linker symbol table
131128345Stjr   entries in an ELF object file under SVR4 (and a.out on NetBSD).
132161478Sdelphij   These macros also output the starting labels for the relevant
13389019Sps   functions/objects.  */
13489019Sps
13589019Sps/* Write the extra assembler code needed to declare a function properly.
13689019Sps   Some svr4 assemblers need to also have something extra said about the
13789019Sps   function's return value.  We allow for that here.  */
13889019Sps
13989019Sps#undef ASM_DECLARE_FUNCTION_NAME
140161478Sdelphij#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
141161478Sdelphij  do									\
142161478Sdelphij    {									\
143161478Sdelphij      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");		\
144161478Sdelphij      ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));			\
145161478Sdelphij      ASM_OUTPUT_LABEL(FILE, NAME);					\
146161478Sdelphij    }									\
147161478Sdelphij  while (0)
148161478Sdelphij
149161478Sdelphij
15060786Sps/* Write the extra assembler code needed to declare an object properly.  */
15160786Sps
15260786Sps#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
15360786Sps  do								\
15460786Sps    {								\
15560786Sps      HOST_WIDE_INT size;					\
15660786Sps								\
157161478Sdelphij      ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");		\
15860786Sps								\
159161478Sdelphij      size_directive_output = 0;				\
160161478Sdelphij      if (!flag_inhibit_size_directive				\
16160786Sps	  && (DECL) && DECL_SIZE (DECL))			\
16260786Sps	{							\
16363128Sps	  size_directive_output = 1;				\
164128345Stjr	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
165128345Stjr	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
16689019Sps	}							\
167161478Sdelphij								\
16889019Sps      ASM_OUTPUT_LABEL (FILE, NAME);				\
16960786Sps    }								\
17060786Sps  while (0)
17160786Sps
17260786Sps/* Output the size directive for a decl in rest_of_decl_compilation
17360786Sps   in the case where we did not do so before the initializer.
17460786Sps   Once we find the error_mark_node, we know that the value of
17560786Sps   size_directive_output was set
17660786Sps   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
17760786Sps
178128345Stjr#undef ASM_FINISH_DECLARE_OBJECT
17960786Sps#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)	\
18060786Sps  do									\
18163128Sps    {									\
18263128Sps      const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);		\
18363128Sps      HOST_WIDE_INT size;						\
18463128Sps      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)		\
18563128Sps	  && ! AT_END && TOP_LEVEL					\
18663128Sps	  && DECL_INITIAL (DECL) == error_mark_node			\
18763128Sps	  && !size_directive_output)					\
18863128Sps	{								\
18963128Sps	  size_directive_output = 1;					\
19063128Sps	  size = int_size_in_bytes (TREE_TYPE (DECL));			\
191128345Stjr	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);			\
19263128Sps	}								\
19363128Sps    }									\
19460786Sps  while (0)
19563128Sps
19660786Sps
19763128Sps/* This is how to declare the size of a function.  */
19863128Sps
19963128Sps#undef ASM_DECLARE_FUNCTION_SIZE
20063128Sps#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
20163128Sps  do									\
202161478Sdelphij    {									\
20363128Sps      if (!flag_inhibit_size_directive)					\
204161478Sdelphij	ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);				\
20563128Sps    }									\
20663128Sps  while (0)
20763128Sps