netbsd-elf.h revision 117395
1117395Skan/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version.
2117395Skan   Copyright (C) 2002 Free Software Foundation, Inc.
3117395Skan   Contributed by Wasabi Systems, Inc.
4117395Skan
5117395SkanThis file is part of GNU CC.
6117395Skan
7117395SkanGNU CC is free software; you can redistribute it and/or modify
8117395Skanit under the terms of the GNU General Public License as published by
9117395Skanthe Free Software Foundation; either version 2, or (at your option)
10117395Skanany later version.
11117395Skan
12117395SkanGNU CC is distributed in the hope that it will be useful,
13117395Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of
14117395SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15117395SkanGNU General Public License for more details.
16117395Skan
17117395SkanYou should have received a copy of the GNU General Public License
18117395Skanalong with GNU CC; see the file COPYING.  If not, write to
19117395Skanthe Free Software Foundation, 59 Temple Place - Suite 330,
20117395SkanBoston, MA 02111-1307, USA.  */
21117395Skan
22117395Skan/* Run-time Target Specification.  */
23117395Skan#undef TARGET_VERSION
24117395Skan#define TARGET_VERSION fputs (" (NetBSD/arm ELF)", stderr);
25117395Skan
26117395Skan/* This is used in ASM_FILE_START.  */
27117395Skan#undef ARM_OS_NAME
28117395Skan#define ARM_OS_NAME "NetBSD"
29117395Skan
30117395Skan/* arm.h defaults to ARM6 CPU.  */
31117395Skan
32117395Skan/* This defaults us to little-endian.  */
33117395Skan#ifndef TARGET_ENDIAN_DEFAULT
34117395Skan#define TARGET_ENDIAN_DEFAULT 0
35117395Skan#endif
36117395Skan
37117395Skan#undef MULTILIB_DEFAULTS
38117395Skan
39117395Skan/* Default it to use ATPCS with soft-VFP.  */
40117395Skan#undef TARGET_DEFAULT
41117395Skan#define TARGET_DEFAULT			\
42117395Skan  (ARM_FLAG_APCS_32			\
43117395Skan   | ARM_FLAG_SOFT_FLOAT		\
44117395Skan   | ARM_FLAG_APCS_FRAME		\
45117395Skan   | ARM_FLAG_ATPCS			\
46117395Skan   | ARM_FLAG_VFP			\
47117395Skan   | ARM_FLAG_MMU_TRAPS			\
48117395Skan   | TARGET_ENDIAN_DEFAULT)
49117395Skan
50117395Skan#define TARGET_OS_CPP_BUILTINS()	\
51117395Skan  do					\
52117395Skan    {					\
53117395Skan      NETBSD_OS_CPP_BUILTINS_ELF();	\
54117395Skan    }					\
55117395Skan  while (0)
56117395Skan
57117395Skan#undef SUBTARGET_CPP_SPEC
58117395Skan#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC
59117395Skan
60117395Skan#undef SUBTARGET_EXTRA_ASM_SPEC
61117395Skan#define SUBTARGET_EXTRA_ASM_SPEC	\
62117395Skan  "-matpcs %{fpic:-k} %{fPIC:-k}"
63117395Skan
64117395Skan/* Default floating point model is soft-VFP.
65117395Skan   FIXME: -mhard-float currently implies FPA.  */
66117395Skan#undef SUBTARGET_ASM_FLOAT_SPEC
67117395Skan#define SUBTARGET_ASM_FLOAT_SPEC	\
68117395Skan  "%{mhard-float:-mfpu=fpa} \
69117395Skan   %{msoft-float:-mfpu=softvfp} \
70117395Skan   %{!mhard-float: \
71117395Skan     %{!msoft-float:-mfpu=softvfp}}"
72117395Skan
73117395Skan#undef SUBTARGET_EXTRA_SPECS
74117395Skan#define SUBTARGET_EXTRA_SPECS				\
75117395Skan  { "subtarget_extra_asm_spec",	SUBTARGET_EXTRA_ASM_SPEC }, \
76117395Skan  { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, \
77117395Skan  { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF },	\
78117395Skan  { "netbsd_entry_point",	NETBSD_ENTRY_POINT },
79117395Skan
80117395Skan#define NETBSD_ENTRY_POINT "__start"
81117395Skan
82117395Skan#undef LINK_SPEC
83117395Skan#define LINK_SPEC \
84117395Skan  "-X %{mbig-endian:-EB} %{mlittle-endian:-EL} \
85117395Skan   %(netbsd_link_spec)"
86117395Skan
87117395Skan/* Make GCC agree with <machine/ansi.h>.  */
88117395Skan
89117395Skan#undef SIZE_TYPE
90117395Skan#define SIZE_TYPE "long unsigned int"
91117395Skan
92117395Skan#undef PTRDIFF_TYPE
93117395Skan#define PTRDIFF_TYPE "long int"
94117395Skan
95117395Skan/* We don't have any limit on the length as out debugger is GDB.  */
96117395Skan#undef DBX_CONTIN_LENGTH
97117395Skan
98117395Skan/* NetBSD does its profiling differently to the Acorn compiler. We
99117395Skan   don't need a word following the mcount call; and to skip it
100117395Skan   requires either an assembly stub or use of fomit-frame-pointer when
101117395Skan   compiling the profiling functions.  Since we break Acorn CC
102117395Skan   compatibility below a little more won't hurt.  */
103117395Skan
104117395Skan#undef ARM_FUNCTION_PROFILER
105117395Skan#define ARM_FUNCTION_PROFILER(STREAM,LABELNO)		\
106117395Skan{							\
107117395Skan  asm_fprintf (STREAM, "\tmov\t%Rip, %Rlr\n");		\
108117395Skan  asm_fprintf (STREAM, "\tbl\t__mcount%s\n",		\
109117395Skan	       NEED_PLT_RELOC ? "(PLT)" : "");		\
110117395Skan}
111117395Skan
112117395Skan/* VERY BIG NOTE: Change of structure alignment for NetBSD/arm.
113117395Skan   There are consequences you should be aware of...
114117395Skan
115117395Skan   Normally GCC/arm uses a structure alignment of 32 for compatibility
116117395Skan   with armcc.  This means that structures are padded to a word
117117395Skan   boundary.  However this causes problems with bugged NetBSD kernel
118117395Skan   code (possibly userland code as well - I have not checked every
119117395Skan   binary).  The nature of this bugged code is to rely on sizeof()
120117395Skan   returning the correct size of various structures rounded to the
121117395Skan   nearest byte (SCSI and ether code are two examples, the vm system
122117395Skan   is another).  This code breaks when the structure alignment is 32
123117395Skan   as sizeof() will report a word=rounded size.  By changing the
124117395Skan   structure alignment to 8. GCC will conform to what is expected by
125117395Skan   NetBSD.
126117395Skan
127117395Skan   This has several side effects that should be considered.
128117395Skan   1. Structures will only be aligned to the size of the largest member.
129117395Skan      i.e. structures containing only bytes will be byte aligned.
130117395Skan           structures containing shorts will be half word alinged.
131117395Skan           structures containing ints will be word aligned.
132117395Skan
133117395Skan      This means structures should be padded to a word boundary if
134117395Skan      alignment of 32 is required for byte structures etc.
135117395Skan
136117395Skan   2. A potential performance penalty may exist if strings are no longer
137117395Skan      word aligned.  GCC will not be able to use word load/stores to copy
138117395Skan      short strings.
139117395Skan
140117395Skan   This modification is not encouraged but with the present state of the
141117395Skan   NetBSD source tree it is currently the only solution that meets the
142117395Skan   requirements.  */
143117395Skan
144117395Skan#undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
145117395Skan#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
146117395Skan
147117395Skan/* Emit code to set up a trampoline and synchronize the caches.  */
148117395Skan#undef INITIALIZE_TRAMPOLINE
149117395Skan#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
150117395Skando									\
151117395Skan  {									\
152117395Skan    emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 8)),	\
153117395Skan		    (CXT));						\
154117395Skan    emit_move_insn (gen_rtx (MEM, SImode, plus_constant ((TRAMP), 12)),	\
155117395Skan		    (FNADDR));						\
156117395Skan    emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),	\
157117395Skan		       0, VOIDmode, 2, TRAMP, Pmode,			\
158117395Skan		       plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);	\
159117395Skan  }									\
160117395Skanwhile (0)
161117395Skan
162117395Skan/* Clear the instruction cache from `BEG' to `END'.  This makes a
163117395Skan   call to the ARM_SYNC_ICACHE architecture specific syscall.  */
164117395Skan#define CLEAR_INSN_CACHE(BEG, END)					\
165117395Skando									\
166117395Skan  {									\
167117395Skan    extern int sysarch(int number, void *args);				\
168117395Skan    struct								\
169117395Skan      {									\
170117395Skan	unsigned int addr;						\
171117395Skan	int          len;						\
172117395Skan      } s;								\
173117395Skan    s.addr = (unsigned int)(BEG);					\
174117395Skan    s.len = (END) - (BEG);						\
175117395Skan    (void) sysarch (0, &s);						\
176117395Skan  }									\
177117395Skanwhile (0)
178