Lines Matching refs:dwfl

33 __libdwfl_segment_start (Dwfl *dwfl, GElf_Addr start)  in __libdwfl_segment_start()  argument
35 if (dwfl->segment_align > 1) in __libdwfl_segment_start()
36 start &= -dwfl->segment_align; in __libdwfl_segment_start()
42 __libdwfl_segment_end (Dwfl *dwfl, GElf_Addr end) in __libdwfl_segment_end() argument
44 if (dwfl->segment_align > 1) in __libdwfl_segment_end()
45 end = (end + dwfl->segment_align - 1) & -dwfl->segment_align; in __libdwfl_segment_end()
50 insert (Dwfl *dwfl, size_t i, GElf_Addr start, GElf_Addr end, int segndx) in insert() argument
52 bool need_start = (i == 0 || dwfl->lookup_addr[i - 1] != start); in insert()
53 bool need_end = (i + 1 >= dwfl->lookup_elts in insert()
54 || dwfl->lookup_addr[i + 1] != end); in insert()
59 if (dwfl->lookup_alloc - dwfl->lookup_elts < need) in insert()
61 size_t n = dwfl->lookup_alloc == 0 ? 16 : dwfl->lookup_alloc * 2; in insert()
62 GElf_Addr *naddr = realloc (dwfl->lookup_addr, sizeof naddr[0] * n); in insert()
65 int *nsegndx = realloc (dwfl->lookup_segndx, sizeof nsegndx[0] * n); in insert()
68 if (naddr != dwfl->lookup_addr) in insert()
72 dwfl->lookup_alloc = n; in insert()
73 dwfl->lookup_addr = naddr; in insert()
74 dwfl->lookup_segndx = nsegndx; in insert()
76 if (dwfl->lookup_module != NULL) in insert()
79 Dwfl_Module **old = dwfl->lookup_module; in insert()
80 dwfl->lookup_module = realloc (dwfl->lookup_module, in insert()
81 sizeof dwfl->lookup_module[0] * n); in insert()
82 if (unlikely (dwfl->lookup_module == NULL)) in insert()
90 if (unlikely (i < dwfl->lookup_elts)) in insert()
92 const size_t move = dwfl->lookup_elts - i; in insert()
93 memmove (&dwfl->lookup_addr[i + need], &dwfl->lookup_addr[i], in insert()
94 move * sizeof dwfl->lookup_addr[0]); in insert()
95 memmove (&dwfl->lookup_segndx[i + need], &dwfl->lookup_segndx[i], in insert()
96 move * sizeof dwfl->lookup_segndx[0]); in insert()
97 if (dwfl->lookup_module != NULL) in insert()
98 memmove (&dwfl->lookup_module[i + need], &dwfl->lookup_module[i], in insert()
99 move * sizeof dwfl->lookup_module[0]); in insert()
104 dwfl->lookup_addr[i] = start; in insert()
105 dwfl->lookup_segndx[i] = segndx; in insert()
106 if (dwfl->lookup_module != NULL) in insert()
107 dwfl->lookup_module[i] = NULL; in insert()
111 dwfl->lookup_segndx[i - 1] = segndx; in insert()
115 dwfl->lookup_addr[i] = end; in insert()
116 dwfl->lookup_segndx[i] = -1; in insert()
117 if (dwfl->lookup_module != NULL) in insert()
118 dwfl->lookup_module[i] = NULL; in insert()
121 dwfl->lookup_elts += need; in insert()
127 lookup (Dwfl *dwfl, GElf_Addr address, int hint) in lookup() argument
130 && address >= dwfl->lookup_addr[hint] in lookup()
131 && ((size_t) hint + 1 == dwfl->lookup_elts in lookup()
132 || address < dwfl->lookup_addr[hint + 1])) in lookup()
136 size_t l = 0, u = dwfl->lookup_elts; in lookup()
140 if (address < dwfl->lookup_addr[idx]) in lookup()
145 if (l == dwfl->lookup_elts || address < dwfl->lookup_addr[l]) in lookup()
154 reify_segments (Dwfl *dwfl) in reify_segments() argument
159 for (Dwfl_Module *mod = dwfl->modulelist; mod != NULL; mod = mod->next) in reify_segments()
162 const GElf_Addr start = __libdwfl_segment_start (dwfl, mod->low_addr); in reify_segments()
163 const GElf_Addr end = __libdwfl_segment_end (dwfl, mod->high_addr); in reify_segments()
166 int idx = lookup (dwfl, start, hint); in reify_segments()
170 if (unlikely (insert (dwfl, 0, start, end, -1))) in reify_segments()
175 else if (dwfl->lookup_addr[idx] > start) in reify_segments()
178 if (unlikely (insert (dwfl, idx + 1, start, end, in reify_segments()
179 dwfl->lookup_segndx[idx]))) in reify_segments()
184 else if (dwfl->lookup_addr[idx] < start) in reify_segments()
188 if (unlikely (insert (dwfl, idx + 1, start, end, -1))) in reify_segments()
194 if ((size_t) idx + 1 < dwfl->lookup_elts in reify_segments()
195 && end < dwfl->lookup_addr[idx + 1]) in reify_segments()
198 if (unlikely (insert (dwfl, idx + 1, in reify_segments()
199 end, dwfl->lookup_addr[idx + 1], -1))) in reify_segments()
204 if (dwfl->lookup_module == NULL) in reify_segments()
206 dwfl->lookup_module = calloc (dwfl->lookup_alloc, in reify_segments()
207 sizeof dwfl->lookup_module[0]); in reify_segments()
208 if (unlikely (dwfl->lookup_module == NULL)) in reify_segments()
217 dwfl->lookup_module[idx++] = mod; in reify_segments()
218 while ((size_t) idx < dwfl->lookup_elts in reify_segments()
219 && dwfl->lookup_addr[idx] < end); in reify_segments()
220 assert (dwfl->lookup_module[mod->segment] == mod); in reify_segments()
228 hint = (size_t) idx < dwfl->lookup_elts ? idx : -1; in reify_segments()
233 for (size_t idx = 0; idx < dwfl->lookup_elts; ++idx) in reify_segments()
234 if (dwfl->lookup_module[idx] != NULL) in reify_segments()
235 dwfl->lookup_module[idx]->segment = idx; in reify_segments()
241 dwfl_addrsegment (Dwfl *dwfl, Dwarf_Addr address, Dwfl_Module **mod) in dwfl_addrsegment() argument
243 if (unlikely (dwfl == NULL)) in dwfl_addrsegment()
246 if (unlikely (dwfl->lookup_module == NULL) in dwfl_addrsegment()
248 && unlikely (reify_segments (dwfl))) in dwfl_addrsegment()
254 int idx = lookup (dwfl, address, -1); in dwfl_addrsegment()
257 if (unlikely (idx < 0) || unlikely (dwfl->lookup_module == NULL)) in dwfl_addrsegment()
261 *mod = dwfl->lookup_module[idx]; in dwfl_addrsegment()
265 if (*mod == NULL && idx > 0 && dwfl->lookup_addr[idx] == address) in dwfl_addrsegment()
267 *mod = dwfl->lookup_module[idx - 1]; in dwfl_addrsegment()
276 idx = dwfl->lookup_segndx[idx]; in dwfl_addrsegment()
283 dwfl_report_segment (Dwfl *dwfl, int ndx, const GElf_Phdr *phdr, GElf_Addr bias, in INTDEF()
286 if (dwfl == NULL) in INTDEF()
290 ndx = dwfl->lookup_tail_ndx; in INTDEF()
292 if (phdr->p_align > 1 && (dwfl->segment_align <= 1 || in INTDEF()
293 phdr->p_align < dwfl->segment_align)) in INTDEF()
294 dwfl->segment_align = phdr->p_align; in INTDEF()
296 if (unlikely (dwfl->lookup_module != NULL)) in INTDEF()
298 free (dwfl->lookup_module); in INTDEF()
299 dwfl->lookup_module = NULL; in INTDEF()
302 GElf_Addr start = __libdwfl_segment_start (dwfl, bias + phdr->p_vaddr); in INTDEF()
303 GElf_Addr end = __libdwfl_segment_end (dwfl, in INTDEF()
307 if (ndx != dwfl->lookup_tail_ndx in INTDEF()
309 || ident != dwfl->lookup_tail_ident in INTDEF()
310 || start != dwfl->lookup_tail_vaddr in INTDEF()
311 || phdr->p_offset != dwfl->lookup_tail_offset) in INTDEF()
315 size_t i = dwfl->lookup_elts; in INTDEF()
316 while (i > 0 && unlikely (start < dwfl->lookup_addr[i - 1])) in INTDEF()
319 if (unlikely (insert (dwfl, i, start, end, ndx))) in INTDEF()
326 dwfl->lookup_tail_ident = ident; in INTDEF()
327 dwfl->lookup_tail_vaddr = end; in INTDEF()
328 dwfl->lookup_tail_offset = end - bias - phdr->p_vaddr + phdr->p_offset; in INTDEF()
329 dwfl->lookup_tail_ndx = ndx + 1; in INTDEF()