10cdf705cSLionel Sambuc /* Definitions for ARM running MINIX using the ELF format 2b86af8beSLionel Sambuc Copyright (C) 2001, 2004, 2007 Free Software Foundation, Inc. 3b86af8beSLionel Sambuc Contributed by David E. O'Brien <obrien@FreeBSD.org> and BSDi. 40cdf705cSLionel Sambuc Adapted for MINIX by Lionel Sambuc <lionel@minix3.org> 5b86af8beSLionel Sambuc 6b86af8beSLionel Sambuc This file is part of GCC. 7b86af8beSLionel Sambuc 8b86af8beSLionel Sambuc GCC is free software; you can redistribute it and/or modify it 9b86af8beSLionel Sambuc under the terms of the GNU General Public License as published 10b86af8beSLionel Sambuc by the Free Software Foundation; either version 3, or (at your 11b86af8beSLionel Sambuc option) any later version. 12b86af8beSLionel Sambuc 13b86af8beSLionel Sambuc GCC is distributed in the hope that it will be useful, but WITHOUT 14b86af8beSLionel Sambuc ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15b86af8beSLionel Sambuc or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 16b86af8beSLionel Sambuc License for more details. 17b86af8beSLionel Sambuc 18b86af8beSLionel Sambuc You should have received a copy of the GNU General Public License 19b86af8beSLionel Sambuc along with GCC; see the file COPYING3. If not see 20b86af8beSLionel Sambuc <http://www.gnu.org/licenses/>. */ 21b86af8beSLionel Sambuc 22b86af8beSLionel Sambuc #undef MINIX_TARGET_CPU_CPP_BUILTINS 23b86af8beSLionel Sambuc #define MINIX_TARGET_CPU_CPP_BUILTINS() \ 24b86af8beSLionel Sambuc do \ 25b86af8beSLionel Sambuc { \ 26b86af8beSLionel Sambuc TARGET_BPABI_CPP_BUILTINS(); \ 2784d9c625SLionel Sambuc if (ARM_EABI_UNWIND_TABLES) \ 2884d9c625SLionel Sambuc builtin_define ("__UNWIND_TABLES__"); \ 29b86af8beSLionel Sambuc } \ 30b86af8beSLionel Sambuc while (0) 31b86af8beSLionel Sambuc 32b86af8beSLionel Sambuc /* Define the actual types of some ANSI-mandated types. 33b86af8beSLionel Sambuc Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c, 34b86af8beSLionel Sambuc c-common.c, and config/<arch>/<arch>.h. */ 35b86af8beSLionel Sambuc #undef SIZE_TYPE 36b86af8beSLionel Sambuc #define SIZE_TYPE "unsigned int" 37b86af8beSLionel Sambuc 38b86af8beSLionel Sambuc #undef PTRDIFF_TYPE 39b86af8beSLionel Sambuc #define PTRDIFF_TYPE "int" 40b86af8beSLionel Sambuc 41b86af8beSLionel Sambuc #undef WCHAR_TYPE 42b86af8beSLionel Sambuc #define WCHAR_TYPE "int" 43b86af8beSLionel Sambuc 4484d9c625SLionel Sambuc #undef WINT_TYPE 4584d9c625SLionel Sambuc #define WINT_TYPE "int" 4684d9c625SLionel Sambuc 4784d9c625SLionel Sambuc /* We don't have any limit on the length as out debugger is GDB. */ 4884d9c625SLionel Sambuc #undef DBX_CONTIN_LENGTH 4984d9c625SLionel Sambuc 5084d9c625SLionel Sambuc /* NetBSD does its profiling differently to the Acorn compiler. We 5184d9c625SLionel Sambuc don't need a word following the mcount call; and to skip it 5284d9c625SLionel Sambuc requires either an assembly stub or use of fomit-frame-pointer when 5384d9c625SLionel Sambuc compiling the profiling functions. Since we break Acorn CC 5484d9c625SLionel Sambuc compatibility below a little more won't hurt. */ 5584d9c625SLionel Sambuc 5684d9c625SLionel Sambuc #undef ARM_FUNCTION_PROFILER 5784d9c625SLionel Sambuc #define ARM_FUNCTION_PROFILER(STREAM,LABELNO) \ 5884d9c625SLionel Sambuc { \ 5984d9c625SLionel Sambuc asm_fprintf (STREAM, "\tmov\t%Rip, %Rlr\n"); \ 6084d9c625SLionel Sambuc asm_fprintf (STREAM, "\tbl\t__mcount%s\n", \ 6184d9c625SLionel Sambuc (TARGET_ARM && NEED_PLT_RELOC) \ 6284d9c625SLionel Sambuc ? "(PLT)" : ""); \ 6384d9c625SLionel Sambuc } 6484d9c625SLionel Sambuc 650cdf705cSLionel Sambuc /* VERY BIG NOTE: Change of structure alignment for NetBSD/arm. 660cdf705cSLionel Sambuc There are consequences you should be aware of... 670cdf705cSLionel Sambuc 680cdf705cSLionel Sambuc Normally GCC/arm uses a structure alignment of 32 for compatibility 690cdf705cSLionel Sambuc with armcc. This means that structures are padded to a word 700cdf705cSLionel Sambuc boundary. However this causes problems with bugged NetBSD kernel 710cdf705cSLionel Sambuc code (possibly userland code as well - I have not checked every 720cdf705cSLionel Sambuc binary). The nature of this bugged code is to rely on sizeof() 730cdf705cSLionel Sambuc returning the correct size of various structures rounded to the 740cdf705cSLionel Sambuc nearest byte (SCSI and ether code are two examples, the vm system 750cdf705cSLionel Sambuc is another). This code breaks when the structure alignment is 32 760cdf705cSLionel Sambuc as sizeof() will report a word=rounded size. By changing the 770cdf705cSLionel Sambuc structure alignment to 8. GCC will conform to what is expected by 780cdf705cSLionel Sambuc NetBSD. 790cdf705cSLionel Sambuc 800cdf705cSLionel Sambuc This has several side effects that should be considered. 810cdf705cSLionel Sambuc 1. Structures will only be aligned to the size of the largest member. 820cdf705cSLionel Sambuc i.e. structures containing only bytes will be byte aligned. 830cdf705cSLionel Sambuc structures containing shorts will be half word aligned. 840cdf705cSLionel Sambuc structures containing ints will be word aligned. 850cdf705cSLionel Sambuc 860cdf705cSLionel Sambuc This means structures should be padded to a word boundary if 870cdf705cSLionel Sambuc alignment of 32 is required for byte structures etc. 880cdf705cSLionel Sambuc 890cdf705cSLionel Sambuc 2. A potential performance penalty may exist if strings are no longer 900cdf705cSLionel Sambuc word aligned. GCC will not be able to use word load/stores to copy 910cdf705cSLionel Sambuc short strings. 920cdf705cSLionel Sambuc 930cdf705cSLionel Sambuc This modification is not encouraged but with the present state of the 940cdf705cSLionel Sambuc NetBSD source tree it is currently the only solution that meets the 950cdf705cSLionel Sambuc requirements. */ 960cdf705cSLionel Sambuc 970cdf705cSLionel Sambuc #undef DEFAULT_STRUCTURE_SIZE_BOUNDARY 980cdf705cSLionel Sambuc #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8 990cdf705cSLionel Sambuc 1000cdf705cSLionel Sambuc /* Fixed-sized enum by default (-fno-short-enums) */ 1010cdf705cSLionel Sambuc #undef MINIX_CC1_SPEC 1020cdf705cSLionel Sambuc #define MINIX_CC1_SPEC "%{!fshort-enums:%{!fno-short-enums:-fno-short-enums}} " 103b86af8beSLionel Sambuc 104b86af8beSLionel Sambuc /* Use by default the new abi and calling standard */ 105b86af8beSLionel Sambuc #undef ARM_DEFAULT_ABI 106b86af8beSLionel Sambuc #define ARM_DEFAULT_ABI ARM_ABI_AAPCS 107b86af8beSLionel Sambuc 1080a6a1f1dSLionel Sambuc #undef ARM_EABI_UNWIND_TABLES 1090a6a1f1dSLionel Sambuc #define ARM_EABI_UNWIND_TABLES 0 1100a6a1f1dSLionel Sambuc #undef ARM_UNWIND_INFO 1110a6a1f1dSLionel Sambuc #define ARM_UNWIND_INFO 0 1120a6a1f1dSLionel Sambuc #undef ARM_DWARF_UNWIND_TABLES 1130a6a1f1dSLionel Sambuc #define ARM_DWARF_UNWIND_TABLES 1 1140a6a1f1dSLionel Sambuc 1150cdf705cSLionel Sambuc /* LSC: FIXME: When activated, some programs crash on qemu with an illegal 1160cdf705cSLionel Sambuc * instruction. 1170cdf705cSLionel Sambuc * The cause is unknown (Missing support on MINIX, missing support 1180cdf705cSLionel Sambuc * on the emulator, library error...). 1190cdf705cSLionel Sambuc */ 1200cdf705cSLionel Sambuc #if 0 1210cdf705cSLionel Sambuc /* Make sure we use hard-floating point ABI by default */ 1220cdf705cSLionel Sambuc #undef TARGET_DEFAULT_FLOAT_ABI 1230cdf705cSLionel Sambuc #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD 124b86af8beSLionel Sambuc #endif 125b86af8beSLionel Sambuc 12684d9c625SLionel Sambuc #if defined(NETBSD_NATIVE) 12784d9c625SLionel Sambuc /* LSC: On arm, when compiling statically, we need gcc_eh. */ 12884d9c625SLionel Sambuc #undef MINIX_LINK_GCC_C_SEQUENCE_SPEC 12984d9c625SLionel Sambuc #define MINIX_LINK_GCC_C_SEQUENCE_SPEC \ 13084d9c625SLionel Sambuc "%{static:--start-group} %G %L -lgcc_eh %{static:--end-group}%{!static:%G}" 13184d9c625SLionel Sambuc #endif /* defined(NETBSD_NATIVE) */ 13284d9c625SLionel Sambuc 1330cdf705cSLionel Sambuc /* Default to full VFP if -mhard-float is specified. */ 1340cdf705cSLionel Sambuc #undef MINIX_SUBTARGET_ASM_FLOAT_SPEC 1350cdf705cSLionel Sambuc #define MINIX_SUBTARGET_ASM_FLOAT_SPEC \ 136*03de4d97SMark Pauley "%{mhard-float:%{!mfpu=*:-mfpu=vfpv3-d16}} \ 137*03de4d97SMark Pauley %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfpv3-d16}}" 1380cdf705cSLionel Sambuc 1390cdf705cSLionel Sambuc #undef MINIX_SUBTARGET_EXTRA_ASM_SPEC 1400cdf705cSLionel Sambuc #define MINIX_SUBTARGET_EXTRA_ASM_SPEC \ 1410cdf705cSLionel Sambuc "%{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu;:-meabi=5}" \ 1420cdf705cSLionel Sambuc TARGET_FIX_V4BX_SPEC \ 1430cdf705cSLionel Sambuc "%{fpic|fpie:-k} %{fPIC|fPIE:-k}" 1440cdf705cSLionel Sambuc 1450cdf705cSLionel Sambuc /* Little endian by default */ 1460cdf705cSLionel Sambuc #undef TARGET_ENDIAN_DEFAULT 1470cdf705cSLionel Sambuc #define TARGET_ENDIAN_DEFAULT 0 1480cdf705cSLionel Sambuc 149b86af8beSLionel Sambuc #undef SUBTARGET_CPU_DEFAULT 150b86af8beSLionel Sambuc #define SUBTARGET_CPU_DEFAULT TARGET_CPU_cortexa8 151