1 /* Definitions of target machine for GNU compiler,
2 for PowerPC machines running Linux.
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 Free Software Foundation, Inc.
5 Contributed by Michael Meissner (meissner@cygnus.com).
7 This file is part of GCC.
9 GCC is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 2, or (at your
12 option) any later version.
14 GCC is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING. If not, write to the
21 Free Software Foundation, 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA. */
25 #undef MD_STARTFILE_PREFIX
27 #undef TARGET_OS_CPP_BUILTINS
28 #define TARGET_OS_CPP_BUILTINS() \
31 builtin_define_std ("PPC"); \
32 builtin_define_std ("powerpc"); \
33 builtin_assert ("cpu=powerpc"); \
34 builtin_assert ("machine=powerpc"); \
35 TARGET_OS_SYSV_CPP_BUILTINS (); \
39 #undef CPP_OS_DEFAULT_SPEC
40 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
42 /* The GNU C++ standard library currently requires _GNU_SOURCE being
43 defined on glibc-based systems. This temporary hack accomplishes this,
44 it should go away as soon as libstdc++-v3 has a real fix. */
45 #undef CPLUSPLUS_CPP_SPEC
46 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
48 #undef LINK_SHLIB_SPEC
49 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
51 #undef LIB_DEFAULT_SPEC
52 #define LIB_DEFAULT_SPEC "%(lib_linux)"
54 #undef STARTFILE_DEFAULT_SPEC
55 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
57 #undef ENDFILE_DEFAULT_SPEC
58 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
60 #undef LINK_START_DEFAULT_SPEC
61 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
63 #undef LINK_OS_DEFAULT_SPEC
64 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
66 #define LINK_GCC_C_SEQUENCE_SPEC \
67 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
70 #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
72 /* Override rs6000.h definition. */
74 #define ASM_APP_ON "#APP\n"
76 /* Override rs6000.h definition. */
78 #define ASM_APP_OFF "#NO_APP\n"
80 /* For backward compatibility, we must continue to use the AIX
81 structure return convention. */
82 #undef DRAFT_V4_STRUCT_RET
83 #define DRAFT_V4_STRUCT_RET 1
85 /* We are 32-bit all the time, so optimize a little. */
87 #define TARGET_64BIT 0
89 /* We don't need to generate entries in .fixup. */
90 #undef RELOCATABLE_NEEDS_FIXUP
92 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
94 #define TARGET_HAS_F_SETLKW
96 /* Do code reading to identify a signal frame, and set the frame
97 state data appropriately. See unwind-dw2.c for the structs. */
102 /* During the 2.5 kernel series the kernel ucontext was changed, but
103 the new layout is compatible with the old one, so we just define
104 and use the old one here for simplicity and compatibility. */
106 struct kernel_old_ucontext
{
107 unsigned long uc_flags
;
108 struct ucontext
*uc_link
;
110 struct sigcontext_struct uc_mcontext
;
114 enum { SIGNAL_FRAMESIZE
= 64 };
117 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
119 unsigned char *pc_ = (CONTEXT)->ra; \
120 struct sigcontext *sc_; \
124 /* li r0, 0x7777; sc (sigreturn old) */ \
125 /* li r0, 0x0077; sc (sigreturn new) */ \
126 /* li r0, 0x6666; sc (rt_sigreturn old) */ \
127 /* li r0, 0x00AC; sc (rt_sigreturn new) */ \
128 if (*(unsigned int *) (pc_+4) != 0x44000002) \
130 if (*(unsigned int *) (pc_+0) == 0x38007777 \
131 || *(unsigned int *) (pc_+0) == 0x38000077) \
134 char gap[SIGNAL_FRAMESIZE]; \
135 struct sigcontext sigctx; \
136 } *rt_ = (CONTEXT)->cfa; \
137 sc_ = &rt_->sigctx; \
139 else if (*(unsigned int *) (pc_+0) == 0x38006666 \
140 || *(unsigned int *) (pc_+0) == 0x380000AC) \
142 struct rt_sigframe { \
143 char gap[SIGNAL_FRAMESIZE]; \
144 unsigned long _unused[2]; \
145 struct siginfo *pinfo; \
147 struct siginfo info; \
148 struct kernel_old_ucontext uc; \
149 } *rt_ = (CONTEXT)->cfa; \
150 sc_ = &rt_->uc.uc_mcontext; \
155 new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \
156 (FS)->cfa_how = CFA_REG_OFFSET; \
157 (FS)->cfa_reg = STACK_POINTER_REGNUM; \
158 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
160 for (i_ = 0; i_ < 32; i_++) \
161 if (i_ != STACK_POINTER_REGNUM) \
163 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
164 (FS)->regs.reg[i_].loc.offset \
165 = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \
168 (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \
169 (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \
170 = (long)&(sc_->regs->link) - new_cfa_; \
172 (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \
173 (FS)->regs.reg[CR0_REGNO].loc.offset \
174 = (long)&(sc_->regs->nip) - new_cfa_; \
175 (FS)->retaddr_column = CR0_REGNO; \
180 #define OS_MISSING_POWERPC64 1