Sync recvmmsg prototype with kernel usage.
[glibc.git] / sysdeps / arm / find_exidx.c
blob39910ed350a06e1cd78f89ccda3baa686088d526
1 /* Copyright (C) 2005-2014 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/>. */
18 #include <link.h>
19 #include <unwind.h>
21 struct unw_eh_callback_data
23 _Unwind_Ptr pc;
24 _Unwind_Ptr exidx_start;
25 int exidx_len;
29 /* Callback to determins if the PC lies within an object, and remember the
30 location of the exception index table if it does. */
32 static int
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;
37 int i;
38 int match;
39 _Unwind_Ptr load_base;
41 data = (struct unw_eh_callback_data *) ptr;
42 load_base = info->dlpi_addr;
43 phdr = info->dlpi_phdr;
45 match = 0;
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)
52 match = 1;
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;
61 return match;
65 /* Find the exception index table containing PC. */
67 _Unwind_Ptr
68 __gnu_Unwind_Find_exidx (_Unwind_Ptr pc, int * pcount)
70 struct unw_eh_callback_data data;
72 data.pc = pc;
73 data.exidx_start = 0;
74 if (__dl_iterate_phdr (find_exidx_callback, &data) <= 0)
75 return 0;
77 *pcount = data.exidx_len / 8;
78 return data.exidx_start;