1/* Definitions of target machine for GNU compiler, 2 for ARM with ELF obj format. 3 Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. 4 Contributed by Philip Blundell <philb@gnu.org> and 5 Catherine Moore <clm@cygnus.com> 6 7This file is part of GNU CC. 8 9GNU CC is free software; you can redistribute it and/or modify 10it under the terms of the GNU General Public License as published by 11the Free Software Foundation; either version 2, or (at your option) 12any later version. 13 14GNU CC is distributed in the hope that it will be useful, 15but WITHOUT ANY WARRANTY; without even the implied warranty of 16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17GNU General Public License for more details. 18 19You should have received a copy of the GNU General Public License 20along with GNU CC; see the file COPYING. If not, write to 21the Free Software Foundation, 59 Temple Place - Suite 330, 22Boston, MA 02111-1307, USA. */ 23 24 25#define OBJECT_FORMAT_ELF 26 27#ifndef LOCAL_LABEL_PREFIX 28#define LOCAL_LABEL_PREFIX "." 29#endif 30 31#ifndef USER_LABEL_PREFIX 32#define USER_LABEL_PREFIX "" 33#endif 34 35#ifndef CPP_PREDEFINES 36#define CPP_PREDEFINES "-Darm -Darm_elf -Acpu(arm) -Amachine(arm) -D__ELF__" 37#endif 38 39/* The following macro defines the format used to output the second 40 operand of the .type assembler directive. Different svr4 assemblers 41 expect various different forms for this operand. The one given here 42 is just a default. You may need to override it in your machine- 43 specific tm.h file (depending upon the particulars of your assembler). */ 44#define TYPE_OPERAND_FMT "%s" 45 46/* Write the extra assembler code needed to declare a function's result. 47 Most svr4 assemblers don't require any special declaration of the 48 result value, but there are exceptions. */ 49#ifndef ASM_DECLARE_RESULT 50#define ASM_DECLARE_RESULT(FILE, RESULT) 51#endif 52 53/* These macros generate the special .type and .size directives which 54 are used to set the corresponding fields of the linker symbol table 55 entries in an ELF object file under SVR4. These macros also output 56 the starting labels for the relevant functions/objects. */ 57#define TYPE_ASM_OP ".type" 58#define SIZE_ASM_OP ".size" 59 60/* Write the extra assembler code needed to declare a function properly. 61 Some svr4 assemblers need to also have something extra said about the 62 function's return value. We allow for that here. */ 63#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 64 do \ 65 { \ 66 if (TARGET_POKE_FUNCTION_NAME) \ 67 arm_poke_function_name (FILE, NAME); \ 68 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ 69 assemble_name (FILE, NAME); \ 70 putc (',', FILE); \ 71 fprintf (FILE, TYPE_OPERAND_FMT, "function"); \ 72 putc ('\n', FILE); \ 73 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ 74 ASM_OUTPUT_LABEL(FILE, NAME); \ 75 } \ 76 while (0) 77 78/* Write the extra assembler code needed to declare an object properly. */ 79#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 80 do { \ 81 fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ 82 assemble_name (FILE, NAME); \ 83 putc (',', FILE); \ 84 fprintf (FILE, TYPE_OPERAND_FMT, "object"); \ 85 putc ('\n', FILE); \ 86 size_directive_output = 0; \ 87 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ 88 { \ 89 size_directive_output = 1; \ 90 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ 91 assemble_name (FILE, NAME); \ 92 putc (',', FILE); \ 93 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \ 94 int_size_in_bytes (TREE_TYPE (DECL))); \ 95 fputc ('\n', FILE); \ 96 } \ 97 ASM_OUTPUT_LABEL(FILE, NAME); \ 98 } while (0) 99 100/* Output the size directive for a decl in rest_of_decl_compilation 101 in the case where we did not do so before the initializer. 102 Once we find the error_mark_node, we know that the value of 103 size_directive_output was set 104 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ 105#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ 106do { \ 107 char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 108 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ 109 && ! AT_END && TOP_LEVEL \ 110 && DECL_INITIAL (DECL) == error_mark_node \ 111 && !size_directive_output) \ 112 { \ 113 size_directive_output = 1; \ 114 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ 115 assemble_name (FILE, name); \ 116 putc (',', FILE); \ 117 fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \ 118 int_size_in_bytes (TREE_TYPE (DECL))); \ 119 fputc ('\n', FILE); \ 120 } \ 121 } while (0) 122 123/* This is how to declare the size of a function. */ 124#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ 125 do { \ 126 if (!flag_inhibit_size_directive) \ 127 { \ 128 char label[256]; \ 129 static int labelno; \ 130 labelno ++; \ 131 ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \ 132 ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \ 133 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ 134 assemble_name (FILE, (FNAME)); \ 135 fprintf (FILE, ","); \ 136 assemble_name (FILE, label); \ 137 fprintf (FILE, "-"); \ 138 assemble_name (FILE, (FNAME)); \ 139 putc ('\n', FILE); \ 140 } \ 141 } while (0) 142 143/* Define this macro if jump tables (for `tablejump' insns) should be 144 output in the text section, along with the assembler instructions. 145 Otherwise, the readonly data section is used. */ 146#define JUMP_TABLES_IN_TEXT_SECTION 1 147 148#ifndef ASM_SPEC 149#define ASM_SPEC "%{mbig-endian:-EB} %{mcpu=*:-m%*} %{march=*:-m%*} \ 150 %{mapcs-*:-mapcs-%*} %{mthumb-interwork:-mthumb-interwork} %{mapcs-float:mfloat}" 151#endif 152 153#ifndef LINK_SPEC 154#define LINK_SPEC "%{mbig-endian:-EB} -X" 155#endif 156 157/* Run-time Target Specification. */ 158#ifndef TARGET_VERSION 159#define TARGET_VERSION fputs (" (ARM/elf)", stderr) 160#endif 161 162#ifndef TARGET_DEFAULT 163#define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | ARM_FLAG_APCS_32) 164#endif 165 166#ifndef MULTILIB_DEFAULTS 167#define MULTILIB_DEFAULTS { "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" } 168#endif 169 170/* Setting this to 32 produces more efficient code, but the value set in previous 171 versions of this toolchain was 8, which produces more compact structures. The 172 command line option -mstructure_size_boundary=<n> can be used to change this 173 value. */ 174#undef STRUCTURE_SIZE_BOUNDARY 175#define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary 176 177extern int arm_structure_size_boundary; 178 179/* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS 180 is a valid machine specific attribute for DECL. 181 The attributes in ATTRIBUTES have previously been assigned to DECL. */ 182#define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \ 183arm_valid_machine_decl_attribute (DECL, IDENTIFIER, ARGS) 184 185 186/* A C statement to output assembler commands which will identify the 187 object file as having been compiled with GNU CC (or another GNU 188 compiler). */ 189/* Define this to NULL so we don't get anything. 190 We have ASM_IDENTIFY_LANGUAGE. 191 Also, when using stabs, gcc2_compiled must be a stabs entry, not an 192 ordinary symbol, or gdb won't see it. The stabs entry must be 193 before the N_SO in order for gdb to find it. */ 194#ifndef ASM_IDENTIFY_GCC 195#define ASM_IDENTIFY_GCC(STREAM) \ 196 fprintf (STREAM, "%sgcc2_compiled.:\n", LOCAL_LABEL_PREFIX ) 197#endif 198 199/* This outputs a lot of .req's to define alias for various registers. 200 Let's try to avoid this. */ 201#ifndef ASM_FILE_START 202#define ASM_FILE_START(STREAM) \ 203do { \ 204 extern char * version_string; \ 205 fprintf (STREAM, "%s Generated by gcc %s for ARM/elf\n", \ 206 ASM_COMMENT_START, version_string); \ 207 output_file_directive ((STREAM), main_input_filename); \ 208} while (0) 209#endif 210 211/* Output an internal label definition. */ 212#ifndef ASM_OUTPUT_INTERNAL_LABEL 213#define ASM_OUTPUT_INTERNAL_LABEL(STREAM, PREFIX, NUM) \ 214 do \ 215 { \ 216 char * s = (char *) alloca (40 + strlen (PREFIX)); \ 217 extern int arm_target_label, arm_ccfsm_state; \ 218 extern rtx arm_target_insn; \ 219 \ 220 if (arm_ccfsm_state == 3 && arm_target_label == (NUM) \ 221 && !strcmp (PREFIX, "L")) \ 222 { \ 223 arm_ccfsm_state = 0; \ 224 arm_target_insn = NULL; \ 225 } \ 226 ASM_GENERATE_INTERNAL_LABEL (s, (PREFIX), (NUM)); \ 227 ASM_OUTPUT_LABEL (STREAM, s); \ 228 } while (0) 229#endif 230 231/* Support the ctors/dtors and other sections. */ 232 233/* Define the pseudo-ops used to switch to the .ctors and .dtors sections. 234 235 Note that we want to give these sections the SHF_WRITE attribute 236 because these sections will actually contain data (i.e. tables of 237 addresses of functions in the current root executable or shared library 238 file) and, in the case of a shared library, the relocatable addresses 239 will have to be properly resolved/relocated (and then written into) by 240 the dynamic linker when it actually attaches the given shared library 241 to the executing process. (Note that on SVR4, you may wish to use the 242 `-z text' option to the ELF linker, when building a shared library, as 243 an additional check that you are doing everything right. But if you do 244 use the `-z text' option when building a shared library, you will get 245 errors unless the .ctors and .dtors sections are marked as writable 246 via the SHF_WRITE attribute.) */ 247#ifndef CTORS_SECTION_ASM_OP 248#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\"" 249#endif 250 251#ifndef DTORS_SECTION_ASM_OP 252#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\"" 253#endif 254 255/* A list of other sections which the compiler might be "in" at any 256 given time. */ 257#ifndef SUBTARGET_EXTRA_SECTIONS 258#define SUBTARGET_EXTRA_SECTIONS 259#endif 260 261#ifndef EXTRA_SECTIONS 262#define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_ctors, in_dtors 263#endif 264 265/* A list of extra section function definitions. */ 266#ifndef SUBTARGET_EXTRA_SECTION_FUNCTIONS 267#define SUBTARGET_EXTRA_SECTION_FUNCTIONS 268#endif 269 270#ifndef EXTRA_SECTION_FUNCTIONS 271#define EXTRA_SECTION_FUNCTIONS \ 272 SUBTARGET_EXTRA_SECTION_FUNCTIONS \ 273 CTORS_SECTION_FUNCTION \ 274 DTORS_SECTION_FUNCTION 275#endif 276 277#ifndef CTORS_SECTION_FUNCTION 278#define CTORS_SECTION_FUNCTION \ 279void \ 280ctors_section () \ 281{ \ 282 if (in_section != in_ctors) \ 283 { \ 284 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \ 285 in_section = in_ctors; \ 286 } \ 287} 288#endif 289 290#ifndef DTORS_SECTION_FUNCTION 291#define DTORS_SECTION_FUNCTION \ 292void \ 293dtors_section () \ 294{ \ 295 if (in_section != in_dtors) \ 296 { \ 297 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \ 298 in_section = in_dtors; \ 299 } \ 300} 301#endif 302 303/* Support the ctors/dtors sections for g++. */ 304#ifndef INT_ASM_OP 305#define INT_ASM_OP ".word" 306#endif 307 308/* A C statement (sans semicolon) to output an element in the table of 309 global constructors. */ 310#ifndef ASM_OUTPUT_CONSTRUCTOR 311#define ASM_OUTPUT_CONSTRUCTOR(STREAM,NAME) \ 312do { \ 313 ctors_section (); \ 314 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \ 315 assemble_name (STREAM, NAME); \ 316 fprintf (STREAM, "\n"); \ 317} while (0) 318#endif 319 320/* A C statement (sans semicolon) to output an element in the table of 321 global destructors. */ 322#ifndef ASM_OUTPUT_DESTRUCTOR 323#define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \ 324do { \ 325 dtors_section (); \ 326 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \ 327 assemble_name (STREAM, NAME); \ 328 fprintf (STREAM, "\n"); \ 329} while (0) 330#endif 331 332/* This is how we tell the assembler that a symbol is weak. */ 333 334#define ASM_WEAKEN_LABEL(FILE,NAME) \ 335 do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ 336 fputc ('\n', FILE); } while (0) 337 338/* For PIC code we need to explicitly specify (PLT) and (GOT) relocs. */ 339#define NEED_PLT_GOT flag_pic 340 341/* The ELF assembler handles GOT addressing differently to NetBSD. */ 342#define GOT_PCREL 0 343 344/* Biggest alignment supported by the object file format of this 345 machine. Use this macro to limit the alignment which can be 346 specified using the `__attribute__ ((aligned (N)))' construct. If 347 not defined, the default value is `BIGGEST_ALIGNMENT'. */ 348#define MAX_OFILE_ALIGNMENT (32768*8) 349 350/* Align output to a power of two. */ 351#define ASM_OUTPUT_ALIGN(STREAM, POWER) \ 352 fprintf (STREAM, "\t.align\t%d\n", POWER) 353 354#include "arm/aout.h" 355