netbsd-aout.h revision 169689
142660Smarkm/* Common configuration file for NetBSD a.out targets. 2146515Sru Copyright (C) 2002 Free Software Foundation, Inc. 321495Sjmacd Contributed by Wasabi Systems, Inc. 4146515Sru 5146515SruThis file is part of GCC. 621495Sjmacd 721495SjmacdGCC is free software; you can redistribute it and/or modify 821495Sjmacdit under the terms of the GNU General Public License as published by 921495Sjmacdthe Free Software Foundation; either version 2, or (at your option) 1021495Sjmacdany later version. 1121495Sjmacd 1221495SjmacdGCC is distributed in the hope that it will be useful, 1321495Sjmacdbut WITHOUT ANY WARRANTY; without even the implied warranty of 1421495SjmacdMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1521495SjmacdGNU General Public License for more details. 1621495Sjmacd 1721495SjmacdYou should have received a copy of the GNU General Public License 1821495Sjmacdalong with GCC; see the file COPYING. If not, write to 1921495Sjmacdthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 2021495SjmacdBoston, MA 02110-1301, USA. */ 2121495Sjmacd 2221495Sjmacd/* TARGET_OS_CPP_BUILTINS() common to all NetBSD a.out targets. */ 2321495Sjmacd#define NETBSD_OS_CPP_BUILTINS_AOUT() \ 2442660Smarkm do \ 2521495Sjmacd { \ 2621495Sjmacd NETBSD_OS_CPP_BUILTINS_COMMON(); \ 2721495Sjmacd } \ 2821495Sjmacd while (0) 2921495Sjmacd 3021495Sjmacd/* This defines which switch letters take arguments. */ 3156160Sru 3221495Sjmacd#undef SWITCH_TAKES_ARG 3321495Sjmacd#define SWITCH_TAKES_ARG(CHAR) \ 3421495Sjmacd (DEFAULT_SWITCH_TAKES_ARG(CHAR) \ 3521495Sjmacd || (CHAR) == 'R') 3621495Sjmacd 3721495Sjmacd 3821495Sjmacd/* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal 3942660Smarkm with the options for generating PIC code. */ 4042660Smarkm 4142660Smarkm#undef ASM_SPEC 4242660Smarkm#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" 4356160Sru 4456160Sru#define AS_NEEDS_DASH_FOR_PIPED_INPUT 4556160Sru 4656160Sru 4756160Sru/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out. Here we 4842660Smarkm provide support for the special GCC option -static. */ 4956160Sru 5042660Smarkm#undef STARTFILE_SPEC 5142660Smarkm#define STARTFILE_SPEC \ 5221495Sjmacd "%{!shared: \ 5321495Sjmacd %{pg:gcrt0%O%s} \ 5421495Sjmacd %{!pg: \ 5521495Sjmacd %{p:mcrt0%O%s} \ 5621495Sjmacd %{!p: \ 5721495Sjmacd %{!static:crt0%O%s} \ 5821495Sjmacd %{static:scrt0%O%s}}}}" 5921495Sjmacd 6021495Sjmacd/* Provide a LINK_SPEC appropriate for NetBSD a.out. Here we provide 6121495Sjmacd support for the special GCC options -static, -assert, and -nostdlib. */ 6221495Sjmacd 6321495Sjmacd#undef NETBSD_LINK_SPEC_AOUT 6421495Sjmacd#define NETBSD_LINK_SPEC_AOUT \ 6521495Sjmacd "%{nostdlib:-nostdlib} \ 6621495Sjmacd %{!shared: \ 6721495Sjmacd %{!nostdlib: \ 6821495Sjmacd %{!r*: \ 6921495Sjmacd %{!e*:-e start}}} \ 7021495Sjmacd -dc -dp \ 7121495Sjmacd %{static:-Bstatic}} \ 7221495Sjmacd %{shared:-Bshareable} \ 7321495Sjmacd %{R*} \ 7421495Sjmacd %{assert*}" 7521495Sjmacd 7621495Sjmacd/* Default LINK_SPEC. */ 7756160Sru#undef LINK_SPEC 7856160Sru#define LINK_SPEC NETBSD_LINK_SPEC_AOUT 7956160Sru 80146515Sru/* Some imports from svr4.h in support of shared libraries. */ 81146515Sru 8293139Sru/* Define the strings used for the .type, .size, and .set directives. 83146515Sru These strings generally do not vary from one system running NetBSD 84146515Sru to another, but if a given system needs to use different pseudo-op 85146515Sru names for these, they may be overridden in the file included after 8656160Sru this one. */ 8756160Sru 8856160Sru#undef TYPE_ASM_OP 8956160Sru#undef SIZE_ASM_OP 9056160Sru#undef SET_ASM_OP 9156160Sru#define TYPE_ASM_OP "\t.type\t" 9256160Sru#define SIZE_ASM_OP "\t.size\t" 9356160Sru#define SET_ASM_OP "\t.set\t" 9456160Sru 9521495Sjmacd 9621495Sjmacd/* This is how we tell the assembler that a symbol is weak. */ 9721495Sjmacd 9821495Sjmacd#undef ASM_WEAKEN_LABEL 9921495Sjmacd#define ASM_WEAKEN_LABEL(FILE,NAME) \ 10021495Sjmacd do \ 10142660Smarkm { \ 10221495Sjmacd fputs ("\t.globl\t", FILE); assemble_name (FILE, NAME); \ 10321495Sjmacd fputc ('\n', FILE); \ 10421495Sjmacd fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ 105100513Sru fputc ('\n', FILE); \ 106100513Sru } \ 107100513Sru while (0) 108100513Sru 109146515Sru 11021495Sjmacd/* The following macro defines the format used to output the second 11121495Sjmacd operand of the .type assembler directive. Different svr4 assemblers 11293139Sru expect various different forms of this operand. The one given here 113146515Sru is just a default. You may need to override it in your machine- 114100513Sru specific tm.h file (depending on the particulars of your assembler). */ 11556160Sru 116100513Sru#undef TYPE_OPERAND_FMT 11756160Sru#define TYPE_OPERAND_FMT "@%s" 118100513Sru 11956160Sru 120146515Sru/* Write the extra assembler code needed to declare a function's result. 12156160Sru Most svr4 assemblers don't require any special declaration of the 12256160Sru result value, but there are exceptions. */ 12356160Sru 12421495Sjmacd#ifndef ASM_DECLARE_RESULT 12521495Sjmacd#define ASM_DECLARE_RESULT(FILE, RESULT) 12621495Sjmacd#endif 12721495Sjmacd 12856160Sru 129146515Sru/* These macros generate the special .type and .size directives which 13056160Sru are used to set the corresponding fields of the linker symbol table 131146515Sru entries in an ELF object file under SVR4 (and a.out on NetBSD). 13256160Sru These macros also output the starting labels for the relevant 13321495Sjmacd functions/objects. */ 13421495Sjmacd 13521495Sjmacd/* Write the extra assembler code needed to declare a function properly. 13621495Sjmacd Some svr4 assemblers need to also have something extra said about the 13721495Sjmacd function's return value. We allow for that here. */ 138146515Sru 139146515Sru#undef ASM_DECLARE_FUNCTION_NAME 14021495Sjmacd#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 14121495Sjmacd do \ 14221495Sjmacd { \ 14342660Smarkm ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ 14442660Smarkm ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ 14542660Smarkm ASM_OUTPUT_LABEL(FILE, NAME); \ 14621495Sjmacd } \ 14721495Sjmacd while (0) 14821495Sjmacd 149146515Sru 15021495Sjmacd/* Write the extra assembler code needed to declare an object properly. */ 15142660Smarkm 15242660Smarkm#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 15321495Sjmacd do \ 15442660Smarkm { \ 15542660Smarkm HOST_WIDE_INT size; \ 15642660Smarkm \ 15742660Smarkm ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 15842660Smarkm \ 159146515Sru size_directive_output = 0; \ 16042660Smarkm if (!flag_inhibit_size_directive \ 16142660Smarkm && (DECL) && DECL_SIZE (DECL)) \ 16242660Smarkm { \ 163146515Sru size_directive_output = 1; \ 16442660Smarkm size = int_size_in_bytes (TREE_TYPE (DECL)); \ 16556160Sru ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \ 166116525Sru } \ 16721495Sjmacd \ 16821495Sjmacd ASM_OUTPUT_LABEL (FILE, NAME); \ 16921495Sjmacd } \ 17021495Sjmacd while (0) 17121495Sjmacd 17242660Smarkm/* Output the size directive for a decl in rest_of_decl_compilation 17321495Sjmacd in the case where we did not do so before the initializer. 174116525Sru Once we find the error_mark_node, we know that the value of 17521495Sjmacd size_directive_output was set 17642660Smarkm by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ 17721495Sjmacd 17821495Sjmacd#undef ASM_FINISH_DECLARE_OBJECT 17921495Sjmacd#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ 18042660Smarkm do \ 18121495Sjmacd { \ 18221495Sjmacd const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 18321495Sjmacd HOST_WIDE_INT size; \ 18442660Smarkm if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ 18542660Smarkm && ! AT_END && TOP_LEVEL \ 18642660Smarkm && DECL_INITIAL (DECL) == error_mark_node \ 18721495Sjmacd && !size_directive_output) \ 18842660Smarkm { \ 18942660Smarkm size_directive_output = 1; \ 19042660Smarkm size = int_size_in_bytes (TREE_TYPE (DECL)); \ 19142660Smarkm ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \ 19221495Sjmacd } \ 19342660Smarkm } \ 19442660Smarkm while (0) 19542660Smarkm 19642660Smarkm 19742660Smarkm/* This is how to declare the size of a function. */ 19821495Sjmacd 19942660Smarkm#undef ASM_DECLARE_FUNCTION_SIZE 20042660Smarkm#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 20142660Smarkm do \ 20242660Smarkm { \ 20321495Sjmacd if (!flag_inhibit_size_directive) \ 20442660Smarkm ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME); \ 20542660Smarkm } \ 20621495Sjmacd while (0) 207116525Sru