aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config/darwin10-unwind-find-enc-func.c
blob: b08396c5f1b510436c09d164025943a1c46c4266 (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
#include "libgcc_tm.h"

/* This shim is special, it needs to be built for Mac OSX 10.6
   regardless of the current system version.
   We must also build it to use the unwinder layout that was
   present for 10.6 (and not update that).
   So we copy the referenced structures from unwind-dw2-fde.h
   to avoid pulling in newer system headers and/or changed
   layouts.  */
struct dwarf_eh_bases
{
  void *tbase;
  void *dbase;
  void *func;
};

typedef          int  sword __attribute__ ((mode (SI)));
typedef unsigned int  uword __attribute__ ((mode (SI)));

/* The first few fields of an FDE.  */
struct dwarf_fde
{
  uword length;
  sword CIE_delta;
  unsigned char pc_begin[];
} __attribute__ ((packed, aligned (__alignof__ (void *))));

typedef struct dwarf_fde fde;

extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);

void *
_darwin10_Unwind_FindEnclosingFunction (void *pc)
{
  struct dwarf_eh_bases bases;
  const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases);
  if (fde)
    return bases.func;
  return (void *) 0;
}