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