View | Details | Return to bug 42159
Collapse All | Expand All

(-)a/libgcc/config/i386/libgcc-darwin.10.4.ver (-27 lines)
Lines 15-37 Link Here
15
# You should have received a copy of the GNU General Public License
15
# You should have received a copy of the GNU General Public License
16
# along with GCC; see the file COPYING3.  If not see
16
# along with GCC; see the file COPYING3.  If not see
17
# <http://www.gnu.org/licenses/>.
17
# <http://www.gnu.org/licenses/>.
18
__Unwind_Backtrace
19
__Unwind_DeleteException
20
__Unwind_FindEnclosingFunction
21
__Unwind_Find_FDE
22
__Unwind_ForcedUnwind
23
__Unwind_GetCFA
24
__Unwind_GetDataRelBase
25
__Unwind_GetGR
26
__Unwind_GetIP
27
__Unwind_GetLanguageSpecificData
28
__Unwind_GetRegionStart
29
__Unwind_GetTextRelBase
30
__Unwind_RaiseException
31
__Unwind_Resume
32
__Unwind_Resume_or_Rethrow
33
__Unwind_SetGR
34
__Unwind_SetIP
35
___absvdi2
18
___absvdi2
36
___absvsi2
19
___absvsi2
37
___addvdi3
20
___addvdi3
Lines 44-52 ___clzsi2 Link Here
44
___cmpdi2
27
___cmpdi2
45
___ctzdi2
28
___ctzdi2
46
___ctzsi2
29
___ctzsi2
47
___deregister_frame
48
___deregister_frame_info
49
___deregister_frame_info_bases
50
___divdc3
30
___divdc3
51
___divdi3
31
___divdi3
52
___divsc3
32
___divsc3
Lines 65-71 ___fixxfdi Link Here
65
___floatdidf
45
___floatdidf
66
___floatdisf
46
___floatdisf
67
___floatdixf
47
___floatdixf
68
___gcc_personality_v0
69
___lshrdi3
48
___lshrdi3
70
___moddi3
49
___moddi3
71
___muldc3
50
___muldc3
Lines 84-95 ___popcountsi2 Link Here
84
___powidf2
63
___powidf2
85
___powisf2
64
___powisf2
86
___powixf2
65
___powixf2
87
___register_frame
88
___register_frame_info
89
___register_frame_info_bases
90
___register_frame_info_table
91
___register_frame_info_table_bases
92
___register_frame_table
93
___subvdi3
66
___subvdi3
94
___subvsi3
67
___subvsi3
95
___ucmpdi2
68
___ucmpdi2
(-)a/libgcc/config/i386/libgcc-darwin.10.5.ver (-28 lines)
Lines 15-38 Link Here
15
# You should have received a copy of the GNU General Public License
15
# You should have received a copy of the GNU General Public License
16
# along with GCC; see the file COPYING3.  If not see
16
# along with GCC; see the file COPYING3.  If not see
17
# <http://www.gnu.org/licenses/>.
17
# <http://www.gnu.org/licenses/>.
18
__Unwind_Backtrace
19
__Unwind_DeleteException
20
__Unwind_FindEnclosingFunction
21
__Unwind_Find_FDE
22
__Unwind_ForcedUnwind
23
__Unwind_GetCFA
24
__Unwind_GetDataRelBase
25
__Unwind_GetGR
26
__Unwind_GetIP
27
__Unwind_GetIPInfo
28
__Unwind_GetLanguageSpecificData
29
__Unwind_GetRegionStart
30
__Unwind_GetTextRelBase
31
__Unwind_RaiseException
32
__Unwind_Resume
33
__Unwind_Resume_or_Rethrow
34
__Unwind_SetGR
35
__Unwind_SetIP
36
___absvdi2
18
___absvdi2
37
___absvsi2
19
___absvsi2
38
___addvdi3
20
___addvdi3
Lines 45-53 ___clzsi2 Link Here
45
___cmpdi2
27
___cmpdi2
46
___ctzdi2
28
___ctzdi2
47
___ctzsi2
29
___ctzsi2
48
___deregister_frame
49
___deregister_frame_info
50
___deregister_frame_info_bases
51
___divdc3
30
___divdc3
52
___divdi3
31
___divdi3
53
___divsc3
32
___divsc3
Lines 69-75 ___floatdixf Link Here
69
___floatundidf
48
___floatundidf
70
___floatundisf
49
___floatundisf
71
___floatundixf
50
___floatundixf
72
___gcc_personality_v0
73
___lshrdi3
51
___lshrdi3
74
___moddi3
52
___moddi3
75
___muldc3
53
___muldc3
Lines 88-99 ___popcountsi2 Link Here
88
___powidf2
66
___powidf2
89
___powisf2
67
___powisf2
90
___powixf2
68
___powixf2
91
___register_frame
92
___register_frame_info
93
___register_frame_info_bases
94
___register_frame_info_table
95
___register_frame_info_table_bases
96
___register_frame_table
97
___subvdi3
69
___subvdi3
98
___subvsi3
70
___subvsi3
99
___ucmpdi2
71
___ucmpdi2
(-)a/libgcc/config/t-darwin (-3 / +3 lines)
Lines 13-18 crttme.o: $(srcdir)/config/darwin-crt-tm.c Link Here
13
# works around this by not having any temporary file names.
13
# works around this by not having any temporary file names.
14
HOST_LIBGCC2_CFLAGS += -pipe
14
HOST_LIBGCC2_CFLAGS += -pipe
15
15
16
# Use unwind-dw2-fde-darwin
16
# Avoid including our unwinder as it is incompatible with the system's
17
LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/config/unwind-dw2-fde-darwin.c \
17
LIB2ADDEH =
18
  $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
18
LIB2ADDEHDEP =
(-)a/libgcc/config/unwind-dw2-fde-darwin.c (-288 lines)
Lines 1-288 Link Here
1
/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
2
3
   This file is part of GCC.
4
5
   GCC is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3, or (at your option)
8
   any later version.
9
10
   GCC is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
15
   Under Section 7 of GPL version 3, you are granted additional
16
   permissions described in the GCC Runtime Library Exception, version
17
   3.1, as published by the Free Software Foundation.
18
19
   You should have received a copy of the GNU General Public License and
20
   a copy of the GCC Runtime Library Exception along with this program;
21
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
22
   <http://www.gnu.org/licenses/>.  */
23
24
/* Locate the FDE entry for a given address, using Darwin's keymgr support.  */
25
26
#include "tconfig.h"
27
#include "tsystem.h"
28
#include <string.h>
29
#include <stdlib.h>
30
#include "dwarf2.h"
31
#include "unwind.h"
32
#define NO_BASE_OF_ENCODED_VALUE
33
#define DWARF2_OBJECT_END_PTR_EXTENSION
34
#include "unwind-pe.h"
35
#include "unwind-dw2-fde.h"
36
/* Carefully don't include gthr.h.  */
37
38
typedef int __gthread_mutex_t;
39
#define __gthread_mutex_lock(x)  (void)(x)
40
#define __gthread_mutex_unlock(x) (void)(x)
41
42
static const fde * _Unwind_Find_registered_FDE (void *pc,
43
						struct dwarf_eh_bases *bases);
44
45
#define _Unwind_Find_FDE _Unwind_Find_registered_FDE
46
#include "unwind-dw2-fde.c"
47
#undef _Unwind_Find_FDE
48
49
/* KeyMgr stuff.  */
50
#define KEYMGR_GCC3_LIVE_IMAGE_LIST     301     /* loaded images  */
51
#define KEYMGR_GCC3_DW2_OBJ_LIST        302     /* Dwarf2 object list  */
52
53
extern void *_keymgr_get_and_lock_processwide_ptr (int);
54
extern void _keymgr_set_and_unlock_processwide_ptr (int, void *);
55
extern void _keymgr_unlock_processwide_ptr (int);
56
57
struct mach_header;
58
struct mach_header_64;
59
extern char *getsectdatafromheader (struct mach_header*, const char*,
60
				    const char *, unsigned long *);
61
extern char *getsectdatafromheader_64 (struct mach_header_64*, const char*,
62
				       const char *, unsigned long *);
63
64
/* This is referenced from KEYMGR_GCC3_DW2_OBJ_LIST.  */
65
struct km_object_info {
66
  struct object *seen_objects;
67
  struct object *unseen_objects;
68
  unsigned spare[2];
69
};
70
71
/* Node of KEYMGR_GCC3_LIVE_IMAGE_LIST.  Info about each resident image.  */
72
struct live_images {
73
  unsigned long this_size;                      /* sizeof (live_images)  */
74
  struct mach_header *mh;                       /* the image info  */
75
  unsigned long vm_slide;
76
  void (*destructor)(struct live_images *);     /* destructor for this  */
77
  struct live_images *next;
78
  unsigned int examined_p;
79
  void *fde;
80
  void *object_info;
81
  unsigned long info[2];                        /* Future use.  */
82
};
83
84
/* Bits in the examined_p field of struct live_images.  */
85
enum {
86
  EXAMINED_IMAGE_MASK = 1,	/* We've seen this one.  */
87
  ALLOCED_IMAGE_MASK = 2,	/* The FDE entries were allocated by
88
				   malloc, and must be freed.  This isn't
89
				   used by newer libgcc versions.  */
90
  IMAGE_IS_TEXT_MASK = 4,	/* This image is in the TEXT segment.  */
91
  DESTRUCTOR_MAY_BE_CALLED_LIVE = 8  /* The destructor may be called on an
92
					object that's part of the live
93
					image list.  */
94
};
95
96
/* Delete any data we allocated on a live_images structure.  Either
97
   IMAGE has already been removed from the
98
   KEYMGR_GCC3_LIVE_IMAGE_LIST and the struct will be deleted
99
   after we return, or that list is locked and we're being called
100
   because this object might be about to be unloaded.  Called by
101
   KeyMgr.  */
102
103
static void
104
live_image_destructor (struct live_images *image)
105
{
106
  if (image->object_info)
107
    {
108
      struct km_object_info *the_obj_info;
109
110
      the_obj_info =
111
	_keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST);
112
      if (the_obj_info)
113
	{
114
	  seen_objects = the_obj_info->seen_objects;
115
	  unseen_objects = the_obj_info->unseen_objects;
116
117
	  /* Free any sorted arrays.  */
118
	  __deregister_frame_info_bases (image->fde);
119
120
	  the_obj_info->seen_objects = seen_objects;
121
	  the_obj_info->unseen_objects = unseen_objects;
122
	}
123
      _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST,
124
					      the_obj_info);
125
126
      free (image->object_info);
127
      image->object_info = NULL;
128
      if (image->examined_p & ALLOCED_IMAGE_MASK)
129
	free (image->fde);
130
      image->fde = NULL;
131
    }
132
  image->examined_p = 0;
133
  image->destructor = NULL;
134
}
135
136
/* Run through the list of live images.  If we can allocate memory,
137
   give each unseen image a new `struct object'.  Even if we can't,
138
   check whether the PC is inside the FDE of each unseen image.
139
 */
140
141
static inline const fde *
142
examine_objects (void *pc, struct dwarf_eh_bases *bases, int dont_alloc)
143
{
144
  const fde *result = NULL;
145
  struct live_images *image;
146
147
  image = _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
148
149
  for (; image != NULL; image = image->next)
150
    if ((image->examined_p & EXAMINED_IMAGE_MASK) == 0)
151
      {
152
	char *fde = NULL;
153
	unsigned long sz;
154
155
	/* For ppc only check whether or not we have __DATA eh frames.  */
156
#ifdef __ppc__
157
	fde = getsectdatafromheader (image->mh, "__DATA", "__eh_frame", &sz);
158
#endif
159
160
	if (fde == NULL)
161
	  {
162
#if __LP64__
163
	    fde = getsectdatafromheader_64 ((struct mach_header_64 *) image->mh,
164
					    "__TEXT", "__eh_frame", &sz);
165
#else
166
	    fde = getsectdatafromheader (image->mh, "__TEXT",
167
					 "__eh_frame", &sz);
168
#endif
169
	    if (fde != NULL)
170
	      image->examined_p |= IMAGE_IS_TEXT_MASK;
171
	  }
172
173
	/* If .eh_frame is empty, don't register at all.  */
174
	if (fde != NULL && sz > 0)
175
	  {
176
	    char *real_fde = (fde + image->vm_slide);
177
	    struct object *ob = NULL;
178
	    struct object panicob;
179
180
	    if (! dont_alloc)
181
	      ob = calloc (1, sizeof (struct object));
182
	    dont_alloc |= ob == NULL;
183
	    if (dont_alloc)
184
	      ob = &panicob;
185
186
	    ob->pc_begin = (void *)-1;
187
	    ob->tbase = 0;
188
	    ob->dbase = 0;
189
	    ob->u.single = (struct dwarf_fde *)real_fde;
190
	    ob->s.i = 0;
191
	    ob->s.b.encoding = DW_EH_PE_omit;
192
	    ob->fde_end = real_fde + sz;
193
194
	    image->fde = real_fde;
195
196
	    result = search_object (ob, pc);
197
198
	    if (! dont_alloc)
199
	      {
200
		struct object **p;
201
202
		image->destructor = live_image_destructor;
203
		image->object_info = ob;
204
205
		image->examined_p |= (EXAMINED_IMAGE_MASK
206
				      | DESTRUCTOR_MAY_BE_CALLED_LIVE);
207
208
		/* Insert the object into the classified list.  */
209
		for (p = &seen_objects; *p ; p = &(*p)->next)
210
		  if ((*p)->pc_begin < ob->pc_begin)
211
		    break;
212
		ob->next = *p;
213
		*p = ob;
214
	      }
215
216
	    if (result)
217
	      {
218
		int encoding;
219
		_Unwind_Ptr func;
220
221
		bases->tbase = ob->tbase;
222
		bases->dbase = ob->dbase;
223
224
		encoding = ob->s.b.encoding;
225
		if (ob->s.b.mixed_encoding)
226
		  encoding = get_fde_encoding (result);
227
		read_encoded_value_with_base (encoding,
228
					      base_from_object (encoding, ob),
229
					      result->pc_begin, &func);
230
		bases->func = (void *) func;
231
		break;
232
	      }
233
	  }
234
	else
235
	  image->examined_p |= EXAMINED_IMAGE_MASK;
236
      }
237
238
  _keymgr_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
239
240
  return result;
241
}
242
243
const fde *
244
_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
245
{
246
  struct km_object_info *the_obj_info;
247
  const fde *ret = NULL;
248
249
  the_obj_info =
250
    _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST);
251
  if (! the_obj_info)
252
    the_obj_info = calloc (1, sizeof (*the_obj_info));
253
254
  if (the_obj_info != NULL)
255
    {
256
      seen_objects = the_obj_info->seen_objects;
257
      unseen_objects = the_obj_info->unseen_objects;
258
259
      ret = _Unwind_Find_registered_FDE (pc, bases);
260
    }
261
262
  /* OK, didn't find it in the list of FDEs we've seen before,
263
     so go through and look at the new ones.  */
264
  if (ret == NULL)
265
    ret = examine_objects (pc, bases, the_obj_info == NULL);
266
267
  if (the_obj_info != NULL)
268
    {
269
      the_obj_info->seen_objects = seen_objects;
270
      the_obj_info->unseen_objects = unseen_objects;
271
    }
272
  _keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST,
273
					  the_obj_info);
274
  return ret;
275
}
276
277
void *
278
_darwin10_Unwind_FindEnclosingFunction (void *pc ATTRIBUTE_UNUSED)
279
{
280
#if __MACH__ && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060)
281
  struct dwarf_eh_bases bases;
282
  const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases);
283
  if (fde)
284
    return bases.func;
285
#endif
286
  return NULL;
287
}
288

Return to bug 42159