summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/config/ia64/linux.h
blob: 5c73b0c25ef40ef8a9e6d81093ad1782ced5bbf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/* Definitions for ia64-linux target.  */

/* This macro is a C statement to print on `stderr' a string describing the
   particular machine description choice.  */

#define TARGET_VERSION fprintf (stderr, " (IA-64) Linux");

/* This is for -profile to use -lc_p instead of -lc.  */
#undef CC1_SPEC
#define CC1_SPEC "%{profile:-p} %{G*}"

/* Target OS builtins.  */
#define TARGET_OS_CPP_BUILTINS()		\
do {						\
	LINUX_TARGET_OS_CPP_BUILTINS();		\
	builtin_define("_LONGLONG");		\
} while (0)

/* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in.  */
#undef STARTFILE_SPEC
#ifdef HAVE_LD_PIE
#define STARTFILE_SPEC \
  "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
   crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
#else
#define STARTFILE_SPEC \
  "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}}\
   crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
#endif

/* Similar to standard Linux, but adding -ffast-math support.  */
#undef  ENDFILE_SPEC
#define ENDFILE_SPEC \
  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"

/* Define this for shared library support because it isn't in the main
   linux.h file.  */

#undef LINK_SPEC
#define LINK_SPEC "\
  %{shared:-shared} \
  %{!shared: \
    %{!static: \
      %{rdynamic:-export-dynamic} \
      %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \
      %{static:-static}}"


#define JMP_BUF_SIZE  76

/* Override linux.h LINK_EH_SPEC definition.
   Signalize that because we have fde-glibc, we don't need all C shared libs
   linked against -lgcc_s.  */
#undef LINK_EH_SPEC
#define LINK_EH_SPEC ""

/* Do code reading to identify a signal frame, and set the frame
   state data appropriately.  See unwind-dw2.c for the structs.  */

/* This works only for glibc-2.3 and later, because sigcontext is different
   in glibc-2.2.4.  */

#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)

#ifdef IN_LIBGCC2
#include <signal.h>
#include <sys/ucontext.h>

#define IA64_GATE_AREA_START 0xa000000000000100LL
#define IA64_GATE_AREA_END   0xa000000000030000LL

#define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS)		\
  if ((CONTEXT)->rp >= IA64_GATE_AREA_START				\
      && (CONTEXT)->rp < IA64_GATE_AREA_END)				\
    {									\
      struct sigframe {							\
	char scratch[16];						\
	unsigned long sig_number;					\
	struct siginfo *info;						\
	struct sigcontext *sc;						\
      } *frame_ = (struct sigframe *)(CONTEXT)->psp;			\
      struct sigcontext *sc_ = frame_->sc;				\
									\
      /* Restore scratch registers in case the unwinder needs to	\
	 refer to a value stored in one of them.  */			\
      {									\
	int i_;								\
									\
	for (i_ = 2; i_ < 4; i_++)					\
	  (CONTEXT)->ireg[i_ - 2].loc = &sc_->sc_gr[i_];		\
	for (i_ = 8; i_ < 12; i_++)					\
	  (CONTEXT)->ireg[i_ - 2].loc = &sc_->sc_gr[i_];		\
	for (i_ = 14; i_ < 32; i_++)					\
	  (CONTEXT)->ireg[i_ - 2].loc = &sc_->sc_gr[i_];		\
      }									\
	  								\
      (CONTEXT)->fpsr_loc = &(sc_->sc_ar_fpsr);				\
      (CONTEXT)->pfs_loc = &(sc_->sc_ar_pfs);				\
      (CONTEXT)->lc_loc = &(sc_->sc_ar_lc);				\
      (CONTEXT)->unat_loc = &(sc_->sc_ar_unat);				\
      (CONTEXT)->br_loc[0] = &(sc_->sc_br[0]);				\
      (CONTEXT)->br_loc[6] = &(sc_->sc_br[6]);				\
      (CONTEXT)->br_loc[7] = &(sc_->sc_br[7]);				\
      (CONTEXT)->pr = sc_->sc_pr;					\
      (CONTEXT)->psp = sc_->sc_gr[12];					\
      (CONTEXT)->gp = sc_->sc_gr[1];					\
      /* Signal frame doesn't have an associated reg. stack frame 	\
         other than what we adjust for below.	  */			\
      (FS) -> no_reg_stack_frame = 1;					\
									\
      if (sc_->sc_rbs_base)						\
	{								\
	  /* Need to switch from alternate register backing store.  */	\
	  long ndirty, loadrs = sc_->sc_loadrs >> 16;			\
	  unsigned long alt_bspstore = (CONTEXT)->bsp - loadrs;		\
	  unsigned long bspstore;					\
	  unsigned long *ar_bsp = (unsigned long *)(sc_->sc_ar_bsp);	\
									\
	  ndirty = ia64_rse_num_regs ((unsigned long *) alt_bspstore,	\
				      (unsigned long *) (CONTEXT)->bsp);\
	  bspstore = (unsigned long)					\
		     ia64_rse_skip_regs (ar_bsp, -ndirty);		\
	  ia64_copy_rbs ((CONTEXT), bspstore, alt_bspstore, loadrs,	\
			 sc_->sc_ar_rnat);				\
	}								\
									\
      /* Don't touch the branch registers o.t. b0, b6 and b7.		\
	 The kernel doesn't pass the preserved branch registers		\
	 in the sigcontext but leaves them intact, so there's no	\
	 need to do anything with them here.  */			\
      {									\
	unsigned long sof = sc_->sc_cfm & 0x7f;				\
	(CONTEXT)->bsp = (unsigned long)				\
	  ia64_rse_skip_regs ((unsigned long *)(sc_->sc_ar_bsp), -sof); \
      }									\
									\
      (FS)->curr.reg[UNW_REG_RP].where = UNW_WHERE_SPREL;		\
      (FS)->curr.reg[UNW_REG_RP].val 					\
	= (unsigned long)&(sc_->sc_ip) - (CONTEXT)->psp;		\
      (FS)->curr.reg[UNW_REG_RP].when = -1;				\
									\
      goto SUCCESS;							\
    }

#define MD_HANDLE_UNWABI(CONTEXT, FS)					\
  if ((FS)->unwabi == ((3 << 8) | 's')					\
      || (FS)->unwabi == ((0 << 8) | 's'))				\
    {									\
      struct sigframe {							\
	char scratch[16];						\
	unsigned long sig_number;					\
	struct siginfo *info;						\
	struct sigcontext *sc;						\
      } *frame_ = (struct sigframe *)(CONTEXT)->psp;			\
      struct sigcontext *sc_ = frame_->sc;				\
									\
      /* Restore scratch registers in case the unwinder needs to	\
	 refer to a value stored in one of them.  */			\
      {									\
	int i_;								\
									\
	for (i_ = 2; i_ < 4; i_++)					\
	  (CONTEXT)->ireg[i_ - 2].loc = &sc_->sc_gr[i_];		\
	for (i_ = 8; i_ < 12; i_++)					\
	  (CONTEXT)->ireg[i_ - 2].loc = &sc_->sc_gr[i_];		\
	for (i_ = 14; i_ < 32; i_++)					\
	  (CONTEXT)->ireg[i_ - 2].loc = &sc_->sc_gr[i_];		\
      }									\
	  								\
      (CONTEXT)->pfs_loc = &(sc_->sc_ar_pfs);				\
      (CONTEXT)->lc_loc = &(sc_->sc_ar_lc);				\
      (CONTEXT)->unat_loc = &(sc_->sc_ar_unat);				\
      (CONTEXT)->br_loc[0] = &(sc_->sc_br[0]);				\
      (CONTEXT)->br_loc[6] = &(sc_->sc_br[6]);				\
      (CONTEXT)->br_loc[7] = &(sc_->sc_br[7]);				\
      (CONTEXT)->pr = sc_->sc_pr;					\
      (CONTEXT)->gp = sc_->sc_gr[1];					\
      /* Signal frame doesn't have an associated reg. stack frame 	\
         other than what we adjust for below.	  */			\
      (FS) -> no_reg_stack_frame = 1;					\
									\
      if (sc_->sc_rbs_base)						\
	{								\
	  /* Need to switch from alternate register backing store.  */	\
	  long ndirty, loadrs = sc_->sc_loadrs >> 16;			\
	  unsigned long alt_bspstore = (CONTEXT)->bsp - loadrs;		\
	  unsigned long bspstore;					\
	  unsigned long *ar_bsp = (unsigned long *)(sc_->sc_ar_bsp);	\
									\
	  ndirty = ia64_rse_num_regs ((unsigned long *) alt_bspstore,	\
				      (unsigned long *) (CONTEXT)->bsp);\
	  bspstore = (unsigned long)					\
		     ia64_rse_skip_regs (ar_bsp, -ndirty);		\
	  ia64_copy_rbs ((CONTEXT), bspstore, alt_bspstore, loadrs,	\
			 sc_->sc_ar_rnat);				\
	}								\
									\
      /* Don't touch the branch registers o.t. b0, b6 and b7.		\
	 The kernel doesn't pass the preserved branch registers		\
	 in the sigcontext but leaves them intact, so there's no	\
	 need to do anything with them here.  */			\
      {									\
	unsigned long sof = sc_->sc_cfm & 0x7f;				\
	(CONTEXT)->bsp = (unsigned long)				\
	  ia64_rse_skip_regs ((unsigned long *)(sc_->sc_ar_bsp), -sof); \
      }									\
									\
      /* pfs_loc already set above.  Without this pfs_loc would point	\
	 incorrectly to sc_cfm instead of sc_ar_pfs.  */		\
      (FS)->curr.reg[UNW_REG_PFS].where = UNW_WHERE_NONE;		\
    }

#endif /* IN_LIBGCC2 */
#endif /* glibc-2.3 or better */
OpenPOWER on IntegriCloud