1 /* Copyright (C) 2005-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
21 struct unw_eh_callback_data
24 _Unwind_Ptr exidx_start
;
29 /* Callback to determins if the PC lies within an object, and remember the
30 location of the exception index table if it does. */
33 find_exidx_callback (struct dl_phdr_info
* info
, size_t size
, void * ptr
)
35 struct unw_eh_callback_data
* data
;
36 const ElfW(Phdr
) *phdr
;
39 _Unwind_Ptr load_base
;
41 data
= (struct unw_eh_callback_data
*) ptr
;
42 load_base
= info
->dlpi_addr
;
43 phdr
= info
->dlpi_phdr
;
46 for (i
= info
->dlpi_phnum
; i
> 0; i
--, phdr
++)
48 if (phdr
->p_type
== PT_LOAD
)
50 _Unwind_Ptr vaddr
= phdr
->p_vaddr
+ load_base
;
51 if (data
->pc
>= vaddr
&& data
->pc
< vaddr
+ phdr
->p_memsz
)
54 else if (phdr
->p_type
== PT_ARM_EXIDX
)
56 data
->exidx_start
= (_Unwind_Ptr
) (phdr
->p_vaddr
+ load_base
);
57 data
->exidx_len
= phdr
->p_memsz
;
65 /* Find the exception index table containing PC. */
68 __gnu_Unwind_Find_exidx (_Unwind_Ptr pc
, int * pcount
)
70 struct unw_eh_callback_data data
;
74 if (__dl_iterate_phdr (find_exidx_callback
, &data
) <= 0)
77 *pcount
= data
.exidx_len
/ 8;
78 return data
.exidx_start
;