OSDN Git Service

2001-05-17 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / linux.h
1 /* Definitions of target machine for GNU compiler,
2    for IBM RS/6000 running AIX version 3.1.
3    Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4    Contributed by Michael Meissner (meissner@cygnus.com).
5
6 This file is part of GNU CC.
7
8 GNU CC 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 GNU CC 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 GNU CC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 /* Don't assume anything about the header files. */
24 #define NO_IMPLICIT_EXTERN_C
25
26 #undef MD_EXEC_PREFIX
27 #undef MD_STARTFILE_PREFIX
28
29 #undef CPP_PREDEFINES
30 #define CPP_PREDEFINES \
31  "-DPPC -D__ELF__ -Dpowerpc -Acpu=powerpc -Amachine=powerpc"
32
33 #undef  CPP_OS_DEFAULT_SPEC
34 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
35
36 #undef LINK_SHLIB_SPEC
37 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
38
39 #undef  LIB_DEFAULT_SPEC
40 #define LIB_DEFAULT_SPEC "%(lib_linux)"
41
42 #undef  STARTFILE_DEFAULT_SPEC
43 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
44
45 #undef  ENDFILE_DEFAULT_SPEC
46 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
47
48 #undef  LINK_START_DEFAULT_SPEC
49 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
50
51 #undef  LINK_OS_DEFAULT_SPEC
52 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
53
54 #undef TARGET_VERSION
55 #define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
56
57 /* Override rs6000.h definition.  */
58 #undef ASM_APP_ON
59 #define ASM_APP_ON "#APP\n"
60
61 /* Override rs6000.h definition.  */
62 #undef ASM_APP_OFF
63 #define ASM_APP_OFF "#NO_APP\n"
64
65 #undef DEFAULT_VTABLE_THUNKS
66 #ifndef USE_GNULIBC_1
67 #define DEFAULT_VTABLE_THUNKS 1
68 #endif
69
70 /* Do code reading to identify a signal frame, and set the frame
71    state data appropriately.  See unwind-dw2.c for the structs.  */
72
73 #ifdef IN_LIBGCC2
74 #include <signal.h>
75 #include <sys/ucontext.h>
76 #endif
77
78 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)               \
79   do {                                                                  \
80     unsigned char *pc_ = (CONTEXT)->ra;                                 \
81     struct sigcontext *sc_;                                             \
82     long new_cfa_;                                                      \
83     int i_;                                                             \
84                                                                         \
85     /* li r0, 0x7777; sc  (rt_sigreturn)  */                            \
86     /* li r0, 0x6666; sc  (sigreturn)  */                               \
87     if (((*(unsigned int *) (pc_+0) == 0x38007777)                      \
88          || (*(unsigned int *) (pc_+0) == 0x38006666))                  \
89         && (*(unsigned int *) (pc_+4)  == 0x44000002))                  \
90         sc_ = (CONTEXT)->cfa + __SIGNAL_FRAMESIZE;                      \
91     else                                                                \
92       break;                                                            \
93                                                                         \
94     new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM];                    \
95     (FS)->cfa_how = CFA_REG_OFFSET;                                     \
96     (FS)->cfa_reg = STACK_POINTER_REGNUM;                               \
97     (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;                \
98                                                                         \
99     for (i_ = 0; i_ < 32; i_++)                                         \
100       if (i_ != STACK_POINTER_REGNUM)                                   \
101         {                                                               \
102           (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;                    \
103           (FS)->regs.reg[i_].loc.offset                                 \
104             = (long)&(sc_->regs->gpr[i_]) - new_cfa_;                   \
105         }                                                               \
106                                                                         \
107     (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET;        \
108     (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset                     \
109       = (long)&(sc_->regs->link) - new_cfa_;                            \
110                                                                         \
111     /* The unwinder expects the IP to point to the following insn,      \
112        whereas the kernel returns the address of the actual             \
113        faulting insn.  */                                               \
114     sc_->regs->nip += 4;                                                \
115     (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET;                   \
116     (FS)->regs.reg[CR0_REGNO].loc.offset                                \
117       = (long)&(sc_->regs->nip) - new_cfa_;                             \
118     (FS)->retaddr_column = CR0_REGNO;                                   \
119     goto SUCCESS;                                                       \
120   } while (0)
121