1
/* Copyright (C) 2005, 2008 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, write to the Free
16
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22
struct unw_eh_callback_data
25
_Unwind_Ptr exidx_start;
30
/* Callback to determins if the PC lies within an object, and remember the
31
location of the exception index table if it does. */
34
find_exidx_callback (struct dl_phdr_info * info, size_t size, void * ptr)
36
struct unw_eh_callback_data * data;
37
const ElfW(Phdr) *phdr;
40
_Unwind_Ptr load_base;
42
data = (struct unw_eh_callback_data *) ptr;
43
load_base = info->dlpi_addr;
44
phdr = info->dlpi_phdr;
47
for (i = info->dlpi_phnum; i > 0; i--, phdr++)
49
if (phdr->p_type == PT_LOAD)
51
_Unwind_Ptr vaddr = phdr->p_vaddr + load_base;
52
if (data->pc >= vaddr && data->pc < vaddr + phdr->p_memsz)
55
else if (phdr->p_type == PT_ARM_EXIDX)
57
data->exidx_start = (_Unwind_Ptr) (phdr->p_vaddr + load_base);
58
data->exidx_len = phdr->p_memsz;
66
/* Find the exception index table containing PC. */
69
__gnu_Unwind_Find_exidx (_Unwind_Ptr pc, int * pcount)
71
struct unw_eh_callback_data data;
75
if (__dl_iterate_phdr (find_exidx_callback, &data) <= 0)
78
*pcount = data.exidx_len / 8;
79
return data.exidx_start;