elf.h revision 90075
1130293Sscottl/* Definitions of target machine for GNU compiler.
2130293Sscottl   For ARM with ELF obj format.
3130293Sscottl   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
4130293Sscottl   Free Software Foundation, Inc.
5130293Sscottl   Contributed by Philip Blundell <philb@gnu.org> and
6130293Sscottl   Catherine Moore <clm@cygnus.com>
7130293Sscottl
8130293SscottlThis file is part of GNU CC.
9130293Sscottl
10130293SscottlGNU CC is free software; you can redistribute it and/or modify
11130293Sscottlit under the terms of the GNU General Public License as published by
12130293Sscottlthe Free Software Foundation; either version 2, or (at your option)
13130293Sscottlany later version.
14130293Sscottl
15130293SscottlGNU CC is distributed in the hope that it will be useful,
16130293Sscottlbut WITHOUT ANY WARRANTY; without even the implied warranty of
17130293SscottlMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18130293SscottlGNU General Public License for more details.
19130293Sscottl
20130293SscottlYou should have received a copy of the GNU General Public License
21130293Sscottlalong with GNU CC; see the file COPYING.  If not, write to
22130293Sscottlthe Free Software Foundation, 59 Temple Place - Suite 330,
23130293SscottlBoston, MA 02111-1307, USA.  */
24130293Sscottl
25130293Sscottl#ifndef OBJECT_FORMAT_ELF
26130293Sscottl #error elf.h included before elfos.h
27130293Sscottl#endif
28130293Sscottl
29130293Sscottl#ifndef LOCAL_LABEL_PREFIX
30130293Sscottl#define LOCAL_LABEL_PREFIX "."
31130293Sscottl#endif
32130293Sscottl
33130293Sscottl#ifndef SUBTARGET_CPP_SPEC
34130293Sscottl#define SUBTARGET_CPP_SPEC  "-D__ELF__"
35130293Sscottl#endif
36130293Sscottl
37130293Sscottl#ifndef SUBTARGET_EXTRA_SPECS
38130293Sscottl#define SUBTARGET_EXTRA_SPECS \
39130293Sscottl  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC },
40130293Sscottl#endif
41130293Sscottl
42130293Sscottl#ifndef SUBTARGET_EXTRA_ASM_SPEC
43130293Sscottl#define SUBTARGET_EXTRA_ASM_SPEC ""
44130293Sscottl#endif
45130293Sscottl
46130293Sscottl#ifndef ASM_SPEC
47130293Sscottl#define ASM_SPEC "\
48130293Sscottl%{mbig-endian:-EB} \
49130293Sscottl%{mcpu=*:-m%*} \
50130293Sscottl%{march=*:-m%*} \
51130293Sscottl%{mapcs-*:-mapcs-%*} \
52130293Sscottl%{mapcs-float:-mfloat} \
53130293Sscottl%{msoft-float:-mno-fpu} \
54130293Sscottl%{mthumb-interwork:-mthumb-interwork} \
55130293Sscottl%(subtarget_extra_asm_spec)"
56130293Sscottl#endif
57130293Sscottl
58130293Sscottl/* The ARM uses @ are a comment character so we need to redefine
59130293Sscottl   TYPE_OPERAND_FMT.  */
60130293Sscottl#undef  TYPE_OPERAND_FMT
61130293Sscottl#define TYPE_OPERAND_FMT	"%s"
62130293Sscottl
63130293Sscottl/* We might need a ARM specific header to function declarations.  */
64130293Sscottl#undef  ASM_DECLARE_FUNCTION_NAME
65130293Sscottl#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)	\
66130293Sscottl  do							\
67130293Sscottl    {							\
68130293Sscottl      ARM_DECLARE_FUNCTION_NAME (FILE, NAME, DECL);     \
69130293Sscottl      fprintf (FILE, "%s", TYPE_ASM_OP);		\
70130293Sscottl      assemble_name (FILE, NAME);			\
71130293Sscottl      putc (',', FILE);					\
72130293Sscottl      fprintf (FILE, TYPE_OPERAND_FMT, "function");	\
73130293Sscottl      putc ('\n', FILE);				\
74130293Sscottl      ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));	\
75130293Sscottl      ASM_OUTPUT_LABEL(FILE, NAME);			\
76130293Sscottl    }							\
77130293Sscottl  while (0)
78130293Sscottl
79130293Sscottl/* We might need an ARM specific trailer for function declarations.  */
80130293Sscottl#undef  ASM_DECLARE_FUNCTION_SIZE
81130293Sscottl#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)		\
82130293Sscottl  do								\
83130293Sscottl    {								\
84130293Sscottl      ARM_DECLARE_FUNCTION_SIZE (FILE, FNAME, DECL);		\
85130293Sscottl      if (!flag_inhibit_size_directive)				\
86130293Sscottl        {							\
87130293Sscottl          char label[256];					\
88130293Sscottl	  static int labelno;					\
89130293Sscottl	  labelno ++;						\
90130293Sscottl	  ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);	\
91130293Sscottl	  ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);	\
92130293Sscottl	  fprintf (FILE, "%s", SIZE_ASM_OP);			\
93130293Sscottl	  assemble_name (FILE, (FNAME));			\
94130293Sscottl          fprintf (FILE, ",");					\
95130293Sscottl	  assemble_name (FILE, label);				\
96130293Sscottl          fprintf (FILE, "-");					\
97130293Sscottl	  assemble_name (FILE, (FNAME));			\
98130293Sscottl	  putc ('\n', FILE);					\
99130293Sscottl        }							\
100130293Sscottl    }								\
101130293Sscottl  while (0)
102130293Sscottl
103130293Sscottl/* Define this macro if jump tables (for `tablejump' insns) should be
104130293Sscottl   output in the text section, along with the assembler instructions.
105130293Sscottl   Otherwise, the readonly data section is used.  */
106130293Sscottl#define JUMP_TABLES_IN_TEXT_SECTION 1
107130293Sscottl
108130293Sscottl#ifndef LINK_SPEC
109130293Sscottl#define LINK_SPEC "%{mbig-endian:-EB} -X"
110130293Sscottl#endif
111130293Sscottl
112130293Sscottl/* Run-time Target Specification.  */
113130293Sscottl#ifndef TARGET_VERSION
114130293Sscottl#define TARGET_VERSION fputs (" (ARM/elf)", stderr)
115130293Sscottl#endif
116130293Sscottl
117130293Sscottl#ifndef TARGET_DEFAULT
118130293Sscottl#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME)
119130293Sscottl#endif
120130293Sscottl
121130293Sscottl#ifndef MULTILIB_DEFAULTS
122130293Sscottl#define MULTILIB_DEFAULTS \
123130293Sscottl  { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
124130293Sscottl#endif
125130293Sscottl
126130293Sscottl
127130293Sscottl/* This outputs a lot of .req's to define alias for various registers.
128130293Sscottl   Let's try to avoid this.  */
129130293Sscottl#ifndef ASM_FILE_START
130130293Sscottl#define ASM_FILE_START(STREAM)					\
131130293Sscottl  do								\
132130293Sscottl    {								\
133130293Sscottl      fprintf (STREAM, "%s Generated by gcc %s for ARM/elf\n",	\
134130293Sscottl	       ASM_COMMENT_START, version_string);		\
135130293Sscottl      output_file_directive (STREAM, main_input_filename);	\
136130293Sscottl      fprintf (STREAM, ASM_APP_OFF);				\
137130293Sscottl    }								\
138130293Sscottl  while (0)
139130293Sscottl#endif
140130293Sscottl
141130293Sscottl/* Output an internal label definition.  */
142130293Sscottl#undef  ASM_OUTPUT_INTERNAL_LABEL
143130293Sscottl#define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM)  	\
144130293Sscottl  do								\
145130293Sscottl    {								\
146130293Sscottl      char * s = (char *) alloca (40 + strlen (PREFIX));	\
147130293Sscottl      extern int arm_target_label, arm_ccfsm_state;		\
148130293Sscottl      extern rtx arm_target_insn;				\
149130293Sscottl								\
150130293Sscottl      if (arm_ccfsm_state == 3 && arm_target_label == (NUM)	\
151130293Sscottl	  && !strcmp (PREFIX, "L"))				\
152130293Sscottl	{							\
153130293Sscottl	  arm_ccfsm_state = 0;					\
154130293Sscottl	  arm_target_insn = NULL;				\
155130293Sscottl	}							\
156130293Sscottl      ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM));		\
157130293Sscottl      ASM_OUTPUT_LABEL (STREAM, s);		                \
158130293Sscottl    }								\
159130293Sscottl  while (0)
160130293Sscottl
161130293Sscottl#undef  TARGET_ASM_NAMED_SECTION
162130293Sscottl#define TARGET_ASM_NAMED_SECTION  arm_elf_asm_named_section
163130293Sscottl
164130293Sscottl#undef  ASM_OUTPUT_ALIGNED_COMMON
165130293Sscottl#define ASM_OUTPUT_ALIGNED_COMMON(STREAM, NAME, SIZE, ALIGN)	\
166130293Sscottl  do								\
167130293Sscottl    {								\
168130293Sscottl      fprintf (STREAM, "\t.comm\t");				\
169130293Sscottl      assemble_name (STREAM, NAME);				\
170130293Sscottl      fprintf (STREAM, ", %d, %d\n", SIZE, ALIGN);		\
171130293Sscottl    }								\
172130293Sscottl  while (0)
173130293Sscottl
174130293Sscottl/* For PIC code we need to explicitly specify (PLT) and (GOT) relocs.  */
175130293Sscottl#define NEED_PLT_RELOC	flag_pic
176130293Sscottl#define NEED_GOT_RELOC	flag_pic
177130293Sscottl
178130293Sscottl/* The ELF assembler handles GOT addressing differently to NetBSD.  */
179130293Sscottl#define GOT_PCREL	0
180130293Sscottl
181130293Sscottl/* Biggest alignment supported by the object file format of this
182130293Sscottl   machine.  Use this macro to limit the alignment which can be
183130293Sscottl   specified using the `__attribute__ ((aligned (N)))' construct.  If
184130293Sscottl   not defined, the default value is `BIGGEST_ALIGNMENT'.  */
185130293Sscottl#define MAX_OFILE_ALIGNMENT (32768 * 8)
186130293Sscottl
187130293Sscottl/* Align output to a power of two.  Note ".align 0" is redundant,
188130293Sscottl   and also GAS will treat it as ".align 2" which we do not want.  */
189130293Sscottl#define ASM_OUTPUT_ALIGN(STREAM, POWER)			\
190130293Sscottl  do							\
191130293Sscottl    {							\
192130293Sscottl      if ((POWER) > 0)					\
193130293Sscottl	fprintf (STREAM, "\t.align\t%d\n", POWER);	\
194130293Sscottl    }							\
195130293Sscottl  while (0)
196130293Sscottl
197130293Sscottl#define SUPPORTS_INIT_PRIORITY 1
198130293Sscottl