xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/config/arm/netbsd-elf.h (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /* Definitions of target machine for GNU compiler, NetBSD/arm ELF version.
2    Copyright (C) 2002-2015 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    Under Section 7 of GPL version 3, you are granted additional
18    permissions described in the GCC Runtime Library Exception, version
19    3.1, as published by the Free Software Foundation.
20 
21    You should have received a copy of the GNU General Public License and
22    a copy of the GCC Runtime Library Exception along with this program;
23    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24    <http://www.gnu.org/licenses/>.  */
25 
26 /* Run-time Target Specification.  */
27 
28 /* arm.h defaults to ARM6 CPU.  */
29 
30 /* Default EABI to armv5t so that thumb shared libraries work.
31    The ARM926EH-S core is the default for armv5te, so set
32    SUBTARGET_CPU_DEFAULT to achieve this.  */
33 
34 #define SUBTARGET_CPU_DEFAULT \
35 	(ARM_DEFAULT_ABI != ARM_ABI_APCS && ARM_DEFAULT_ABI != ARM_ABI_ATPCS \
36 	    ? TARGET_CPU_arm926ejs : TARGET_CPU_arm6)
37 
38 /* TARGET_BIG_ENDIAN_DEFAULT is set in
39    config.gcc for big endian configurations.  */
40 #if TARGET_BIG_ENDIAN_DEFAULT
41 #define TARGET_ENDIAN_DEFAULT    MASK_BIG_END
42 #else
43 #define TARGET_ENDIAN_DEFAULT    0
44 #endif
45 
46 #undef MULTILIB_DEFAULTS
47 
48 /* Default it to use ATPCS with soft-VFP.  */
49 #undef TARGET_DEFAULT
50 #define TARGET_DEFAULT			\
51   (MASK_APCS_FRAME			\
52    | TARGET_ENDIAN_DEFAULT)
53 
54 #undef ARM_DEFAULT_ABI
55 #define ARM_DEFAULT_ABI ARM_ABI_ATPCS
56 
57 #undef TARGET_OS_CPP_BUILTINS
58 #define TARGET_OS_CPP_BUILTINS()	\
59   do					\
60     {					\
61       NETBSD_OS_CPP_BUILTINS_ELF();	\
62     }					\
63   while (0)
64 
65 #undef SUBTARGET_CPP_SPEC
66 #define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
67 
68 #undef SUBTARGET_EXTRA_ASM_SPEC
69 #define SUBTARGET_EXTRA_ASM_SPEC	\
70   "-matpcs %{mabi=aapcs*:-meabi=5} %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
71 
72 /* Default to full VFP if -mfloat-abi=hard is specified.  */
73 #undef SUBTARGET_ASM_FLOAT_SPEC
74 #define SUBTARGET_ASM_FLOAT_SPEC	\
75   "%{mhard-float:%{!mfpu=*:-mfpu=vfp}}   \
76    %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfp}}"
77 
78 #define NETBSD_ENTRY_POINT "__start"
79 
80 #undef LINK_SPEC
81 #define LINK_SPEC \
82   "-X \
83    %{mbig-endian:-EB %{-mabi=aapcs*:-m armelfb_nbsd_eabi}} \
84    %{mlittle-endian:-EL %{-mabi=aapcs*:-m armelf_nbsd_eabi}} \
85    %(netbsd_link_spec)"
86 
87 /* Make GCC agree with <machine/ansi.h>.  */
88 
89 #undef SIZE_TYPE
90 #define SIZE_TYPE "long unsigned int"
91 
92 #undef PTRDIFF_TYPE
93 #define PTRDIFF_TYPE "long int"
94 
95 #undef INTPTR_TYPE
96 #define INTPTR_TYPE PTRDIFF_TYPE
97 
98 #undef UINTPTR_TYPE
99 #define UINTPTR_TYPE SIZE_TYPE
100 
101 /* We don't have any limit on the length as out debugger is GDB.  */
102 #undef DBX_CONTIN_LENGTH
103 
104 /* NetBSD does its profiling differently to the Acorn compiler. We
105    don't need a word following the mcount call; and to skip it
106    requires either an assembly stub or use of fomit-frame-pointer when
107    compiling the profiling functions.  Since we break Acorn CC
108    compatibility below a little more won't hurt.  */
109 
110 #undef ARM_FUNCTION_PROFILER
111 #define ARM_FUNCTION_PROFILER(STREAM,LABELNO)		\
112 {							\
113   asm_fprintf (STREAM, "\tmov\t%Rip, %Rlr\n");		\
114   asm_fprintf (STREAM, "\tbl\t__mcount%s\n",		\
115 	       (TARGET_ARM && NEED_PLT_RELOC)		\
116 	       ? "(PLT)" : "");				\
117 }
118 
119 /* VERY BIG NOTE: Change of structure alignment for NetBSD/arm.
120    There are consequences you should be aware of...
121 
122    Normally GCC/arm uses a structure alignment of 32 for compatibility
123    with armcc.  This means that structures are padded to a word
124    boundary.  However this causes problems with bugged NetBSD kernel
125    code (possibly userland code as well - I have not checked every
126    binary).  The nature of this bugged code is to rely on sizeof()
127    returning the correct size of various structures rounded to the
128    nearest byte (SCSI and ether code are two examples, the vm system
129    is another).  This code breaks when the structure alignment is 32
130    as sizeof() will report a word=rounded size.  By changing the
131    structure alignment to 8. GCC will conform to what is expected by
132    NetBSD.
133 
134    This has several side effects that should be considered.
135    1. Structures will only be aligned to the size of the largest member.
136       i.e. structures containing only bytes will be byte aligned.
137            structures containing shorts will be half word aligned.
138            structures containing ints will be word aligned.
139 
140       This means structures should be padded to a word boundary if
141       alignment of 32 is required for byte structures etc.
142 
143    2. A potential performance penalty may exist if strings are no longer
144       word aligned.  GCC will not be able to use word load/stores to copy
145       short strings.
146 
147    This modification is not encouraged but with the present state of the
148    NetBSD source tree it is currently the only solution that meets the
149    requirements.  */
150 
151 #undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
152 #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
153 
154 /* Clear the instruction cache from `BEG' to `END'.  This makes a
155    call to the ARM_SYNC_ICACHE architecture specific syscall.  */
156 #define CLEAR_INSN_CACHE(BEG, END)					\
157 do									\
158   {									\
159     extern int sysarch(int number, void *args);				\
160     struct								\
161       {									\
162 	unsigned int addr;						\
163 	int          len;						\
164       } s;								\
165     s.addr = (unsigned int)(BEG);					\
166     s.len = (END) - (BEG);						\
167     (void) sysarch (0, &s);						\
168   }									\
169 while (0)
170 
171 #undef FPUTYPE_DEFAULT
172 #define FPUTYPE_DEFAULT "vfp"
173 
174 /* Ensure that libgcc does not attempt to define __[CD]TOR_LIST__[] for APCS,
175    which belongs in crtbegin on NetBSD.  */
176 #ifndef __ARM_EABI__
177 #define CTOR_LISTS_DEFINED_EXTERNALLY
178 #endif
179