elf.h revision 96263
190075Sobrien/* Definitions of target machine for GNU compiler.
290075Sobrien   For ARM with ELF obj format.
390075Sobrien   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001
490075Sobrien   Free Software Foundation, Inc.
590075Sobrien   Contributed by Philip Blundell <philb@gnu.org> and
690075Sobrien   Catherine Moore <clm@cygnus.com>
790075Sobrien
890075SobrienThis file is part of GNU CC.
990075Sobrien
1090075SobrienGNU CC is free software; you can redistribute it and/or modify
1190075Sobrienit under the terms of the GNU General Public License as published by
1290075Sobrienthe Free Software Foundation; either version 2, or (at your option)
1390075Sobrienany later version.
1490075Sobrien
1590075SobrienGNU CC is distributed in the hope that it will be useful,
1690075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1790075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1890075SobrienGNU General Public License for more details.
1990075Sobrien
2090075SobrienYou should have received a copy of the GNU General Public License
2190075Sobrienalong with GNU CC; see the file COPYING.  If not, write to
2290075Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
2390075SobrienBoston, MA 02111-1307, USA.  */
2490075Sobrien
2590075Sobrien#ifndef OBJECT_FORMAT_ELF
2690075Sobrien #error elf.h included before elfos.h
2790075Sobrien#endif
2890075Sobrien
2990075Sobrien#ifndef LOCAL_LABEL_PREFIX
3090075Sobrien#define LOCAL_LABEL_PREFIX "."
3190075Sobrien#endif
3290075Sobrien
3390075Sobrien#ifndef SUBTARGET_CPP_SPEC
3490075Sobrien#define SUBTARGET_CPP_SPEC  "-D__ELF__"
3590075Sobrien#endif
3690075Sobrien
3790075Sobrien#ifndef SUBTARGET_EXTRA_SPECS
3890075Sobrien#define SUBTARGET_EXTRA_SPECS \
3990075Sobrien  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC },
4090075Sobrien#endif
4190075Sobrien
4290075Sobrien#ifndef SUBTARGET_EXTRA_ASM_SPEC
4390075Sobrien#define SUBTARGET_EXTRA_ASM_SPEC ""
4490075Sobrien#endif
4590075Sobrien
4690075Sobrien#ifndef ASM_SPEC
4790075Sobrien#define ASM_SPEC "\
4890075Sobrien%{mbig-endian:-EB} \
4990075Sobrien%{mcpu=*:-m%*} \
5090075Sobrien%{march=*:-m%*} \
5190075Sobrien%{mapcs-*:-mapcs-%*} \
5290075Sobrien%{mapcs-float:-mfloat} \
5390075Sobrien%{msoft-float:-mno-fpu} \
5490075Sobrien%{mthumb-interwork:-mthumb-interwork} \
5590075Sobrien%(subtarget_extra_asm_spec)"
5690075Sobrien#endif
5790075Sobrien
5890075Sobrien/* The ARM uses @ are a comment character so we need to redefine
5990075Sobrien   TYPE_OPERAND_FMT.  */
6090075Sobrien#undef  TYPE_OPERAND_FMT
6190075Sobrien#define TYPE_OPERAND_FMT	"%s"
6290075Sobrien
6390075Sobrien/* We might need a ARM specific header to function declarations.  */
6490075Sobrien#undef  ASM_DECLARE_FUNCTION_NAME
6590075Sobrien#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)	\
6690075Sobrien  do							\
6790075Sobrien    {							\
6890075Sobrien      ARM_DECLARE_FUNCTION_NAME (FILE, NAME, DECL);     \
6990075Sobrien      fprintf (FILE, "%s", TYPE_ASM_OP);		\
7090075Sobrien      assemble_name (FILE, NAME);			\
7190075Sobrien      putc (',', FILE);					\
7290075Sobrien      fprintf (FILE, TYPE_OPERAND_FMT, "function");	\
7390075Sobrien      putc ('\n', FILE);				\
7490075Sobrien      ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));	\
7590075Sobrien      ASM_OUTPUT_LABEL(FILE, NAME);			\
7690075Sobrien    }							\
7790075Sobrien  while (0)
7890075Sobrien
7990075Sobrien/* We might need an ARM specific trailer for function declarations.  */
8090075Sobrien#undef  ASM_DECLARE_FUNCTION_SIZE
8190075Sobrien#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)		\
8290075Sobrien  do								\
8390075Sobrien    {								\
8490075Sobrien      ARM_DECLARE_FUNCTION_SIZE (FILE, FNAME, DECL);		\
8590075Sobrien      if (!flag_inhibit_size_directive)				\
8690075Sobrien        {							\
8790075Sobrien          char label[256];					\
8890075Sobrien	  static int labelno;					\
8990075Sobrien	  labelno ++;						\
9090075Sobrien	  ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);	\
9190075Sobrien	  ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);	\
9290075Sobrien	  fprintf (FILE, "%s", SIZE_ASM_OP);			\
9390075Sobrien	  assemble_name (FILE, (FNAME));			\
9490075Sobrien          fprintf (FILE, ",");					\
9590075Sobrien	  assemble_name (FILE, label);				\
9690075Sobrien          fprintf (FILE, "-");					\
9790075Sobrien	  assemble_name (FILE, (FNAME));			\
9890075Sobrien	  putc ('\n', FILE);					\
9990075Sobrien        }							\
10090075Sobrien    }								\
10190075Sobrien  while (0)
10290075Sobrien
10390075Sobrien/* Define this macro if jump tables (for `tablejump' insns) should be
10490075Sobrien   output in the text section, along with the assembler instructions.
10590075Sobrien   Otherwise, the readonly data section is used.  */
10696263Sobrien/* We put ARM jump tables in the text section, because it makes the code
10796263Sobrien   more efficient, but for Thumb it's better to put them out of band.  */
10896263Sobrien#define JUMP_TABLES_IN_TEXT_SECTION (TARGET_ARM)
10990075Sobrien
11090075Sobrien#ifndef LINK_SPEC
11190075Sobrien#define LINK_SPEC "%{mbig-endian:-EB} -X"
11290075Sobrien#endif
11390075Sobrien
11490075Sobrien/* Run-time Target Specification.  */
11590075Sobrien#ifndef TARGET_VERSION
11690075Sobrien#define TARGET_VERSION fputs (" (ARM/elf)", stderr)
11790075Sobrien#endif
11890075Sobrien
11990075Sobrien#ifndef TARGET_DEFAULT
12090075Sobrien#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32 | ARM_FLAG_APCS_FRAME)
12190075Sobrien#endif
12290075Sobrien
12390075Sobrien#ifndef MULTILIB_DEFAULTS
12490075Sobrien#define MULTILIB_DEFAULTS \
12590075Sobrien  { "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork", "fno-leading-underscore" }
12690075Sobrien#endif
12790075Sobrien
12890075Sobrien
12990075Sobrien/* This outputs a lot of .req's to define alias for various registers.
13090075Sobrien   Let's try to avoid this.  */
13190075Sobrien#ifndef ASM_FILE_START
13290075Sobrien#define ASM_FILE_START(STREAM)					\
13390075Sobrien  do								\
13490075Sobrien    {								\
13590075Sobrien      fprintf (STREAM, "%s Generated by gcc %s for ARM/elf\n",	\
13690075Sobrien	       ASM_COMMENT_START, version_string);		\
13790075Sobrien      output_file_directive (STREAM, main_input_filename);	\
13890075Sobrien      fprintf (STREAM, ASM_APP_OFF);				\
13990075Sobrien    }								\
14090075Sobrien  while (0)
14190075Sobrien#endif
14290075Sobrien
14390075Sobrien/* Output an internal label definition.  */
14490075Sobrien#undef  ASM_OUTPUT_INTERNAL_LABEL
14590075Sobrien#define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM)  	\
14690075Sobrien  do								\
14790075Sobrien    {								\
14890075Sobrien      char * s = (char *) alloca (40 + strlen (PREFIX));	\
14990075Sobrien      extern int arm_target_label, arm_ccfsm_state;		\
15090075Sobrien      extern rtx arm_target_insn;				\
15190075Sobrien								\
15290075Sobrien      if (arm_ccfsm_state == 3 && arm_target_label == (NUM)	\
15390075Sobrien	  && !strcmp (PREFIX, "L"))				\
15490075Sobrien	{							\
15590075Sobrien	  arm_ccfsm_state = 0;					\
15690075Sobrien	  arm_target_insn = NULL;				\
15790075Sobrien	}							\
15890075Sobrien      ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM));		\
15990075Sobrien      ASM_OUTPUT_LABEL (STREAM, s);		                \
16090075Sobrien    }								\
16190075Sobrien  while (0)
16290075Sobrien
16390075Sobrien#undef  TARGET_ASM_NAMED_SECTION
16490075Sobrien#define TARGET_ASM_NAMED_SECTION  arm_elf_asm_named_section
16590075Sobrien
16690075Sobrien#undef  ASM_OUTPUT_ALIGNED_COMMON
16790075Sobrien#define ASM_OUTPUT_ALIGNED_COMMON(STREAM, NAME, SIZE, ALIGN)	\
16890075Sobrien  do								\
16990075Sobrien    {								\
17090075Sobrien      fprintf (STREAM, "\t.comm\t");				\
17190075Sobrien      assemble_name (STREAM, NAME);				\
17290075Sobrien      fprintf (STREAM, ", %d, %d\n", SIZE, ALIGN);		\
17390075Sobrien    }								\
17490075Sobrien  while (0)
17590075Sobrien
17690075Sobrien/* For PIC code we need to explicitly specify (PLT) and (GOT) relocs.  */
17790075Sobrien#define NEED_PLT_RELOC	flag_pic
17890075Sobrien#define NEED_GOT_RELOC	flag_pic
17990075Sobrien
18090075Sobrien/* The ELF assembler handles GOT addressing differently to NetBSD.  */
18190075Sobrien#define GOT_PCREL	0
18290075Sobrien
18390075Sobrien/* Biggest alignment supported by the object file format of this
18490075Sobrien   machine.  Use this macro to limit the alignment which can be
18590075Sobrien   specified using the `__attribute__ ((aligned (N)))' construct.  If
18690075Sobrien   not defined, the default value is `BIGGEST_ALIGNMENT'.  */
18790075Sobrien#define MAX_OFILE_ALIGNMENT (32768 * 8)
18890075Sobrien
18990075Sobrien/* Align output to a power of two.  Note ".align 0" is redundant,
19090075Sobrien   and also GAS will treat it as ".align 2" which we do not want.  */
19190075Sobrien#define ASM_OUTPUT_ALIGN(STREAM, POWER)			\
19290075Sobrien  do							\
19390075Sobrien    {							\
19490075Sobrien      if ((POWER) > 0)					\
19590075Sobrien	fprintf (STREAM, "\t.align\t%d\n", POWER);	\
19690075Sobrien    }							\
19790075Sobrien  while (0)
19890075Sobrien
19990075Sobrien#define SUPPORTS_INIT_PRIORITY 1
200