netbsd-elf.h revision 1.9
1/* Common configuration file for NetBSD ELF targets. 2 Copyright (C) 2002-2018 Free Software Foundation, Inc. 3 Contributed by Wasabi Systems, 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 3, 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 COPYING3. If not see 19<http://www.gnu.org/licenses/>. */ 20 21/* TARGET_OS_CPP_BUILTINS() common to all NetBSD ELF targets. */ 22#define NETBSD_OS_CPP_BUILTINS_ELF() \ 23 do \ 24 { \ 25 NETBSD_OS_CPP_BUILTINS_COMMON(); \ 26 } \ 27 while (0) 28 29/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF. Here we 30 provide support for the special GCC option -static. On ELF 31 targets, we also add the crtbegin.o file, which provides part 32 of the support for getting C++ file-scope static objects 33 constructed before entering "main". */ 34 35#define NETBSD_STARTFILE_SPEC \ 36 "%{!shared: \ 37 %{pg:gcrt0%O%s} \ 38 %{!pg: \ 39 %{p:gcrt0%O%s} \ 40 %{!p:crt0%O%s}}} \ 41 %:if-exists(crti%O%s) \ 42 %{pie:crtbeginS%O%s} \ 43 %{!pie: \ 44 %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \ 45 %{!static: \ 46 %{shared:crtbeginS%O%s} \ 47 %{!shared:crtbegin%O%s}}}" 48 49#undef STARTFILE_SPEC 50#define STARTFILE_SPEC NETBSD_STARTFILE_SPEC 51 52 53/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF. Here we 54 add crtend.o, which provides part of the support for getting 55 C++ file-scope static objects deconstructed after exiting "main". */ 56 57#define NETBSD_ENDFILE_SPEC \ 58 "%{pie:crtendS%O%s} \ 59 %{!pie: \ 60 %{shared:crtendS%O%s} \ 61 %{!shared:crtend%O%s}} \ 62 %:if-exists(crtn%O%s)" 63 64#undef ENDFILE_SPEC 65#define ENDFILE_SPEC NETBSD_ENDFILE_SPEC 66 67/* Provide a LINK_SPEC appropriate for NetBSD ELF. Here we provide 68 support for the special GCC options -assert, -R, -rpath, -shared, 69 -nostdlib, -static, -rdynamic, and -dynamic-linker. 70 71 Target-specific code can use this in conjunction with any other 72 target-specific LINK_SPEC options. 73 74 Target-specific code must provide the %(netbsd_entry_point) spec. */ 75 76#define NETBSD_LINK_LD_ELF_SO_SPEC \ 77 "%{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}" 78 79#define NETBSD_LINK_SPEC_ELF \ 80 "%{assert*} %{R*} %{rpath*} \ 81 %{shared:-shared} \ 82 %{symbolic:-Bsymbolic} \ 83 %{!shared: \ 84 -dc -dp \ 85 %{!nostdlib: \ 86 %{!r: \ 87 %{!e*:-e %(netbsd_entry_point)}}} \ 88 %{pie:-pie} \ 89 %{!static: \ 90 %{rdynamic:-export-dynamic} \ 91 %(netbsd_link_ld_elf_so)} \ 92 %{static:-static \ 93 %{pie:--no-dynamic-linker}}} \ 94 %{!shared:%{!nostdlib:%{!nodefaultlibs:\ 95 %{%:sanitize(address): -lasan } \ 96 %{%:sanitize(undefined): -lubsan}}}}" 97 98/* Provide the standard list of subtarget extra specs for NetBSD targets. */ 99#define NETBSD_SUBTARGET_EXTRA_SPECS \ 100 { "netbsd_link_ld_elf_so", NETBSD_LINK_LD_ELF_SO_SPEC }, \ 101 { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ 102 { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ 103 { "netbsd_entry_point", NETBSD_ENTRY_POINT }, \ 104 { "netbsd_endfile_spec", NETBSD_ENDFILE_SPEC }, 105 106#undef SUBTARGET_EXTRA_SPECS 107#define SUBTARGET_EXTRA_SPECS NETBSD_SUBTARGET_EXTRA_SPECS 108 109 110/* Use --as-needed -lgcc_s for eh support. */ 111#ifdef HAVE_LD_AS_NEEDED 112#define USE_LD_AS_NEEDED 1 113#endif 114 115#undef TARGET_UNWIND_TABLES_DEFAULT 116#define TARGET_UNWIND_TABLES_DEFAULT true 117 118#undef REAL_LIBGCC_SPEC 119#define REAL_LIBGCC_SPEC \ 120 "%{static|static-libgcc:-lgcc}" \ 121 "%{!static:%{!static-libgcc:--as-needed -lgcc_s --no-as-needed -lgcc}}" 122