196263Sobrien/* NetBSD/arm a.out version. 2169689Skan Copyright (C) 1993, 1994, 1997, 1998, 2003, 2004, 2005 3169689Skan Free Software Foundation, Inc. 490075Sobrien Contributed by Mark Brinicombe (amb@physig.ph.kcl.ac.uk) 590075Sobrien 6132718Skan This file is part of GCC. 790075Sobrien 8132718Skan GCC is free software; you can redistribute it and/or modify it 9132718Skan under the terms of the GNU General Public License as published 10132718Skan by the Free Software Foundation; either version 2, or (at your 11132718Skan option) any later version. 1290075Sobrien 13132718Skan GCC is distributed in the hope that it will be useful, but WITHOUT 14132718Skan ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15132718Skan or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 16132718Skan License for more details. 1790075Sobrien 18132718Skan You should have received a copy of the GNU General Public License 19132718Skan along with GCC; see the file COPYING. If not, write to 20169689Skan the Free Software Foundation, 51 Franklin Street, Fifth Floor, 21169689Skan Boston, MA 02110-1301, USA. */ 2290075Sobrien 2390075Sobrien/* Run-time Target Specification. */ 2490075Sobrien#undef TARGET_VERSION 2590075Sobrien#define TARGET_VERSION fputs (" (ARM/NetBSD)", stderr); 2690075Sobrien 2790075Sobrien/* Unsigned chars produces much better code than signed. */ 2890075Sobrien#define DEFAULT_SIGNED_CHAR 0 2990075Sobrien 3090075Sobrien/* Since we always use GAS as our assembler we support stabs. */ 3190075Sobrien#define DBX_DEBUGGING_INFO 1 3290075Sobrien 3390075Sobrien/*#undef ASM_DECLARE_FUNCTION_NAME*/ 3490075Sobrien 3590075Sobrien/* ARM6 family default cpu. */ 3690075Sobrien#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm6 3790075Sobrien 3890075Sobrien#undef TARGET_DEFAULT 39169689Skan#define TARGET_DEFAULT (MASK_APCS_FRAME) 4090075Sobrien 4190075Sobrien/* Some defines for CPP. 4290075Sobrien arm32 is the NetBSD port name, so we always define arm32 and __arm32__. */ 43117395Skan#define TARGET_OS_CPP_BUILTINS() \ 44117395Skan do { \ 45117395Skan NETBSD_OS_CPP_BUILTINS_AOUT(); \ 46117395Skan builtin_define_std ("arm32"); \ 47117395Skan builtin_define_std ("unix"); \ 48117395Skan builtin_define_std ("riscbsd"); \ 49117395Skan } while (0) 5090075Sobrien 51117395Skan#undef SUBTARGET_EXTRA_SPECS 52117395Skan#define SUBTARGET_EXTRA_SPECS \ 53117395Skan { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ 54117395Skan { "netbsd_link_spec", NETBSD_LINK_SPEC_AOUT }, 55117395Skan 5690075Sobrien#undef CPP_SPEC 5790075Sobrien#define CPP_SPEC "\ 58169689Skan%(cpp_cpu_arch) %(cpp_float) %(cpp_endian) %(netbsd_cpp_spec) \ 5990075Sobrien" 6090075Sobrien 61169689Skan/* Because TARGET_DEFAULT sets MASK_SOFT_FLOAT */ 6290075Sobrien#undef CPP_FLOAT_DEFAULT_SPEC 6390075Sobrien#define CPP_FLOAT_DEFAULT_SPEC "-D__SOFTFP__" 6490075Sobrien 6590075Sobrien/* Pass -X to the linker so that it will strip symbols starting with 'L' */ 6690075Sobrien#undef LINK_SPEC 67117395Skan#define LINK_SPEC "-X %(netbsd_link_spec)" 6890075Sobrien 6990075Sobrien#undef SIZE_TYPE 7090075Sobrien#define SIZE_TYPE "unsigned int" 7190075Sobrien 7290075Sobrien#undef PTRDIFF_TYPE 7390075Sobrien#define PTRDIFF_TYPE "int" 7490075Sobrien 75117395Skan#define HANDLE_SYSV_PRAGMA 1 7690075Sobrien 7790075Sobrien/* We don't have any limit on the length as out debugger is GDB. */ 7890075Sobrien#undef DBX_CONTIN_LENGTH 7990075Sobrien 8090075Sobrien/* NetBSD does its profiling differently to the Acorn compiler. We 8190075Sobrien don't need a word following the mcount call; and to skip it 8290075Sobrien requires either an assembly stub or use of fomit-frame-pointer when 8390075Sobrien compiling the profiling functions. Since we break Acorn CC 8490075Sobrien compatibility below a little more won't hurt. */ 8590075Sobrien 8690075Sobrien#undef ARM_FUNCTION_PROFILER 8790075Sobrien#define ARM_FUNCTION_PROFILER(STREAM,LABELNO) \ 8890075Sobrien{ \ 8990075Sobrien fprintf(STREAM, "\tmov\t%sip, %slr\n", REGISTER_PREFIX, REGISTER_PREFIX); \ 9090075Sobrien fprintf(STREAM, "\tbl\tmcount\n"); \ 9190075Sobrien} 9290075Sobrien 9390075Sobrien/* On the ARM `@' introduces a comment, so we must use something else 9490075Sobrien for .type directives. */ 9590075Sobrien#undef TYPE_OPERAND_FMT 9690075Sobrien#define TYPE_OPERAND_FMT "%%%s" 9790075Sobrien 98132718Skan/* NetBSD uses the old PCC style aggregate returning conventions. */ 9990075Sobrien#undef DEFAULT_PCC_STRUCT_RETURN 10090075Sobrien#define DEFAULT_PCC_STRUCT_RETURN 1 10190075Sobrien 10290075Sobrien/* Although not normally relevant (since by default, all aggregates 10390075Sobrien are returned in memory) compiling some parts of libc requires 10490075Sobrien non-APCS style struct returns. */ 10590075Sobrien#undef RETURN_IN_MEMORY 10690075Sobrien 10790075Sobrien/* VERY BIG NOTE : Change of structure alignment for RiscBSD. 10890075Sobrien There are consequences you should be aware of... 10990075Sobrien 11090075Sobrien Normally GCC/arm uses a structure alignment of 32 for compatibility 11190075Sobrien with armcc. This means that structures are padded to a word 11290075Sobrien boundary. However this causes problems with bugged NetBSD kernel 11390075Sobrien code (possibly userland code as well - I have not checked every 11490075Sobrien binary). The nature of this bugged code is to rely on sizeof() 11590075Sobrien returning the correct size of various structures rounded to the 11690075Sobrien nearest byte (SCSI and ether code are two examples, the vm system 11790075Sobrien is another). This code breaks when the structure alignment is 32 11890075Sobrien as sizeof() will report a word=rounded size. By changing the 11990075Sobrien structure alignment to 8. GCC will conform to what is expected by 12090075Sobrien NetBSD. 12190075Sobrien 12290075Sobrien This has several side effects that should be considered. 12390075Sobrien 1. Structures will only be aligned to the size of the largest member. 12490075Sobrien i.e. structures containing only bytes will be byte aligned. 125132718Skan structures containing shorts will be half word aligned. 12690075Sobrien structures containing ints will be word aligned. 12790075Sobrien 12890075Sobrien This means structures should be padded to a word boundary if 12990075Sobrien alignment of 32 is required for byte structures etc. 13090075Sobrien 13190075Sobrien 2. A potential performance penalty may exist if strings are no longer 13290075Sobrien word aligned. GCC will not be able to use word load/stores to copy 13390075Sobrien short strings. 13490075Sobrien 13590075Sobrien This modification is not encouraged but with the present state of the 13690075Sobrien NetBSD source tree it is currently the only solution that meets the 13790075Sobrien requirements. */ 13890075Sobrien#undef DEFAULT_STRUCTURE_SIZE_BOUNDARY 13990075Sobrien#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8 140117395Skan 141117395Skan/* Clear the instruction cache from `BEG' to `END'. This makes a 142117395Skan call to the ARM32_SYNC_ICACHE architecture specific syscall. */ 143117395Skan#define CLEAR_INSN_CACHE(BEG, END) \ 144117395Skan{ \ 145117395Skan extern int sysarch(int number, void *args); \ 146117395Skan struct { \ 147117395Skan unsigned int addr; \ 148117395Skan int len; \ 149117395Skan } s; \ 150117395Skan s.addr = (unsigned int)(BEG); \ 151117395Skan s.len = (END) - (BEG); \ 152117395Skan (void)sysarch(0, &s); \ 153117395Skan} 154