]>
Commit | Line | Data |
---|---|---|
9a57586f | 1 | /* Definitions of target machine for GNU compiler, |
88cad84b | 2 | for PowerPC machines running Linux. |
c4db7ecb FS |
3 | Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 |
4 | Free Software Foundation, Inc. | |
9a57586f MM |
5 | Contributed by Michael Meissner (meissner@cygnus.com). |
6 | ||
7 | This file is part of GNU CC. | |
8 | ||
9 | GNU CC is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2, or (at your option) | |
12 | any later version. | |
13 | ||
14 | GNU CC is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GNU CC; see the file COPYING. If not, write to | |
5f38fdda JL |
21 | the Free Software Foundation, 59 Temple Place - Suite 330, |
22 | Boston, MA 02111-1307, USA. */ | |
9a57586f | 23 | |
bd227acc FS |
24 | #undef MD_EXEC_PREFIX |
25 | #undef MD_STARTFILE_PREFIX | |
26 | ||
7990b46f MK |
27 | #undef TARGET_OS_CPP_BUILTINS |
28 | #define TARGET_OS_CPP_BUILTINS() \ | |
29 | do \ | |
30 | { \ | |
31 | builtin_define_std ("PPC"); \ | |
32 | builtin_define ("__ELF__"); \ | |
33 | builtin_define_std ("powerpc"); \ | |
34 | builtin_assert ("cpu=powerpc"); \ | |
35 | builtin_assert ("machine=powerpc"); \ | |
36 | } \ | |
37 | while (0) | |
9a57586f | 38 | |
373107aa FS |
39 | #undef CPP_OS_DEFAULT_SPEC |
40 | #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" | |
41 | ||
437558e8 FS |
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)" | |
47 | ||
362c63a5 GK |
48 | #undef LINK_SHLIB_SPEC |
49 | #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}" | |
9a57586f MM |
50 | |
51 | #undef LIB_DEFAULT_SPEC | |
0bc25b2b | 52 | #define LIB_DEFAULT_SPEC "%(lib_linux)" |
9a57586f MM |
53 | |
54 | #undef STARTFILE_DEFAULT_SPEC | |
0bc25b2b | 55 | #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)" |
9a57586f MM |
56 | |
57 | #undef ENDFILE_DEFAULT_SPEC | |
0bc25b2b | 58 | #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)" |
9a57586f | 59 | |
362c63a5 GK |
60 | #undef LINK_START_DEFAULT_SPEC |
61 | #define LINK_START_DEFAULT_SPEC "%(link_start_linux)" | |
62 | ||
63 | #undef LINK_OS_DEFAULT_SPEC | |
64 | #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" | |
65 | ||
9a57586f | 66 | #undef TARGET_VERSION |
956d6950 | 67 | #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)"); |
3807773b | 68 | |
832ea3b3 FS |
69 | /* Override rs6000.h definition. */ |
70 | #undef ASM_APP_ON | |
71 | #define ASM_APP_ON "#APP\n" | |
72 | ||
73 | /* Override rs6000.h definition. */ | |
74 | #undef ASM_APP_OFF | |
75 | #define ASM_APP_OFF "#NO_APP\n" | |
76 | ||
6fa3f289 ZW |
77 | /* For backward compatibility, we must continue to use the AIX |
78 | structure return convention. */ | |
79 | #undef DRAFT_V4_STRUCT_RET | |
80 | #define DRAFT_V4_STRUCT_RET 1 | |
81 | ||
da502956 AH |
82 | /* Do code reading to identify a signal frame, and set the frame |
83 | state data appropriately. See unwind-dw2.c for the structs. */ | |
84 | ||
85 | #ifdef IN_LIBGCC2 | |
86 | #include <signal.h> | |
87 | #include <sys/ucontext.h> | |
a0a843c7 GK |
88 | |
89 | enum { SIGNAL_FRAMESIZE = 64 }; | |
da502956 AH |
90 | #endif |
91 | ||
92 | #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \ | |
93 | do { \ | |
94 | unsigned char *pc_ = (CONTEXT)->ra; \ | |
95 | struct sigcontext *sc_; \ | |
96 | long new_cfa_; \ | |
97 | int i_; \ | |
98 | \ | |
c4db7ecb FS |
99 | /* li r0, 0x7777; sc (sigreturn old) */ \ |
100 | /* li r0, 0x0077; sc (sigreturn new) */ \ | |
101 | /* li r0, 0x6666; sc (rt_sigreturn old) */ \ | |
102 | /* li r0, 0x00AC; sc (rt_sigreturn new) */ \ | |
103 | if (*(unsigned int *) (pc_+4) != 0x44000002) \ | |
104 | break; \ | |
105 | if (*(unsigned int *) (pc_+0) == 0x38007777 \ | |
106 | || *(unsigned int *) (pc_+0) == 0x38000077) \ | |
107 | { \ | |
108 | struct sigframe { \ | |
109 | char gap[SIGNAL_FRAMESIZE]; \ | |
110 | struct sigcontext sigctx; \ | |
111 | } *rt_ = (CONTEXT)->cfa; \ | |
112 | sc_ = &rt_->sigctx; \ | |
113 | } \ | |
114 | else if (*(unsigned int *) (pc_+0) == 0x38006666 \ | |
115 | || *(unsigned int *) (pc_+0) == 0x380000AC) \ | |
116 | { \ | |
117 | struct rt_sigframe { \ | |
118 | char gap[SIGNAL_FRAMESIZE]; \ | |
119 | unsigned long _unused[2]; \ | |
120 | struct siginfo *pinfo; \ | |
121 | void *puc; \ | |
122 | struct siginfo info; \ | |
123 | struct ucontext uc; \ | |
124 | } *rt_ = (CONTEXT)->cfa; \ | |
125 | sc_ = &rt_->uc.uc_mcontext; \ | |
126 | } \ | |
da502956 AH |
127 | else \ |
128 | break; \ | |
129 | \ | |
130 | new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM]; \ | |
131 | (FS)->cfa_how = CFA_REG_OFFSET; \ | |
132 | (FS)->cfa_reg = STACK_POINTER_REGNUM; \ | |
133 | (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \ | |
134 | \ | |
135 | for (i_ = 0; i_ < 32; i_++) \ | |
136 | if (i_ != STACK_POINTER_REGNUM) \ | |
137 | { \ | |
138 | (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \ | |
139 | (FS)->regs.reg[i_].loc.offset \ | |
140 | = (long)&(sc_->regs->gpr[i_]) - new_cfa_; \ | |
141 | } \ | |
142 | \ | |
143 | (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET; \ | |
144 | (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset \ | |
145 | = (long)&(sc_->regs->link) - new_cfa_; \ | |
146 | \ | |
147 | /* The unwinder expects the IP to point to the following insn, \ | |
148 | whereas the kernel returns the address of the actual \ | |
c4db7ecb FS |
149 | faulting insn. We store NIP+4 in an unused register slot to \ |
150 | get the same result for multiple evaluation of the same signal \ | |
151 | frame. */ \ | |
152 | sc_->regs->gpr[47] = sc_->regs->nip + 4; \ | |
da502956 AH |
153 | (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET; \ |
154 | (FS)->regs.reg[CR0_REGNO].loc.offset \ | |
c4db7ecb | 155 | = (long)&(sc_->regs->gpr[47]) - new_cfa_; \ |
da502956 AH |
156 | (FS)->retaddr_column = CR0_REGNO; \ |
157 | goto SUCCESS; \ | |
158 | } while (0) | |
159 |