1  /* Definitions of target machine for GNU compiler.
       2     For ARM with ELF obj format.
       3     Copyright (C) 1995-2023 Free Software Foundation, Inc.
       4     Contributed by Philip Blundell <philb@gnu.org> and
       5     Catherine Moore <clm@cygnus.com>
       6     
       7     This file is part of GCC.
       8  
       9     GCC is free software; you can redistribute it and/or modify it
      10     under the terms of the GNU General Public License as published
      11     by the Free Software Foundation; either version 3, or (at your
      12     option) any later version.
      13  
      14     GCC is distributed in the hope that it will be useful, but WITHOUT
      15     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      16     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
      17     License for more details.
      18  
      19     Under Section 7 of GPL version 3, you are granted additional
      20     permissions described in the GCC Runtime Library Exception, version
      21     3.1, as published by the Free Software Foundation.
      22  
      23     You should have received a copy of the GNU General Public License and
      24     a copy of the GCC Runtime Library Exception along with this program;
      25     see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      26     <http://www.gnu.org/licenses/>.  */
      27  
      28  #ifndef OBJECT_FORMAT_ELF
      29   #error elf.h included before elfos.h
      30  #endif
      31  
      32  #ifndef LOCAL_LABEL_PREFIX
      33  #define LOCAL_LABEL_PREFIX "."
      34  #endif
      35  
      36  #ifndef SUBTARGET_CPP_SPEC
      37  #define SUBTARGET_CPP_SPEC  "-D__ELF__"
      38  #endif
      39  
      40  #ifndef SUBTARGET_EXTRA_SPECS
      41  #define SUBTARGET_EXTRA_SPECS \
      42    { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC }, \
      43    { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, \
      44    SUBSUBTARGET_EXTRA_SPECS
      45  #endif
      46  
      47  #ifndef SUBTARGET_EXTRA_ASM_SPEC
      48  #define SUBTARGET_EXTRA_ASM_SPEC ""
      49  #endif
      50  
      51  #ifndef SUBTARGET_ASM_FLOAT_SPEC
      52  #define SUBTARGET_ASM_FLOAT_SPEC "\
      53  %{mapcs-float:-mfloat}"
      54  #endif
      55  
      56  #undef SUBSUBTARGET_EXTRA_SPECS
      57  #define SUBSUBTARGET_EXTRA_SPECS
      58  
      59  #ifndef ASM_SPEC
      60  #define ASM_SPEC "\
      61  %{mbig-endian:-EB} \
      62  %{mlittle-endian:-EL} \
      63  %(asm_cpu_spec) \
      64  %{mapcs-*:-mapcs-%*} \
      65  %(subtarget_asm_float_spec) \
      66  %{mthumb-interwork:-mthumb-interwork} \
      67  %{mfloat-abi=*} %{!mfpu=auto: %{mfpu=*}} \
      68  %(subtarget_extra_asm_spec)"
      69  #endif
      70  
      71  /* The ARM uses @ are a comment character so we need to redefine
      72     TYPE_OPERAND_FMT.  */
      73  #undef  TYPE_OPERAND_FMT
      74  #define TYPE_OPERAND_FMT	"%%%s"
      75  
      76  /* We might need a ARM specific header to function declarations.  */
      77  #undef  ASM_DECLARE_FUNCTION_NAME
      78  #define ASM_DECLARE_FUNCTION_NAME arm_asm_declare_function_name
      79  
      80  /* We might need an ARM specific trailer for function declarations.  */
      81  #undef  ASM_DECLARE_FUNCTION_SIZE
      82  #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)		\
      83    do								\
      84      {								\
      85        ARM_OUTPUT_FN_UNWIND (FILE, FALSE);			\
      86        if (!flag_inhibit_size_directive)				\
      87  	ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);			\
      88      }								\
      89    while (0)
      90  
      91  /* Define this macro if jump tables (for `tablejump' insns) should be
      92     output in the text section, along with the assembler instructions.
      93     Otherwise, the readonly data section is used.  */
      94  /* We put ARM and Thumb-2 jump tables in the text section, because it makes
      95     the code more efficient, but for Thumb-1 it's better to put them out of
      96     band unless we are generating compressed tables.  */
      97  #define JUMP_TABLES_IN_TEXT_SECTION					\
      98     ((TARGET_32BIT || (TARGET_THUMB && (optimize_size || flag_pic))) \
      99      && !target_pure_code)
     100  
     101  #ifndef LINK_SPEC
     102  #define LINK_SPEC "%{mbig-endian:-EB} %{mlittle-endian:-EL} -X"
     103  #endif
     104    
     105  /* Run-time Target Specification.  */
     106  #ifndef TARGET_DEFAULT
     107  #define TARGET_DEFAULT (MASK_APCS_FRAME)
     108  #endif
     109  
     110  
     111  #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
     112  
     113  
     114  /* Output an element in the static constructor array.  */
     115  #undef TARGET_ASM_CONSTRUCTOR
     116  #define TARGET_ASM_CONSTRUCTOR arm_elf_asm_constructor
     117  
     118  #undef TARGET_ASM_DESTRUCTOR
     119  #define TARGET_ASM_DESTRUCTOR arm_elf_asm_destructor
     120  
     121  /* For PIC code we need to explicitly specify (PLT) and (GOT) relocs.  */
     122  #define NEED_PLT_RELOC	flag_pic
     123  #define NEED_GOT_RELOC	flag_pic
     124  
     125  /* The ELF assembler handles GOT addressing differently to NetBSD.  */
     126  #define GOT_PCREL	0
     127  
     128  /* Align output to a power of two.  Note ".align 0" is redundant,
     129     and also GAS will treat it as ".align 2" which we do not want.  */
     130  #define ASM_OUTPUT_ALIGN(STREAM, POWER)			\
     131    do							\
     132      {							\
     133        if ((POWER) > 0)					\
     134  	fprintf (STREAM, "\t.align\t%d\n", POWER);	\
     135      }							\
     136    while (0)
     137  
     138  /* Horrible hack: We want to prevent some libgcc routines being included
     139     for some multilibs.  The condition should match the one in
     140     libgcc/config/arm/lib1funcs.S and libgcc/config/arm/t-elf.  */
     141  #if __ARM_ARCH_ISA_ARM || __ARM_ARCH_ISA_THUMB != 1
     142  #undef L_fixdfsi
     143  #undef L_fixunsdfsi
     144  #undef L_truncdfsf2
     145  #undef L_fixsfsi
     146  #undef L_fixunssfsi
     147  #undef L_floatdidf
     148  #undef L_floatdisf
     149  #undef L_floatundidf
     150  #undef L_floatundisf
     151  #endif
     152