xref: /openbsd-src/gnu/gcc/gcc/config/mcore/mcore-elf.h (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1 /* Definitions of MCore target.
2    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004
3    Free Software Foundation, Inc.
4    Contributed by Cygnus Solutions.
5 
6 This file is part of GCC.
7 
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12 
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.  */
22 
23 #ifndef __MCORE_ELF_H__
24 #define __MCORE_ELF_H__
25 
26 /* Run-time Target Specification.  */
27 #define TARGET_VERSION fputs (" (Motorola MCORE/elf)", stderr)
28 
29 /* Use DWARF2 debugging info.  */
30 #define DWARF2_DEBUGGING_INFO 1
31 
32 #undef  PREFERRED_DEBUGGING_TYPE
33 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
34 
35 #define MCORE_EXPORT_NAME(STREAM, NAME)			\
36   do							\
37     {							\
38       fprintf (STREAM, "\t.section .exports\n");	\
39       fprintf (STREAM, "\t.ascii \" -export:%s\"\n",	\
40 	       (* targetm.strip_name_encoding) (NAME));	\
41       in_section = NULL;				\
42     }							\
43   while (0);
44 
45 /* Write the extra assembler code needed to declare a function properly.
46    Some svr4 assemblers need to also have something extra said about the
47    function's return value.  We allow for that here.  */
48 #undef  ASM_DECLARE_FUNCTION_NAME
49 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)		\
50   do								\
51     {								\
52       if (mcore_dllexport_name_p (NAME))			\
53 	{							\
54           MCORE_EXPORT_NAME (FILE, NAME);			\
55 	  switch_to_section (function_section (DECL));		\
56 	}							\
57       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");	\
58       ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));		\
59       ASM_OUTPUT_LABEL (FILE, NAME);				\
60     }								\
61   while (0)
62 
63 /* Write the extra assembler code needed to declare an object properly.  */
64 #undef  ASM_DECLARE_OBJECT_NAME
65 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
66   do								\
67     {								\
68       HOST_WIDE_INT size;					\
69       if (mcore_dllexport_name_p (NAME))			\
70         {							\
71 	  section *save_section = in_section;			\
72 	  MCORE_EXPORT_NAME (FILE, NAME);			\
73 	  switch_to_section (save_section);			\
74         }							\
75       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");		\
76       size_directive_output = 0;				\
77       if (!flag_inhibit_size_directive && DECL_SIZE (DECL))	\
78         {							\
79           size_directive_output = 1;				\
80 	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
81 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
82         }							\
83       ASM_OUTPUT_LABEL(FILE, NAME);				\
84     }								\
85   while (0)
86 
87 /* Output the size directive for a decl in rest_of_decl_compilation
88    in the case where we did not do so before the initializer.
89    Once we find the error_mark_node, we know that the value of
90    size_directive_output was set
91    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
92 #undef  ASM_FINISH_DECLARE_OBJECT
93 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)         \
94   do                                                                     \
95     {                                                                    \
96       const char * name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);           \
97       HOST_WIDE_INT size;						 \
98       if (!flag_inhibit_size_directive && DECL_SIZE (DECL)               \
99           && ! AT_END && TOP_LEVEL                                       \
100           && DECL_INITIAL (DECL) == error_mark_node                      \
101           && !size_directive_output)                                     \
102         {                                                                \
103 	  size_directive_output = 1;					 \
104 	  size = int_size_in_bytes (TREE_TYPE (DECL));			 \
105 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size);			 \
106         }                                                                \
107     }                                                                    \
108   while (0)
109 
110 
111 #undef  STARTFILE_SPEC
112 #define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
113 
114 /* Include the OS stub library, so that the code can be simulated.
115    This is not the right way to do this.  Ideally this kind of thing
116    should be done in the linker script - but I have not worked out how
117    to specify the location of a linker script in a gcc command line yet.  */
118 #undef  ENDFILE_SPEC
119 #define ENDFILE_SPEC  "%{!mno-lsim:-lsim} crtend.o%s crtn.o%s"
120 
121 /* The subroutine calls in the .init and .fini sections create literal
122    pools which must be jumped around....  */
123 #define FORCE_CODE_SECTION_ALIGN	asm ("br 1f ; .literals ; 1:");
124 
125 #undef  CTORS_SECTION_ASM_OP
126 #define CTORS_SECTION_ASM_OP	"\t.section\t.ctors,\"aw\""
127 #undef  DTORS_SECTION_ASM_OP
128 #define DTORS_SECTION_ASM_OP	"\t.section\t.dtors,\"aw\""
129 
130 #endif /* __MCORE_ELF_H__ */
131