1/* Base configuration file for all NetBSD targets. 2 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 3 Free Software Foundation, Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GCC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING. If not, write to 19the Free Software Foundation, 51 Franklin Street, Fifth Floor, 20Boston, MA 02110-1301, USA. */ 21 22/* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets. */ 23#define NETBSD_OS_CPP_BUILTINS_COMMON() \ 24 do \ 25 { \ 26 builtin_define ("__NetBSD__"); \ 27 builtin_define ("__unix__"); \ 28 builtin_assert ("system=bsd"); \ 29 builtin_assert ("system=unix"); \ 30 builtin_assert ("system=NetBSD"); \ 31 } \ 32 while (0) 33 34/* CPP_SPEC parts common to all NetBSD targets. */ 35#define NETBSD_CPP_SPEC \ 36 "%{posix:-D_POSIX_SOURCE} \ 37 %{pthread:-D_REENTRANT -D_PTHREADS}" 38 39/* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD 40 source tree so it can be configured appropriately without using 41 the GNU configure/build mechanism. */ 42 43#ifdef NETBSD_NATIVE 44 45/* Look for the include files in the system-defined places. */ 46 47#undef GPLUSPLUS_INCLUDE_DIR 48#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++" 49 50#undef GCC_INCLUDE_DIR 51#define GCC_INCLUDE_DIR "/usr/include" 52 53#undef INCLUDE_DEFAULTS 54#define INCLUDE_DEFAULTS \ 55 { \ 56 { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \ 57 { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \ 58 { 0, 0, 0, 0 } \ 59 } 60 61/* Under NetBSD, the normal location of the compiler back ends is the 62 /usr/libexec directory. */ 63 64#undef STANDARD_EXEC_PREFIX 65#define STANDARD_EXEC_PREFIX "/usr/libexec/" 66 67/* Under NetBSD, the normal location of the various *crt*.o files is the 68 /usr/lib directory. */ 69 70#undef STANDARD_STARTFILE_PREFIX 71#define STANDARD_STARTFILE_PREFIX "/usr/lib/" 72 73#endif /* NETBSD_NATIVE */ 74 75 76/* Provide a LIB_SPEC appropriate for NetBSD. Here we: 77 78 1. Select the appropriate set of libs, depending on whether we're 79 profiling. 80 81 2. Include the pthread library if -pthread is specified (only 82 if threads are enabled). 83 84 3. Include the posix library if -posix is specified. 85 86 FIXME: Could eliminate the duplication here if we were allowed to 87 use string concatenation. */ 88 89#ifdef NETBSD_ENABLE_PTHREADS 90#define NETBSD_LIB_SPEC \ 91 "%{pthread: \ 92 %{!p: \ 93 %{!pg:-lpthread}} \ 94 %{p:-lpthread_p} \ 95 %{pg:-lpthread_p}} \ 96 %{posix: \ 97 %{!p: \ 98 %{!pg:-lposix}} \ 99 %{p:-lposix_p} \ 100 %{pg:-lposix_p}} \ 101 %{!shared: \ 102 %{!symbolic: \ 103 %{!p: \ 104 %{!pg:-lc}} \ 105 %{p:-lc_p} \ 106 %{pg:-lc_p}}}" 107#else 108#define NETBSD_LIB_SPEC \ 109 "%{posix: \ 110 %{!p: \ 111 %{!pg:-lposix}} \ 112 %{p:-lposix_p} \ 113 %{pg:-lposix_p}} \ 114 %{!shared: \ 115 %{!symbolic: \ 116 %{!p: \ 117 %{!pg:-lc}} \ 118 %{p:-lc_p} \ 119 %{pg:-lc_p}}}" 120#endif 121 122#undef LIB_SPEC 123#define LIB_SPEC NETBSD_LIB_SPEC 124 125/* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude 126 libgcc with -symbolic. */ 127 128#ifdef NETBSD_NATIVE 129#define NETBSD_LIBGCC_SPEC \ 130 "%{!symbolic: \ 131 %{!shared: \ 132 %{!p: \ 133 %{!pg: -lgcc}}} \ 134 %{shared: -lgcc_pic} \ 135 %{p: -lgcc_p} \ 136 %{pg: -lgcc_p}}" 137#else 138#define NETBSD_LIBGCC_SPEC "%{!shared:%{!symbolic: -lgcc}}" 139#endif 140 141#undef LIBGCC_SPEC 142#define LIBGCC_SPEC NETBSD_LIBGCC_SPEC 143 144/* When building shared libraries, the initialization and finalization 145 functions for the library are .init and .fini respectively. */ 146 147#define COLLECT_SHARED_INIT_FUNC(STREAM,FUNC) \ 148 do { \ 149 fprintf ((STREAM), "void __init() __asm__ (\".init\");"); \ 150 fprintf ((STREAM), "void __init() {\n\t%s();\n}\n", (FUNC)); \ 151 } while (0) 152 153#define COLLECT_SHARED_FINI_FUNC(STREAM,FUNC) \ 154 do { \ 155 fprintf ((STREAM), "void __fini() __asm__ (\".fini\");"); \ 156 fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC)); \ 157 } while (0) 158 159#undef TARGET_POSIX_IO 160#define TARGET_POSIX_IO 161 162/* Handle #pragma weak and #pragma pack. */ 163 164#define HANDLE_SYSV_PRAGMA 1 165 166/* Don't assume anything about the header files. */ 167#undef NO_IMPLICIT_EXTERN_C 168#define NO_IMPLICIT_EXTERN_C 1 169 170/* Define some types that are the same on all NetBSD platforms, 171 making them agree with <machine/ansi.h>. */ 172 173#undef WCHAR_TYPE 174#define WCHAR_TYPE "int" 175 176#undef WCHAR_TYPE_SIZE 177#define WCHAR_TYPE_SIZE 32 178 179#undef WINT_TYPE 180#define WINT_TYPE "int" 181 182 183/* Attempt to turn on execute permission for the stack. This may be 184 used by INITIALIZE_TRAMPOLINE of the target needs it (that is, 185 if the target machine can change execute permissions on a page). 186 187 There is no way to query the execute permission of the stack, so 188 we always issue the mprotect() call. 189 190 Note that we go out of our way to use namespace-non-invasive calls 191 here. Unfortunately, there is no libc-internal name for mprotect(). 192 193 Also note that no errors should be emitted by this code; it is considered 194 dangerous for library calls to send messages to stdout/stderr. */ 195 196#define NETBSD_ENABLE_EXECUTE_STACK \ 197extern void __enable_execute_stack (void *); \ 198void \ 199__enable_execute_stack (void *addr) \ 200{ \ 201 extern int mprotect (void *, size_t, int); \ 202 extern int __sysctl (int *, unsigned int, void *, size_t *, \ 203 void *, size_t); \ 204 \ 205 static int size; \ 206 static long mask; \ 207 \ 208 char *page, *end; \ 209 \ 210 if (size == 0) \ 211 { \ 212 int mib[2]; \ 213 size_t len; \ 214 \ 215 mib[0] = 6; /* CTL_HW */ \ 216 mib[1] = 7; /* HW_PAGESIZE */ \ 217 len = sizeof (size); \ 218 (void) __sysctl (mib, 2, &size, &len, NULL, 0); \ 219 mask = ~((long) size - 1); \ 220 } \ 221 \ 222 page = (char *) (((long) addr) & mask); \ 223 end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ 224 \ 225 /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ 226 (void) mprotect (page, end - page, 7); \ 227} 228