1117395Skan/* Target definitions for GNU compiler for SPARC running System V.4 2117395Skan Copyright (C) 1991, 1992, 1995, 1996, 1997, 1998, 2000, 2002 390075Sobrien Free Software Foundation, Inc. 450397Sobrien Contributed by Ron Guilmette (rfg@monkeys.com). 550397Sobrien 6132718SkanThis file is part of GCC. 750397Sobrien 8132718SkanGCC is free software; you can redistribute it and/or modify 950397Sobrienit under the terms of the GNU General Public License as published by 1050397Sobrienthe Free Software Foundation; either version 2, or (at your option) 1150397Sobrienany later version. 1250397Sobrien 13132718SkanGCC is distributed in the hope that it will be useful, 1450397Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1550397SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1650397SobrienGNU General Public License for more details. 1750397Sobrien 1850397SobrienYou should have received a copy of the GNU General Public License 19132718Skanalong with GCC; see the file COPYING. If not, write to 20169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 21169689SkanBoston, MA 02110-1301, USA. */ 2250397Sobrien 2390075Sobrien#ifndef TARGET_VERSION 2490075Sobrien#define TARGET_VERSION fprintf (stderr, " (sparc ELF)"); 2590075Sobrien#endif 2650397Sobrien 2750397Sobrien/* ??? Put back the SIZE_TYPE/PTRDIFF_TYPE definitions set by sparc.h. 2850397Sobrien Why, exactly, is svr4.h messing with this? Seems like the chip 2950397Sobrien would know best. */ 3050397Sobrien 3150397Sobrien#undef SIZE_TYPE 3250397Sobrien#define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int") 3350397Sobrien 3450397Sobrien#undef PTRDIFF_TYPE 3550397Sobrien#define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int") 3650397Sobrien 3750397Sobrien/* Undefined some symbols which are defined in "svr4.h" but which are 3850397Sobrien appropriate only for typical svr4 systems, but not for the specific 39117395Skan case of svr4 running on a SPARC. */ 4050397Sobrien 4150397Sobrien#undef INIT_SECTION_ASM_OP 4250397Sobrien#undef FINI_SECTION_ASM_OP 43117395Skan#undef READONLY_DATA_SECTION_ASM_OP 4450397Sobrien#undef TYPE_OPERAND_FMT 4550397Sobrien#undef PUSHSECTION_FORMAT 4650397Sobrien#undef STRING_ASM_OP 4750397Sobrien#undef COMMON_ASM_OP 4850397Sobrien#undef SKIP_ASM_OP 4950397Sobrien#undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */ 5050397Sobrien 5150397Sobrien/* The native assembler can't compute differences between symbols in different 5250397Sobrien sections when generating pic code, so we must put jump tables in the 5350397Sobrien text section. */ 5452284Sobrien/* But we now defer the tables to the end of the function, so we make 5552284Sobrien this 0 to not confuse the branch shortening code. */ 5652284Sobrien#define JUMP_TABLES_IN_TEXT_SECTION 0 5750397Sobrien 5850397Sobrien/* Pass -K to the assembler when PIC. */ 5950397Sobrien#undef ASM_SPEC 6050397Sobrien#define ASM_SPEC \ 6150397Sobrien "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \ 62132718Skan %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu)" 6350397Sobrien 64117395Skan/* Define the names of various pseudo-op used by the SPARC/svr4 assembler. 6550397Sobrien Note that many of these are different from the typical pseudo-ops used 6650397Sobrien by most svr4 assemblers. That is probably due to a (misguided?) attempt 67117395Skan to keep the SPARC/svr4 assembler somewhat compatible with the SPARC/SunOS 6850397Sobrien assembler. */ 6950397Sobrien 7090075Sobrien#define STRING_ASM_OP "\t.asciz\t" 7190075Sobrien#define COMMON_ASM_OP "\t.common\t" 7290075Sobrien#define SKIP_ASM_OP "\t.skip\t" 7390075Sobrien#define PUSHSECTION_ASM_OP "\t.pushsection\t" 7490075Sobrien#define POPSECTION_ASM_OP "\t.popsection" 7550397Sobrien 7650397Sobrien/* This is the format used to print the second operand of a .type pseudo-op 77117395Skan for the SPARC/svr4 assembler. */ 7850397Sobrien 7950397Sobrien#define TYPE_OPERAND_FMT "#%s" 8050397Sobrien 8150397Sobrien/* This is the format used to print a .pushsection pseudo-op (and its operand) 82117395Skan for the SPARC/svr4 assembler. */ 8350397Sobrien 8490075Sobrien#define PUSHSECTION_FORMAT "%s\"%s\"\n" 8550397Sobrien 8650397Sobrien#undef ASM_OUTPUT_CASE_LABEL 8750397Sobrien#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \ 8850397Sobriendo { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \ 89132718Skan (*targetm.asm_out.internal_label) ((FILE), PREFIX, NUM); \ 9050397Sobrien } while (0) 9150397Sobrien 9250397Sobrien/* This is how to equate one symbol to another symbol. The syntax used is 9350397Sobrien `SYM1=SYM2'. Note that this is different from the way equates are done 9450397Sobrien with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'. */ 9550397Sobrien 9650397Sobrien#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 9750397Sobrien do { fprintf ((FILE), "\t"); \ 9850397Sobrien assemble_name (FILE, LABEL1); \ 9950397Sobrien fprintf (FILE, " = "); \ 10050397Sobrien assemble_name (FILE, LABEL2); \ 10150397Sobrien fprintf (FILE, "\n"); \ 10250397Sobrien } while (0) 10350397Sobrien 104117395Skan/* Define how the SPARC registers should be numbered for Dwarf output. 10550397Sobrien The numbering provided here should be compatible with the native 106117395Skan svr4 SDB debugger in the SPARC/svr4 reference port. The numbering 10750397Sobrien is as follows: 10850397Sobrien 10950397Sobrien Assembly name gcc internal regno Dwarf regno 11050397Sobrien ---------------------------------------------------------- 11150397Sobrien g0-g7 0-7 0-7 11250397Sobrien o0-o7 8-15 8-15 11350397Sobrien l0-l7 16-23 16-23 11450397Sobrien i0-i7 24-31 24-31 11550397Sobrien f0-f31 32-63 40-71 11650397Sobrien*/ 11750397Sobrien 11850397Sobrien#define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8) 11950397Sobrien 12050397Sobrien/* A set of symbol definitions for assembly pseudo-ops which will 12150397Sobrien get us switched to various sections of interest. These are used 12250397Sobrien in all places where we simply want to switch to a section, and 12350397Sobrien *not* to push the previous section name onto the assembler's 12450397Sobrien section names stack (as we do often in dwarfout.c). */ 12550397Sobrien 12690075Sobrien#define TEXT_SECTION_ASM_OP "\t.section\t\".text\"" 12790075Sobrien#define DATA_SECTION_ASM_OP "\t.section\t\".data\"" 12890075Sobrien#define BSS_SECTION_ASM_OP "\t.section\t\".bss\"" 129117395Skan#define READONLY_DATA_SECTION_ASM_OP "\t.section\t\".rodata\"" 13090075Sobrien#define INIT_SECTION_ASM_OP "\t.section\t\".init\"" 13190075Sobrien#define FINI_SECTION_ASM_OP "\t.section\t\".fini\"" 13250397Sobrien 13350397Sobrien/* Define the pseudo-ops used to switch to the .ctors and .dtors sections. 13450397Sobrien 13550397Sobrien Note that we want to give these sections the SHF_WRITE attribute 13650397Sobrien because these sections will actually contain data (i.e. tables of 13750397Sobrien addresses of functions in the current root executable or shared library 13850397Sobrien file) and, in the case of a shared library, the relocatable addresses 13950397Sobrien will have to be properly resolved/relocated (and then written into) by 14050397Sobrien the dynamic linker when it actually attaches the given shared library 14150397Sobrien to the executing process. (Note that on SVR4, you may wish to use the 14250397Sobrien `-z text' option to the ELF linker, when building a shared library, as 14350397Sobrien an additional check that you are doing everything right. But if you do 14450397Sobrien use the `-z text' option when building a shared library, you will get 14550397Sobrien errors unless the .ctors and .dtors sections are marked as writable 14650397Sobrien via the SHF_WRITE attribute.) */ 14750397Sobrien 14850397Sobrien#undef CTORS_SECTION_ASM_OP 14990075Sobrien#define CTORS_SECTION_ASM_OP "\t.section\t\".ctors\",#alloc,#write" 15050397Sobrien#undef DTORS_SECTION_ASM_OP 15190075Sobrien#define DTORS_SECTION_ASM_OP "\t.section\t\".dtors\",#alloc,#write" 15250397Sobrien 15390075Sobrien/* Switch into a generic section. */ 15490075Sobrien#undef TARGET_ASM_NAMED_SECTION 15590075Sobrien#define TARGET_ASM_NAMED_SECTION sparc_elf_asm_named_section 15650397Sobrien 15750397Sobrien#undef ASM_OUTPUT_ALIGNED_BSS 15850397Sobrien#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 15950397Sobrien asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN) 16052284Sobrien 16152284Sobrien/* Override the name of the mcount profiling function. */ 16252284Sobrien 16352284Sobrien#undef MCOUNT_FUNCTION 16452284Sobrien#define MCOUNT_FUNCTION "*_mcount" 165