1 /* Definitions of MCore target. 2 Copyright (C) 1998-2013 Free Software Foundation, Inc. 3 Contributed by Cygnus Solutions. 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 #ifndef __MCORE_ELF_H__ 22 #define __MCORE_ELF_H__ 23 24 /* Use DWARF2 debugging info. */ 25 #define DWARF2_DEBUGGING_INFO 1 26 27 #undef PREFERRED_DEBUGGING_TYPE 28 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG 29 30 #define MCORE_EXPORT_NAME(STREAM, NAME) \ 31 do \ 32 { \ 33 fprintf (STREAM, "\t.section .exports\n"); \ 34 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \ 35 (* targetm.strip_name_encoding) (NAME)); \ 36 in_section = NULL; \ 37 } \ 38 while (0); 39 40 /* Write the extra assembler code needed to declare a function properly. 41 Some svr4 assemblers need to also have something extra said about the 42 function's return value. We allow for that here. */ 43 #undef ASM_DECLARE_FUNCTION_NAME 44 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ 45 do \ 46 { \ 47 if (mcore_dllexport_name_p (NAME)) \ 48 { \ 49 MCORE_EXPORT_NAME (FILE, NAME); \ 50 switch_to_section (function_section (DECL)); \ 51 } \ 52 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ 53 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ 54 ASM_OUTPUT_LABEL (FILE, NAME); \ 55 } \ 56 while (0) 57 58 /* Write the extra assembler code needed to declare an object properly. */ 59 #undef ASM_DECLARE_OBJECT_NAME 60 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ 61 do \ 62 { \ 63 HOST_WIDE_INT size; \ 64 if (mcore_dllexport_name_p (NAME)) \ 65 { \ 66 section *save_section = in_section; \ 67 MCORE_EXPORT_NAME (FILE, NAME); \ 68 switch_to_section (save_section); \ 69 } \ 70 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ 71 size_directive_output = 0; \ 72 if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ 73 { \ 74 size_directive_output = 1; \ 75 size = int_size_in_bytes (TREE_TYPE (DECL)); \ 76 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \ 77 } \ 78 ASM_OUTPUT_LABEL(FILE, NAME); \ 79 } \ 80 while (0) 81 82 /* Output the size directive for a decl in rest_of_decl_compilation 83 in the case where we did not do so before the initializer. 84 Once we find the error_mark_node, we know that the value of 85 size_directive_output was set 86 by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ 87 #undef ASM_FINISH_DECLARE_OBJECT 88 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ 89 do \ 90 { \ 91 const char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ 92 HOST_WIDE_INT size; \ 93 if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ 94 && ! AT_END && TOP_LEVEL \ 95 && DECL_INITIAL (DECL) == error_mark_node \ 96 && !size_directive_output) \ 97 { \ 98 size_directive_output = 1; \ 99 size = int_size_in_bytes (TREE_TYPE (DECL)); \ 100 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \ 101 } \ 102 } \ 103 while (0) 104 105 106 #undef STARTFILE_SPEC 107 #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s" 108 109 /* Include the OS stub library, so that the code can be simulated. 110 This is not the right way to do this. Ideally this kind of thing 111 should be done in the linker script - but I have not worked out how 112 to specify the location of a linker script in a gcc command line yet. */ 113 #undef ENDFILE_SPEC 114 #define ENDFILE_SPEC "%{!mno-lsim:-lsim} crtend.o%s crtn.o%s" 115 116 /* The subroutine calls in the .init and .fini sections create literal 117 pools which must be jumped around.... */ 118 #define FORCE_CODE_SECTION_ALIGN asm ("br 1f ; .literals ; 1:"); 119 120 #undef CTORS_SECTION_ASM_OP 121 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"aw\"" 122 #undef DTORS_SECTION_ASM_OP 123 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"aw\"" 124 125 #endif /* __MCORE_ELF_H__ */ 126