linux.h revision 90075
1/* Definitions of target machine for GNU compiler,
2   for powerpc machines running Linux.
3   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation,
4   Inc.
5   Contributed by Michael Meissner (meissner@cygnus.com).
6
7This file is part of GNU CC.
8
9GNU CC is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GNU CC is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU CC; see the file COPYING.  If not, write to
21the Free Software Foundation, 59 Temple Place - Suite 330,
22Boston, MA 02111-1307, USA.  */
23
24/* Don't assume anything about the header files.  */
25#define NO_IMPLICIT_EXTERN_C
26
27#undef MD_EXEC_PREFIX
28#undef MD_STARTFILE_PREFIX
29
30#undef CPP_PREDEFINES
31#define CPP_PREDEFINES \
32 "-DPPC -D__ELF__ -Dpowerpc -Acpu=powerpc -Amachine=powerpc"
33
34#undef	CPP_OS_DEFAULT_SPEC
35#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
36
37/* The GNU C++ standard library currently requires _GNU_SOURCE being
38   defined on glibc-based systems. This temporary hack accomplishes this,
39   it should go away as soon as libstdc++-v3 has a real fix.  */
40#undef CPLUSPLUS_CPP_SPEC
41#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
42
43#undef LINK_SHLIB_SPEC
44#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
45
46#undef	LIB_DEFAULT_SPEC
47#define LIB_DEFAULT_SPEC "%(lib_linux)"
48
49#undef	STARTFILE_DEFAULT_SPEC
50#define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
51
52#undef	ENDFILE_DEFAULT_SPEC
53#define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
54
55#undef	LINK_START_DEFAULT_SPEC
56#define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
57
58#undef	LINK_OS_DEFAULT_SPEC
59#define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
60
61#undef TARGET_VERSION
62#define TARGET_VERSION fprintf (stderr, " (PowerPC GNU/Linux)");
63
64/* Override rs6000.h definition.  */
65#undef ASM_APP_ON
66#define ASM_APP_ON "#APP\n"
67
68/* Override rs6000.h definition.  */
69#undef ASM_APP_OFF
70#define ASM_APP_OFF "#NO_APP\n"
71
72/* For backward compatibility, we must continue to use the AIX
73   structure return convention.  */
74#undef DRAFT_V4_STRUCT_RET
75#define DRAFT_V4_STRUCT_RET 1
76
77/* Do code reading to identify a signal frame, and set the frame
78   state data appropriately.  See unwind-dw2.c for the structs.  */
79
80#ifdef IN_LIBGCC2
81#include <signal.h>
82#include <sys/ucontext.h>
83
84enum { SIGNAL_FRAMESIZE = 64 };
85#endif
86
87#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)		\
88  do {									\
89    unsigned char *pc_ = (CONTEXT)->ra;					\
90    struct sigcontext *sc_;						\
91    long new_cfa_;							\
92    int i_;								\
93									\
94    /* li r0, 0x7777; sc  (rt_sigreturn)  */				\
95    /* li r0, 0x6666; sc  (sigreturn)  */				\
96    if (((*(unsigned int *) (pc_+0) == 0x38007777)			\
97	 || (*(unsigned int *) (pc_+0) == 0x38006666))			\
98	&& (*(unsigned int *) (pc_+4)  == 0x44000002))			\
99	sc_ = (CONTEXT)->cfa + SIGNAL_FRAMESIZE;			\
100    else								\
101      break;								\
102    									\
103    new_cfa_ = sc_->regs->gpr[STACK_POINTER_REGNUM];			\
104    (FS)->cfa_how = CFA_REG_OFFSET;					\
105    (FS)->cfa_reg = STACK_POINTER_REGNUM;				\
106    (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa;		\
107    									\
108    for (i_ = 0; i_ < 32; i_++)						\
109      if (i_ != STACK_POINTER_REGNUM)					\
110	{	    							\
111	  (FS)->regs.reg[i_].how = REG_SAVED_OFFSET;			\
112	  (FS)->regs.reg[i_].loc.offset 				\
113	    = (long)&(sc_->regs->gpr[i_]) - new_cfa_;			\
114	}								\
115									\
116    (FS)->regs.reg[LINK_REGISTER_REGNUM].how = REG_SAVED_OFFSET;	\
117    (FS)->regs.reg[LINK_REGISTER_REGNUM].loc.offset 			\
118      = (long)&(sc_->regs->link) - new_cfa_;				\
119									\
120    /* The unwinder expects the IP to point to the following insn,	\
121       whereas the kernel returns the address of the actual		\
122       faulting insn.  */						\
123    sc_->regs->nip += 4;  						\
124    (FS)->regs.reg[CR0_REGNO].how = REG_SAVED_OFFSET;			\
125    (FS)->regs.reg[CR0_REGNO].loc.offset 				\
126      = (long)&(sc_->regs->nip) - new_cfa_;				\
127    (FS)->retaddr_column = CR0_REGNO;					\
128    goto SUCCESS;							\
129  } while (0)
130
131