1 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF. 2 Copyright (C) 1996-2017 Free Software Foundation, Inc. 3 Contributed by Richard Henderson (rth@tamu.edu). 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 3, 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 COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 #undef OBJECT_FORMAT_COFF 22 #undef EXTENDED_COFF 23 #define OBJECT_FORMAT_ELF 24 25 /* ??? Move all SDB stuff from alpha.h to osf.h. */ 26 #undef SDB_DEBUGGING_INFO 27 #undef DBX_DEBUGGING_INFO 28 29 #define DWARF2_DEBUGGING_INFO 1 30 31 #undef PREFERRED_DEBUGGING_TYPE 32 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG 33 34 #undef ASM_FINAL_SPEC 35 36 /* alpha/ doesn't use elfos.h for some reason. */ 37 #define TARGET_OBJFMT_CPP_BUILTINS() \ 38 do \ 39 { \ 40 builtin_define ("__ELF__"); \ 41 } \ 42 while (0) 43 44 #undef CC1_SPEC 45 #define CC1_SPEC "%{G*}" 46 47 #undef ASM_SPEC 48 #define ASM_SPEC "%{G*} %{relax:-relax} %{!gstabs*:-no-mdebug}%{gstabs*:-mdebug} %{mcpu=*:-m%*}" 49 50 /* Do not output a .file directive at the beginning of the input file. */ 51 52 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE 53 #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false 54 55 /* This is how to output an assembler line 56 that says to advance the location counter 57 to a multiple of 2**LOG bytes. */ 58 59 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 60 if ((LOG) != 0) \ 61 fprintf (FILE, "\t.align %d\n", LOG); 62 63 /* This says how to output assembler code to declare an 64 uninitialized internal linkage data object. Under SVR4, 65 the linker seems to want the alignment of data objects 66 to depend on their types. We do exactly that here. */ 67 68 #undef ASM_OUTPUT_ALIGNED_LOCAL 69 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ 70 do { \ 71 if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value) \ 72 switch_to_section (sbss_section); \ 73 else \ 74 switch_to_section (bss_section); \ 75 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 76 if (!flag_inhibit_size_directive) \ 77 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, SIZE); \ 78 ASM_OUTPUT_ALIGN ((FILE), exact_log2((ALIGN) / BITS_PER_UNIT)); \ 79 ASM_OUTPUT_LABEL(FILE, NAME); \ 80 ASM_OUTPUT_SKIP((FILE), (SIZE) ? (SIZE) : 1); \ 81 } while (0) 82 83 /* This says how to output assembler code to declare an 84 uninitialized external linkage data object. */ 85 86 #undef ASM_OUTPUT_ALIGNED_BSS 87 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \ 88 do { \ 89 ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \ 90 } while (0) 91 92 #undef BSS_SECTION_ASM_OP 93 #define BSS_SECTION_ASM_OP "\t.section\t.bss" 94 #undef SBSS_SECTION_ASM_OP 95 #define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\"" 96 #undef SDATA_SECTION_ASM_OP 97 #define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\"" 98 99 /* This is how we tell the assembler that two symbols have the same value. */ 100 101 #undef ASM_OUTPUT_DEF 102 #define ASM_OUTPUT_DEF(FILE, ALIAS, NAME) \ 103 do { \ 104 assemble_name(FILE, ALIAS); \ 105 fputs(" = ", FILE); \ 106 assemble_name(FILE, NAME); \ 107 fputc('\n', FILE); \ 108 } while (0) 109 110 #undef ASM_OUTPUT_DEF_FROM_DECLS 111 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \ 112 do { \ 113 const char *alias = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 114 const char *name = IDENTIFIER_POINTER (TARGET); \ 115 if (TREE_CODE (DECL) == FUNCTION_DECL) \ 116 { \ 117 fputc ('$', FILE); \ 118 assemble_name (FILE, alias); \ 119 fputs ("..ng = $", FILE); \ 120 assemble_name (FILE, name); \ 121 fputs ("..ng\n", FILE); \ 122 } \ 123 ASM_OUTPUT_DEF (FILE, alias, name); \ 124 } while (0) 125 126 /* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the 127 (even more) magical crtbegin.o file which provides part of the 128 support for getting C++ file-scope static object constructed 129 before entering `main'. */ 130 131 #undef STARTFILE_SPEC 132 #ifdef HAVE_LD_PIE 133 #define STARTFILE_SPEC \ 134 "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\ 135 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" 136 #else 137 #define STARTFILE_SPEC \ 138 "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\ 139 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" 140 #endif 141 142 /* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the 143 magical crtend.o file which provides part of the support for 144 getting C++ file-scope static object constructed before entering 145 `main', followed by a normal ELF "finalizer" file, `crtn.o'. */ 146 147 #undef ENDFILE_SPEC 148 #define ENDFILE_SPEC \ 149 "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ 150 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" 151 152 /* This variable should be set to 'true' if the target ABI requires 153 unwinding tables even when exceptions are not used. */ 154 #define TARGET_UNWIND_TABLES_DEFAULT true 155 156 /* Select a format to encode pointers in exception handling data. CODE 157 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is 158 true if the symbol may be affected by dynamic relocations. 159 160 Since application size is already constrained to <2GB by the form of 161 the ldgp relocation, we can use a 32-bit pc-relative relocation to 162 static data. Dynamic data is accessed indirectly to allow for read 163 only EH sections. */ 164 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ 165 (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) 166 167 /* If defined, a C statement to be executed just prior to the output of 168 assembler code for INSN. */ 169 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \ 170 (alpha_this_literal_sequence_number = 0, \ 171 alpha_this_gpdisp_sequence_number = 0) 172 extern int alpha_this_literal_sequence_number; 173 extern int alpha_this_gpdisp_sequence_number; 174 175 /* Since the bits of the _init and _fini function is spread across 176 many object files, each potentially with its own GP, we must assume 177 we need to load our GP. Further, the .init/.fini section can 178 easily be more than 4MB away from the function to call so we can't 179 use bsr. */ 180 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ 181 asm (SECTION_OP "\n" \ 182 " br $29,1f\n" \ 183 "1: ldgp $29,0($29)\n" \ 184 " unop\n" \ 185 " jsr $26," USER_LABEL_PREFIX #FUNC "\n" \ 186 " .align 3\n" \ 187 " .previous"); 188 189 /* If we have the capability create headers for efficient EH lookup. 190 As of Jan 2002, only glibc 2.2.4 can actually make use of this, but 191 I imagine that other systems will catch up. In the meantime, it 192 doesn't harm to make sure that the data exists to be used later. */ 193 #if defined(HAVE_LD_EH_FRAME_HDR) && !defined(LINK_EH_SPEC) 194 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " 195 #endif 196