1/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version.
2   Copyright (C) 2002-2020 Free Software Foundation, Inc.
3   Contributed by Wasabi Systems, Inc.
4
5   This file is part of GCC.
6
7   GCC is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published
9   by the Free Software Foundation; either version 3, or (at your
10   option) any later version.
11
12   GCC is distributed in the hope that it will be useful, but WITHOUT
13   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15   License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with GCC; see the file COPYING3.  If not see
19   <http://www.gnu.org/licenses/>.  */
20
21/* Run-time Target Specification.  */
22#undef MULTILIB_DEFAULTS
23#define MULTILIB_DEFAULTS { "mabi=aapcs-linux" }
24
25#define TARGET_LINKER_EABI_SUFFIX_SOFT \
26  "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=hard:_eabihf;:_eabi}}}"
27#define TARGET_LINKER_EABI_SUFFIX_HARD \
28  "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=soft:_eabi;:_eabihf}}}"
29
30#define TARGET_LINKER_EABI_SUFFIX			\
31  (TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_SOFT	\
32   ? TARGET_LINKER_EABI_SUFFIX_SOFT			\
33   : TARGET_LINKER_EABI_SUFFIX_HARD)
34
35#define TARGET_LINKER_BIG_EMULATION "armelfb_nbsd%(linker_eabi_suffix)"
36#define TARGET_LINKER_LITTLE_EMULATION "armelf_nbsd%(linker_eabi_suffix)"
37
38/* TARGET_BIG_ENDIAN_DEFAULT is set in
39   config.gcc for big endian configurations.  */
40#undef  TARGET_LINKER_EMULATION
41#if TARGET_BIG_ENDIAN_DEFAULT
42#define TARGET_LINKER_EMULATION TARGET_LINKER_BIG_EMULATION
43#else
44#define TARGET_LINKER_EMULATION TARGET_LINKER_LITTLE_EMULATION
45#endif
46
47#undef ARM_DEFAULT_ABI
48#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX
49
50#undef ARM_UNWIND_INFO
51#define ARM_UNWIND_INFO 0
52#undef ARM_DWARF_UNWIND_TABLES
53#define ARM_DWARF_UNWIND_TABLES 1
54
55#undef TARGET_OS_CPP_BUILTINS
56#define TARGET_OS_CPP_BUILTINS()		\
57  do						\
58    {						\
59      if (TARGET_AAPCS_BASED)			\
60	TARGET_BPABI_CPP_BUILTINS();		\
61      NETBSD_OS_CPP_BUILTINS_ELF();		\
62      if (ARM_DWARF_UNWIND_TABLES)		\
63	builtin_define ("__ARM_DWARF_EH__");	\
64    }						\
65  while (0)
66
67#undef SUBTARGET_CPP_SPEC
68#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
69
70/*
71 * Override AAPCS types to remain compatible the existing NetBSD types.
72 */
73#undef WCHAR_TYPE
74#define WCHAR_TYPE "int"
75
76#undef SIZE_TYPE
77#define SIZE_TYPE "long unsigned int"
78
79#undef PTRDIFF_TYPE
80#define PTRDIFF_TYPE "long int"
81
82#undef SUBTARGET_EXTRA_ASM_SPEC
83#define SUBTARGET_EXTRA_ASM_SPEC		\
84  "-matpcs %{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} "	\
85  "%{fpic|fpie:-k} "				\
86  "%{fPIC|fPIE:-k}"
87
88/* Default to full VFP if -mhard-float is specified.  */
89#undef SUBTARGET_ASM_FLOAT_SPEC
90#define SUBTARGET_ASM_FLOAT_SPEC	\
91  "%{mhard-float:%{!mfpu=*:-mfpu=vfp}}   \
92   %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfp}}"
93
94#undef SUBTARGET_EXTRA_SPECS
95#define SUBTARGET_EXTRA_SPECS						\
96  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC },		\
97  { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, 		\
98  { "linker_eabi_suffix",	TARGET_LINKER_EABI_SUFFIX },		\
99  { "linker_emulation",		TARGET_LINKER_EMULATION },		\
100  { "linker_big_emulation",	TARGET_LINKER_BIG_EMULATION },		\
101  { "linker_little_emulation",	TARGET_LINKER_LITTLE_EMULATION },	\
102  { "be8_link_spec",		BE8_LINK_SPEC }, 			\
103  { "target_fix_v4bx_spec",	TARGET_FIX_V4BX_SPEC },			\
104  NETBSD_SUBTARGET_EXTRA_SPECS
105
106#define NETBSD_ENTRY_POINT "__start"
107
108#undef LINK_SPEC
109#define LINK_SPEC						\
110  "-X %{mbig-endian:-EB -m %(linker_big_emulation)} "		\
111  "%{mlittle-endian:-EL -m %(linker_liitle_emulation)} "	\
112  "%{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} "	\
113  "%(be8_link_spec) "						\
114  "%(target_fix_v4bx_spec) %(netbsd_link_spec)"
115