OSDN Git Service

* config/i386/i386.c (internal_label_prefix): Export.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / linux.h
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).
6
7    This file is part of GCC.
8
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.
13
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.
18
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.  */
23
24 #undef MD_EXEC_PREFIX
25 #undef MD_STARTFILE_PREFIX
26
27 #undef  TARGET_OS_CPP_BUILTINS
28 #define TARGET_OS_CPP_BUILTINS()          \
29   do                                      \
30     {                                     \
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 ();     \
36     }                                     \
37   while (0)
38
39 #undef  CPP_OS_DEFAULT_SPEC
40 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
41
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
48 #undef  LINK_SHLIB_SPEC
49 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
50
51 #undef  LIB_DEFAULT_SPEC
52 #define LIB_DEFAULT_SPEC "%(lib_linux)"
53
54 #undef  STARTFILE_DEFAULT_SPEC
55 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
56
57 #undef  ENDFILE_DEFAULT_SPEC
58 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
59
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
66 #define LINK_GCC_C_SEQUENCE_SPEC \
67   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
68
69 /* Use --as-needed -lgcc_s for eh support.  */
70 #ifdef HAVE_LD_AS_NEEDED
71 #define USE_LD_AS_NEEDED 1
72 #endif
73
74 #undef  TARGET_VERSION
75 #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
76
77 /* Override rs6000.h definition.  */
78 #undef  ASM_APP_ON
79 #define ASM_APP_ON "#APP\n"
80
81 /* Override rs6000.h definition.  */
82 #undef  ASM_APP_OFF
83 #define ASM_APP_OFF "#NO_APP\n"
84
85 /* For backward compatibility, we must continue to use the AIX
86    structure return convention.  */
87 #undef  DRAFT_V4_STRUCT_RET
88 #define DRAFT_V4_STRUCT_RET 1
89
90 /* We are 32-bit all the time, so optimize a little.  */
91 #undef TARGET_64BIT
92 #define TARGET_64BIT 0
93  
94 /* We don't need to generate entries in .fixup.  */
95 #undef RELOCATABLE_NEEDS_FIXUP
96
97 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
98
99 #define TARGET_HAS_F_SETLKW
100
101 /* Do code reading to identify a signal frame, and set the frame
102    state data appropriately.  See unwind-dw2.c for the structs.  */
103
104 #ifdef IN_LIBGCC2
105 #include <signal.h>
106
107 /* During the 2.5 kernel series the kernel ucontext was changed, but
108    the new layout is compatible with the old one, so we just define
109    and use the old one here for simplicity and compatibility.  */
110
111 struct kernel_old_ucontext {
112   unsigned long     uc_flags;
113   struct ucontext  *uc_link;
114   stack_t           uc_stack;
115   struct sigcontext_struct uc_mcontext;
116   sigset_t          uc_sigmask;
117 };
118
119 enum { SIGNAL_FRAMESIZE = 64 };
120 #endif
121
122 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
123   do {                                                                  \
124     unsigned char *pc_ = (CONTEXT)->ra;                                 \
125     struct sigcontext *sc_;                                             \
126     long new_cfa_;                                                      \
127     int i_;                                                             \
128                                                                         \
129     /* li r0, 0x7777; sc  (sigreturn old)  */                           \
130     /* li r0, 0x0077; sc  (sigreturn new)  */                           \
131     /* li r0, 0x6666; sc  (rt_sigreturn old)  */                        \
132     /* li r0, 0x00AC; sc  (rt_sigreturn new)  */                        \
133     if (*(unsigned int *) (pc_+4) != 0x44000002)                        \
134       break;                                                            \
135     if (*(unsigned int *) (pc_+0) == 0x38007777                         \
136         || *(unsigned int *) (pc_+0) == 0x38000077)                     \
137       {                                                                 \
138         struct sigframe {                                               \
139           char gap[SIGNAL_FRAMESIZE];                                   \
140           struct sigcontext sigctx;                                     \
141         } *rt_ = (CONTEXT)->cfa;                                        \
142         sc_ = &rt_->sigctx;                                             \
143       }                                                                 \
144     else if (*(unsigned int *) (pc_+0) == 0x38006666                    \
145              || *(unsigned int *) (pc_+0) == 0x380000AC)                \
146       {                                                                 \
147         struct rt_sigframe {                                            \
148           char gap[SIGNAL_FRAMESIZE];                                   \
149           unsigned long _unused[2];                                     \
150           struct siginfo *pinfo;                                        \
151           void *puc;                                                    \
152           struct siginfo info;                                          \
153           struct kernel_old_ucontext uc;                                \
154         } *rt_ = (CONTEXT)->cfa;                                        \
155         sc_ = &rt_->uc.uc_mcontext;                                     \
156       }                                                                 \
157     else                                                                \
158       break;                                                            \
159                                                                         \
160     new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM];                    \
161     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
162     (FS)->cfa_reg = STACK_POINTER_REGNUM;                               \
163     (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;                \
164                                                                         \
165     for (i_ = 0; i_ < 32; i_++)                                         \
166       if (i_ != STACK_POINTER_REGNUM)                                   \
167         {                                                               \
168           (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                    \
169           (FS)->regs.reg[i_].loc.offset                                 \
170             = (long)&(sc_->regs->gpr[i_]) - new_cfa_;                   \
171         }                                                               \
172                                                                         \
173     (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET;        \
174     (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset                     \
175       = (long)&(sc_->regs->link) - new_cfa_;                            \
176                                                                         \
177     (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET;                   \
178     (FS)->regs.reg[CR0_REGNO].loc.offset                                \
179       = (long)&(sc_->regs->nip) - new_cfa_;                             \
180     (FS)->retaddr_column = CR0_REGNO;                                   \
181     goto SUCCESS;                                                       \
182   } while (0)
183
184
185 #define OS_MISSING_POWERPC64 1