1 /* Common configuration file for NetBSD a.out targets. 2 Copyright (C) 2002 Free Software Foundation, Inc. 3 Contributed by Wasabi Systems, Inc. 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. 11 12 GCC is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING. If not, write to 19 the Free Software Foundation, 51 Franklin Street, Fifth Floor, 20 Boston, MA 02110-1301, USA. */ 21 22 /* TARGET_OS_CPP_BUILTINS() common to all NetBSD a.out targets. */ 23 #define NETBSD_OS_CPP_BUILTINS_AOUT() \ 24 do \ 25 { \ 26 NETBSD_OS_CPP_BUILTINS_COMMON(); \ 27 } \ 28 while (0) 29 30 /* This defines which switch letters take arguments. */ 31 32 #undef SWITCH_TAKES_ARG 33 #define SWITCH_TAKES_ARG(CHAR) \ 34 (DEFAULT_SWITCH_TAKES_ARG(CHAR) \ 35 || (CHAR) == 'R') 36 37 38 /* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal 39 with the options for generating PIC code. */ 40 41 #undef ASM_SPEC 42 #define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" 43 44 #define AS_NEEDS_DASH_FOR_PIPED_INPUT 45 46 47 /* Provide a STARTFILE_SPEC appropriate for NetBSD a.out. Here we 48 provide support for the special GCC option -static. */ 49 50 #undef STARTFILE_SPEC 51 #define STARTFILE_SPEC \ 52 "%{!shared: \ 53 %{pg:gcrt0%O%s} \ 54 %{!pg: \ 55 %{p:mcrt0%O%s} \ 56 %{!p: \ 57 %{!static:crt0%O%s} \ 58 %{static:scrt0%O%s}}}}" 59 60 /* Provide a LINK_SPEC appropriate for NetBSD a.out. Here we provide 61 support for the special GCC options -static, -assert, and -nostdlib. */ 62 63 #undef NETBSD_LINK_SPEC_AOUT 64 #define NETBSD_LINK_SPEC_AOUT \ 65 "%{nostdlib:-nostdlib} \ 66 %{!shared: \ 67 %{!nostdlib: \ 68 %{!r*: \ 69 %{!e*:-e start}}} \ 70 -dc -dp \ 71 %{static:-Bstatic}} \ 72 %{shared:-Bshareable} \ 73 %{R*} \ 74 %{assert*}" 75 76 /* Default LINK_SPEC. */ 77 #undef LINK_SPEC 78 #define LINK_SPEC NETBSD_LINK_SPEC_AOUT 79 80 /* Some imports from svr4.h in support of shared libraries. */ 81 82 /* Define the strings used for the .type, .size, and .set directives. 83 These strings generally do not vary from one system running NetBSD 84 to another, but if a given system needs to use different pseudo-op 85 names for these, they may be overridden in the file included after 86 this one. */ 87 88 #undef TYPE_ASM_OP 89 #undef SIZE_ASM_OP 90 #undef SET_ASM_OP 91 #define TYPE_ASM_OP "\t.type\t" 92 #define SIZE_ASM_OP "\t.size\t" 93 #define SET_ASM_OP "\t.set\t" 94 95 96 /* This is how we tell the assembler that a symbol is weak. */ 97 98 #undef ASM_WEAKEN_LABEL 99 #define ASM_WEAKEN_LABEL(FILE,NAME) \ 100 do \ 101 { \ 102 fputs ("\t.globl\t", FILE); assemble_name (FILE, NAME); \ 103 fputc ('\n', FILE); \ 104 fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ 105 fputc ('\n', FILE); \ 106 } \ 107 while (0) 108 109 110 /* The following macro defines the format used to output the second 111 operand of the .type assembler directive. Different svr4 assemblers 112 expect various different forms of this operand. The one given here 113 is just a default. You may need to override it in your machine- 114 specific tm.h file (depending on the particulars of your assembler). */ 115 116 #undef TYPE_OPERAND_FMT 117 #define TYPE_OPERAND_FMT "@%s" 118 119 120 /* Write the extra assembler code needed to declare a function's result. 121 Most svr4 assemblers don't require any special declaration of the 122 result value, but there are exceptions. */ 123 124 #ifndef ASM_DECLARE_RESULT 125 #define ASM_DECLARE_RESULT(FILE, RESULT) 126 #endif 127 128 129 /* These macros generate the special .type and .size directives which 130 are used to set the corresponding fields of the linker symbol table 131 entries in an ELF object file under SVR4 (and a.out on NetBSD). 132 These macros also output the starting labels for the relevant 133 functions/objects. */ 134 135 /* Write the extra assembler code needed to declare a function properly. 136 Some svr4 assemblers need to also have something extra said about the 137 function's return value. We allow for that here. */ 138 139 #undef ASM_DECLARE_FUNCTION_NAME 140 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 141 do \ 142 { \ 143 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ 144 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ 145 ASM_OUTPUT_LABEL(FILE, NAME); \ 146 } \ 147 while (0) 148 149 150 /* Write the extra assembler code needed to declare an object properly. */ 151 152 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 153 do \ 154 { \ 155 HOST_WIDE_INT size; \ 156 \ 157 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 158 \ 159 size_directive_output = 0; \ 160 if (!flag_inhibit_size_directive \ 161 && (DECL) && DECL_SIZE (DECL)) \ 162 { \ 163 size_directive_output = 1; \ 164 size = int_size_in_bytes (TREE_TYPE (DECL)); \ 165 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \ 166 } \ 167 \ 168 ASM_OUTPUT_LABEL (FILE, NAME); \ 169 } \ 170 while (0) 171 172 /* Output the size directive for a decl in rest_of_decl_compilation 173 in the case where we did not do so before the initializer. 174 Once we find the error_mark_node, we know that the value of 175 size_directive_output was set 176 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ 177 178 #undef ASM_FINISH_DECLARE_OBJECT 179 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ 180 do \ 181 { \ 182 const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 183 HOST_WIDE_INT size; \ 184 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ 185 && ! AT_END && TOP_LEVEL \ 186 && DECL_INITIAL (DECL) == error_mark_node \ 187 && !size_directive_output) \ 188 { \ 189 size_directive_output = 1; \ 190 size = int_size_in_bytes (TREE_TYPE (DECL)); \ 191 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \ 192 } \ 193 } \ 194 while (0) 195 196 197 /* This is how to declare the size of a function. */ 198 199 #undef ASM_DECLARE_FUNCTION_SIZE 200 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 201 do \ 202 { \ 203 if (!flag_inhibit_size_directive) \ 204 ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \ 205 } \ 206 while (0) 207