Branch data Line data Source code
1 : : /* Find debugging and symbol information for a module in libdwfl.
2 : : Copyright (C) 2005-2012, 2014, 2015, 2025 Red Hat, Inc.
3 : : Copyright (C) 2025 Mark J. Wielaard <mark@klomp.org>
4 : : This file is part of elfutils.
5 : :
6 : : This file is free software; you can redistribute it and/or modify
7 : : it under the terms of either
8 : :
9 : : * the GNU Lesser General Public License as published by the Free
10 : : Software Foundation; either version 3 of the License, or (at
11 : : your option) any later version
12 : :
13 : : or
14 : :
15 : : * the GNU General Public License as published by the Free
16 : : Software Foundation; either version 2 of the License, or (at
17 : : your option) any later version
18 : :
19 : : or both in parallel, as here.
20 : :
21 : : elfutils is distributed in the hope that it will be useful, but
22 : : WITHOUT ANY WARRANTY; without even the implied warranty of
23 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : : General Public License for more details.
25 : :
26 : : You should have received copies of the GNU General Public License and
27 : : the GNU Lesser General Public License along with this program. If
28 : : not, see <http://www.gnu.org/licenses/>. */
29 : :
30 : : #ifdef HAVE_CONFIG_H
31 : : # include <config.h>
32 : : #endif
33 : :
34 : : #include "libdwflP.h"
35 : : #include <inttypes.h>
36 : : #include <fcntl.h>
37 : : #include <string.h>
38 : : #include "libdwP.h" /* DWARF_E_* values are here. */
39 : : #include "libdwfl_stacktraceP.h" /* want the INTDECLS */
40 : : #include "libelfP.h"
41 : : #include "system.h"
42 : :
43 : : static inline Dwfl_Error
44 : 10776 : open_elf_file (Elf **elf, int *fd, char **name)
45 : : {
46 [ + + ]: 10776 : if (*elf == NULL)
47 : : {
48 : : /* CBFAIL uses errno if it's set, so clear it first in case we don't
49 : : set it with an open failure below. */
50 : 10528 : errno = 0;
51 : :
52 : : /* If there was a pre-primed file name left that the callback left
53 : : behind, try to open that file name. */
54 [ + + - + ]: 10528 : if (*fd < 0 && *name != NULL)
55 [ # # # # ]: 0 : *fd = TEMP_FAILURE_RETRY (open (*name, O_RDONLY));
56 : :
57 [ + + ]: 10528 : if (*fd < 0)
58 [ - + ]: 400 : return CBFAIL;
59 : :
60 : : /* This will call __libdwfl_reset_sh_addr. */
61 : 10128 : return __libdw_open_file (fd, elf, true, false);
62 : : }
63 [ - + ]: 248 : else if (unlikely (elf_kind (*elf) != ELF_K_ELF))
64 : : {
65 : 0 : elf_end (*elf);
66 : 0 : *elf = NULL;
67 : 0 : close (*fd);
68 : 0 : *fd = -1;
69 : 0 : return DWFL_E_BADELF;
70 : : }
71 : :
72 : : /* Elf file already open and looks fine. */
73 : : return DWFL_E_NOERROR;
74 : : }
75 : :
76 : : /* Open libelf FILE->fd and compute the load base of ELF as loaded in MOD.
77 : : When we return success, FILE->elf and FILE->vaddr are set up. */
78 : : static inline Dwfl_Error
79 : 10706 : open_elf (Dwfl_Module *mod, struct dwfl_file *file)
80 : : {
81 : 10706 : Dwfl_Error error = open_elf_file (&file->elf, &file->fd, &file->name);
82 [ + + ]: 10706 : if (error != DWFL_E_NOERROR)
83 : : return error;
84 : :
85 : : /* Cache file->elf in Dwflst_Process_Tracker if available: */
86 [ - + - - ]: 10306 : if (mod->dwfl->tracker != NULL && file->name != NULL)
87 : : {
88 : 0 : INTUSE(dwflst_tracker_cache_elf) (mod->dwfl->tracker, file->name,
89 : : file->name, file->elf, file->fd);
90 : : }
91 : :
92 : 10306 : GElf_Ehdr ehdr_mem, *ehdr = gelf_getehdr (file->elf, &ehdr_mem);
93 [ - + ]: 10306 : if (ehdr == NULL)
94 : : {
95 : 0 : elf_error:
96 : 0 : elf_end (file->elf);
97 : 0 : file->elf = NULL;
98 : 0 : close (file->fd);
99 : 0 : file->fd = -1;
100 : 0 : return DWFL_E (LIBELF, elf_errno ());
101 : : }
102 : :
103 [ + + ]: 10306 : if (ehdr->e_type != ET_REL)
104 : : {
105 : : /* In any non-ET_REL file, we compute the "synchronization address".
106 : :
107 : : We start with the address at the end of the first PT_LOAD
108 : : segment. When prelink converts REL to RELA in an ET_DYN
109 : : file, it expands the space between the beginning of the
110 : : segment and the actual code/data addresses. Since that
111 : : change wasn't made in the debug file, the distance from
112 : : p_vaddr to an address of interest (in an st_value or DWARF
113 : : data) now differs between the main and debug files. The
114 : : distance from address_sync to an address of interest remains
115 : : consistent.
116 : :
117 : : If there are no section headers at all (full stripping), then
118 : : the end of the first segment is a valid synchronization address.
119 : : This cannot happen in a prelinked file, since prelink itself
120 : : relies on section headers for prelinking and for undoing it.
121 : : (If you do full stripping on a prelinked file, then you get what
122 : : you deserve--you can neither undo the prelinking, nor expect to
123 : : line it up with a debug file separated before prelinking.)
124 : :
125 : : However, when prelink processes an ET_EXEC file, it can do
126 : : something different. There it juggles the "special" sections
127 : : (SHT_DYNSYM et al) to make space for the additional prelink
128 : : special sections. Sometimes it will do this by moving a special
129 : : section like .dynstr after the real program sections in the first
130 : : PT_LOAD segment--i.e. to the end. That changes the end address of
131 : : the segment, so it no longer lines up correctly and is not a valid
132 : : synchronization address to use. Because of this, we need to apply
133 : : a different prelink-savvy means to discover the synchronization
134 : : address when there is a separate debug file and a prelinked main
135 : : file. That is done in find_debuginfo, below. */
136 : :
137 : 10304 : size_t phnum;
138 [ - + ]: 10304 : if (unlikely (elf_getphdrnum (file->elf, &phnum) != 0))
139 : 0 : goto elf_error;
140 : :
141 : 10304 : file->vaddr = file->address_sync = 0;
142 [ + - ]: 30668 : for (size_t i = 0; i < phnum; ++i)
143 : : {
144 : 30668 : GElf_Phdr ph_mem;
145 : 30668 : GElf_Phdr *ph = gelf_getphdr (file->elf, i, &ph_mem);
146 [ - + ]: 30668 : if (unlikely (ph == NULL))
147 : 0 : goto elf_error;
148 [ + + ]: 30668 : if (ph->p_type == PT_LOAD)
149 : : {
150 : 10304 : file->vaddr = ph->p_vaddr & -ph->p_align;
151 : 10304 : file->address_sync = ph->p_vaddr + ph->p_memsz;
152 : 10304 : break;
153 : : }
154 : : }
155 : : }
156 : :
157 : : /* We only want to set the module e_type explicitly once, derived from
158 : : the main ELF file. (It might be changed for the kernel, because
159 : : that is special - see below.) open_elf is always called first for
160 : : the main ELF file, because both find_dw and find_symtab call
161 : : __libdwfl_getelf first to open the main file. So don't let debug
162 : : or aux files override the module e_type. The kernel heuristic
163 : : below could otherwise trigger for non-kernel/non-main files, since
164 : : their phdrs might not match the actual load addresses. */
165 [ + + ]: 10306 : if (file == &mod->main)
166 : : {
167 : 10130 : mod->e_type = ehdr->e_type;
168 : :
169 : : /* Relocatable Linux kernels are ET_EXEC but act like ET_DYN. */
170 [ + + - + ]: 10130 : if (mod->e_type == ET_EXEC && file->vaddr != mod->low_addr)
171 : 0 : mod->e_type = ET_DYN;
172 : : }
173 : : else
174 [ - + ]: 176 : assert (mod->main.elf != NULL);
175 : :
176 : : return DWFL_E_NOERROR;
177 : : }
178 : :
179 : : /* We have an authoritative build ID for this module MOD, so don't use
180 : : a file by name that doesn't match that ID. */
181 : : static void
182 : 0 : mod_verify_build_id (Dwfl_Module *mod)
183 : : {
184 [ # # ]: 0 : assert (mod->build_id_len > 0);
185 : :
186 [ # # # # ]: 0 : switch (__builtin_expect (__libdwfl_find_build_id (mod, false,
187 : : mod->main.elf), 2))
188 : : {
189 : : case 2:
190 : : /* Build ID matches as it should. */
191 : : return;
192 : :
193 : 0 : case -1: /* ELF error. */
194 : 0 : mod->elferr = INTUSE(dwfl_errno) ();
195 : 0 : break;
196 : :
197 : 0 : case 0: /* File has no build ID note. */
198 : : case 1: /* FIle has a build ID that does not match. */
199 : 0 : mod->elferr = DWFL_E_WRONG_ID_ELF;
200 : 0 : break;
201 : :
202 : 0 : default:
203 : 0 : abort ();
204 : : }
205 : :
206 : : /* We get here when it was the right ELF file. Clear it out. */
207 : 0 : elf_end (mod->main.elf);
208 : 0 : mod->main.elf = NULL;
209 [ # # ]: 0 : if (mod->main.fd >= 0)
210 : : {
211 : 0 : close (mod->main.fd);
212 : 0 : mod->main.fd = -1;
213 : : }
214 : : }
215 : :
216 : : /* Find the main ELF file for this module and open libelf on it.
217 : : When we return success, MOD->main.elf and MOD->main.bias are set up. */
218 : : void
219 : : internal_function
220 : 20238 : __libdwfl_getelf (Dwfl_Module *mod)
221 : : {
222 [ + + ]: 20238 : if (mod->main.elf != NULL /* Already done. */
223 [ + + ]: 10244 : || mod->elferr != DWFL_E_NOERROR) /* Cached failure. */
224 : : return;
225 : :
226 : 10182 : mod->main.fd = (*mod->dwfl->callbacks->find_elf) (MODCB_ARGS (mod),
227 : : &mod->main.name,
228 : : &mod->main.elf);
229 [ + + + + ]: 10182 : const bool fallback = mod->main.elf == NULL && mod->main.fd < 0;
230 : 10182 : mod->elferr = open_elf (mod, &mod->main);
231 [ + + ]: 10182 : if (mod->elferr != DWFL_E_NOERROR)
232 : : return;
233 : :
234 [ + - ]: 10130 : if (!mod->main.valid)
235 : : {
236 : : /* Clear any explicitly reported build ID, just in case it was wrong.
237 : : We'll fetch it from the file when asked. */
238 : 10130 : free (mod->build_id_bits);
239 : 10130 : mod->build_id_bits = NULL;
240 : 10130 : mod->build_id_len = 0;
241 : : }
242 [ # # ]: 0 : else if (fallback)
243 : 0 : mod_verify_build_id (mod);
244 : :
245 [ + - ]: 10130 : mod->main_bias = mod->e_type == ET_REL ? 0 : mod->low_addr - mod->main.vaddr;
246 : : }
247 : :
248 : : static inline void
249 : 1280 : consider_shdr (GElf_Addr interp,
250 : : GElf_Word sh_type,
251 : : GElf_Xword sh_flags,
252 : : GElf_Addr sh_addr,
253 : : GElf_Xword sh_size,
254 : : GElf_Addr *phighest)
255 : : {
256 [ + + ]: 1280 : if ((sh_flags & SHF_ALLOC)
257 [ + + ]: 1096 : && ((sh_type == SHT_PROGBITS && sh_addr != interp)
258 [ + + ]: 576 : || sh_type == SHT_NOBITS))
259 : : {
260 : 560 : const GElf_Addr sh_end = sh_addr + sh_size;
261 [ + - ]: 560 : if (sh_end > *phighest)
262 : 560 : *phighest = sh_end;
263 : : }
264 : 1280 : }
265 : :
266 : : /* If the main file might have been prelinked, then we need to
267 : : discover the correct synchronization address between the main and
268 : : debug files. Because of prelink's section juggling, we cannot rely
269 : : on the address_sync computed from PT_LOAD segments (see open_elf).
270 : :
271 : : We will attempt to discover a synchronization address based on the
272 : : section headers instead. But finding a section address that is
273 : : safe to use requires identifying which sections are SHT_PROGBITS.
274 : : We can do that in the main file, but in the debug file all the
275 : : allocated sections have been transformed into SHT_NOBITS so we have
276 : : lost the means to match them up correctly.
277 : :
278 : : The only method left to us is to decode the .gnu.prelink_undo
279 : : section in the prelinked main file. This shows what the sections
280 : : looked like before prelink juggled them--when they still had a
281 : : direct correspondence to the debug file. */
282 : : static Dwfl_Error
283 : 174 : find_prelink_address_sync (Dwfl_Module *mod, struct dwfl_file *file)
284 : : {
285 : : /* The magic section is only identified by name. */
286 : 174 : size_t shstrndx;
287 [ + - ]: 174 : if (elf_getshdrstrndx (mod->main.elf, &shstrndx) < 0)
288 : : return DWFL_E_LIBELF;
289 : :
290 : : Elf_Scn *scn = NULL;
291 [ + + ]: 5342 : while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
292 : : {
293 : 5192 : GElf_Shdr shdr_mem;
294 : 5192 : GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
295 [ + - ]: 5192 : if (unlikely (shdr == NULL))
296 : 0 : return DWFL_E_LIBELF;
297 [ + + ]: 5192 : if (shdr->sh_type == SHT_PROGBITS
298 [ + + ]: 2784 : && !(shdr->sh_flags & SHF_ALLOC)
299 [ + - ]: 866 : && shdr->sh_name != 0)
300 : : {
301 : 866 : const char *secname = elf_strptr (mod->main.elf, shstrndx,
302 : : shdr->sh_name);
303 [ + - ]: 866 : if (unlikely (secname == NULL))
304 : : return DWFL_E_LIBELF;
305 [ + + ]: 866 : if (!strcmp (secname, ".gnu.prelink_undo"))
306 : : break;
307 : : }
308 : : }
309 : :
310 [ + + ]: 174 : if (scn == NULL)
311 : : /* There was no .gnu.prelink_undo section. */
312 : : return DWFL_E_NOERROR;
313 : :
314 : 24 : Elf_Data *undodata = elf_rawdata (scn, NULL);
315 [ + - ]: 24 : if (unlikely (undodata == NULL))
316 : : return DWFL_E_LIBELF;
317 : :
318 : : /* Decode the section. It consists of the original ehdr, phdrs,
319 : : and shdrs (but omits section 0). */
320 : :
321 : 24 : union
322 : : {
323 : : Elf32_Ehdr e32;
324 : : Elf64_Ehdr e64;
325 : : } ehdr;
326 : 24 : Elf_Data dst =
327 : : {
328 : : .d_buf = &ehdr,
329 : : .d_size = sizeof ehdr,
330 : : .d_type = ELF_T_EHDR,
331 : : .d_version = EV_CURRENT
332 : : };
333 : 24 : Elf_Data src = *undodata;
334 : 24 : src.d_size = gelf_fsize (mod->main.elf, ELF_T_EHDR, 1, EV_CURRENT);
335 : 24 : src.d_type = ELF_T_EHDR;
336 [ + - ]: 24 : if (unlikely (gelf_xlatetom (mod->main.elf, &dst, &src,
337 : : elf_getident (mod->main.elf, NULL)[EI_DATA])
338 : : == NULL))
339 : : return DWFL_E_LIBELF;
340 : :
341 : 24 : size_t shentsize = gelf_fsize (mod->main.elf, ELF_T_SHDR, 1, EV_CURRENT);
342 : 24 : size_t phentsize = gelf_fsize (mod->main.elf, ELF_T_PHDR, 1, EV_CURRENT);
343 : :
344 : 24 : uint_fast16_t phnum;
345 : 24 : uint_fast16_t shnum;
346 [ + + ]: 24 : if (ehdr.e32.e_ident[EI_CLASS] == ELFCLASS32)
347 : : {
348 [ + - ]: 8 : if (ehdr.e32.e_shentsize != shentsize
349 [ - + ]: 8 : || ehdr.e32.e_phentsize != phentsize)
350 : : return DWFL_E_BAD_PRELINK;
351 : 8 : phnum = ehdr.e32.e_phnum;
352 : 8 : shnum = ehdr.e32.e_shnum;
353 : : }
354 : : else
355 : : {
356 [ - + ]: 16 : if (ehdr.e64.e_shentsize != shentsize
357 [ - + ]: 16 : || ehdr.e64.e_phentsize != phentsize)
358 : : return DWFL_E_BAD_PRELINK;
359 : 16 : phnum = ehdr.e64.e_phnum;
360 : 16 : shnum = ehdr.e64.e_shnum;
361 : : }
362 : :
363 : : /* Since prelink does not store the zeroth section header in the undo
364 : : section, it cannot support SHN_XINDEX encoding. */
365 [ - + - + ]: 24 : if (unlikely (shnum >= SHN_LORESERVE) || unlikely(shnum == 0)
366 [ - + ]: 24 : || unlikely (undodata->d_size != (src.d_size
367 : : + phnum * phentsize
368 : : + (shnum - 1) * shentsize)))
369 : : return DWFL_E_BAD_PRELINK;
370 : :
371 : 24 : --shnum;
372 : :
373 : : /* We look at the allocated SHT_PROGBITS (or SHT_NOBITS) sections. (Most
374 : : every file will have some SHT_PROGBITS sections, but it's possible to
375 : : have one with nothing but .bss, i.e. SHT_NOBITS.) The special sections
376 : : that can be moved around have different sh_type values--except for
377 : : .interp, the section that became the PT_INTERP segment. So we exclude
378 : : the SHT_PROGBITS section whose address matches the PT_INTERP p_vaddr.
379 : : For this reason, we must examine the phdrs first to find PT_INTERP. */
380 : :
381 : 24 : GElf_Addr main_interp = 0;
382 : : {
383 : 24 : size_t main_phnum;
384 [ + - ]: 24 : if (unlikely (elf_getphdrnum (mod->main.elf, &main_phnum)))
385 : 0 : return DWFL_E_LIBELF;
386 [ + + ]: 82 : for (size_t i = 0; i < main_phnum; ++i)
387 : : {
388 : 74 : GElf_Phdr phdr;
389 [ - + ]: 74 : if (unlikely (gelf_getphdr (mod->main.elf, i, &phdr) == NULL))
390 : 0 : return DWFL_E_LIBELF;
391 [ + + ]: 74 : if (phdr.p_type == PT_INTERP)
392 : : {
393 : 16 : main_interp = phdr.p_vaddr;
394 : 16 : break;
395 : : }
396 : : }
397 : : }
398 : :
399 : 24 : src.d_buf += src.d_size;
400 : 24 : src.d_type = ELF_T_PHDR;
401 : 24 : src.d_size = phnum * phentsize;
402 : :
403 : 24 : GElf_Addr undo_interp = 0;
404 : 24 : bool class32 = ehdr.e32.e_ident[EI_CLASS] == ELFCLASS32;
405 : : {
406 [ + + ]: 24 : size_t phdr_size = class32 ? sizeof (Elf32_Phdr) : sizeof (Elf64_Phdr);
407 [ - + ]: 24 : if (unlikely (phnum > SIZE_MAX / phdr_size))
408 : : return DWFL_E_NOMEM;
409 : 24 : const size_t phdrs_bytes = phnum * phdr_size;
410 : 24 : void *phdrs = malloc (phdrs_bytes);
411 [ - + ]: 24 : if (unlikely (phdrs == NULL))
412 : : return DWFL_E_NOMEM;
413 : 24 : dst.d_buf = phdrs;
414 : 24 : dst.d_size = phdrs_bytes;
415 [ - + ]: 24 : if (unlikely (gelf_xlatetom (mod->main.elf, &dst, &src,
416 : : ehdr.e32.e_ident[EI_DATA]) == NULL))
417 : : {
418 : 0 : free (phdrs);
419 : 0 : return DWFL_E_LIBELF;
420 : : }
421 [ + + ]: 24 : if (class32)
422 : : {
423 : 32 : Elf32_Phdr (*p32)[phnum] = phdrs;
424 [ + + ]: 32 : for (uint_fast16_t i = 0; i < phnum; ++i)
425 [ + + ]: 28 : if ((*p32)[i].p_type == PT_INTERP)
426 : : {
427 : 4 : undo_interp = (*p32)[i].p_vaddr;
428 : 4 : break;
429 : : }
430 : : }
431 : : else
432 : : {
433 : 50 : Elf64_Phdr (*p64)[phnum] = phdrs;
434 [ + + ]: 50 : for (uint_fast16_t i = 0; i < phnum; ++i)
435 [ + + ]: 46 : if ((*p64)[i].p_type == PT_INTERP)
436 : : {
437 : 12 : undo_interp = (*p64)[i].p_vaddr;
438 : 12 : break;
439 : : }
440 : : }
441 : 24 : free (phdrs);
442 : : }
443 : :
444 [ - + ]: 24 : if (unlikely ((main_interp == 0) != (undo_interp == 0)))
445 : : return DWFL_E_BAD_PRELINK;
446 : :
447 : 24 : src.d_buf += src.d_size;
448 : 24 : src.d_type = ELF_T_SHDR;
449 : 24 : src.d_size = gelf_fsize (mod->main.elf, ELF_T_SHDR, shnum, EV_CURRENT);
450 : :
451 [ + + ]: 24 : size_t shdr_size = class32 ? sizeof (Elf32_Shdr) : sizeof (Elf64_Shdr);
452 [ - + ]: 24 : if (unlikely (shnum > SIZE_MAX / shdr_size))
453 : : return DWFL_E_NOMEM;
454 : 24 : const size_t shdrs_bytes = shnum * shdr_size;
455 : 24 : void *shdrs = malloc (shdrs_bytes);
456 [ - + ]: 24 : if (unlikely (shdrs == NULL))
457 : : return DWFL_E_NOMEM;
458 : 24 : dst.d_buf = shdrs;
459 : 24 : dst.d_size = shdrs_bytes;
460 [ - + ]: 24 : if (unlikely (gelf_xlatetom (mod->main.elf, &dst, &src,
461 : : ehdr.e32.e_ident[EI_DATA]) == NULL))
462 : : {
463 : 0 : free (shdrs);
464 : 0 : return DWFL_E_LIBELF;
465 : : }
466 : :
467 : : /* Now we can look at the original section headers of the main file
468 : : before it was prelinked. First we'll apply our method to the main
469 : : file sections as they are after prelinking, to calculate the
470 : : synchronization address of the main file. Then we'll apply that
471 : : same method to the saved section headers, to calculate the matching
472 : : synchronization address of the debug file.
473 : :
474 : : The method is to consider SHF_ALLOC sections that are either
475 : : SHT_PROGBITS or SHT_NOBITS, excluding the section whose sh_addr
476 : : matches the PT_INTERP p_vaddr. The special sections that can be
477 : : moved by prelink have other types, except for .interp (which
478 : : becomes PT_INTERP). The "real" sections cannot move as such, but
479 : : .bss can be split into .dynbss and .bss, with the total memory
480 : : image remaining the same but being spread across the two sections.
481 : : So we consider the highest section end, which still matches up. */
482 : :
483 : 24 : GElf_Addr highest;
484 : :
485 : 24 : highest = 0;
486 : 24 : scn = NULL;
487 [ + + ]: 702 : while ((scn = elf_nextscn (mod->main.elf, scn)) != NULL)
488 : : {
489 : 678 : GElf_Shdr sh_mem;
490 : 678 : GElf_Shdr *sh = gelf_getshdr (scn, &sh_mem);
491 [ - + ]: 678 : if (unlikely (sh == NULL))
492 : : {
493 : 0 : free (shdrs);
494 : 0 : return DWFL_E_LIBELF;
495 : : }
496 : 678 : consider_shdr (main_interp, sh->sh_type, sh->sh_flags,
497 : : sh->sh_addr, sh->sh_size, &highest);
498 : : }
499 [ + - ]: 24 : if (highest > mod->main.vaddr)
500 : : {
501 : 24 : mod->main.address_sync = highest;
502 : :
503 : 24 : highest = 0;
504 [ + + ]: 24 : if (class32)
505 : : {
506 : 196 : Elf32_Shdr (*s32)[shnum] = shdrs;
507 [ + + ]: 196 : for (size_t i = 0; i < shnum; ++i)
508 : 188 : consider_shdr (undo_interp, (*s32)[i].sh_type,
509 : 188 : (*s32)[i].sh_flags, (*s32)[i].sh_addr,
510 : 188 : (*s32)[i].sh_size, &highest);
511 : : }
512 : : else
513 : : {
514 : 430 : Elf64_Shdr (*s64)[shnum] = shdrs;
515 [ + + ]: 430 : for (size_t i = 0; i < shnum; ++i)
516 : 414 : consider_shdr (undo_interp, (*s64)[i].sh_type,
517 : : (*s64)[i].sh_flags, (*s64)[i].sh_addr,
518 : : (*s64)[i].sh_size, &highest);
519 : : }
520 : :
521 [ + - ]: 24 : if (highest > file->vaddr)
522 : 24 : file->address_sync = highest;
523 : : else
524 : : {
525 : 0 : free (shdrs);
526 : 0 : return DWFL_E_BAD_PRELINK;
527 : : }
528 : : }
529 : :
530 : 24 : free (shdrs);
531 : :
532 : 24 : return DWFL_E_NOERROR;
533 : : }
534 : :
535 : : /* Find the separate debuginfo file for this module and open libelf on it.
536 : : When we return success, MOD->debug is set up. */
537 : : static Dwfl_Error
538 : 502 : find_debuginfo (Dwfl_Module *mod)
539 : : {
540 [ + + ]: 502 : if (mod->debug.elf != NULL)
541 : : return DWFL_E_NOERROR;
542 : :
543 : 448 : GElf_Word debuglink_crc = 0;
544 : 448 : const char *debuglink_file;
545 : 448 : debuglink_file = INTUSE(dwelf_elf_gnu_debuglink) (mod->main.elf,
546 : : &debuglink_crc);
547 : :
548 : 896 : mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
549 : 448 : mod->main.name,
550 : : debuglink_file,
551 : : debuglink_crc,
552 : : &mod->debug.name);
553 : 448 : Dwfl_Error result = open_elf (mod, &mod->debug);
554 [ + + + + ]: 448 : if (result == DWFL_E_NOERROR && mod->debug.address_sync != 0)
555 : 98 : result = find_prelink_address_sync (mod, &mod->debug);
556 : : return result;
557 : : }
558 : :
559 : : /* Try to find the alternative debug link for the given DWARF and set
560 : : it if found. Only called when mod->dw is already setup but still
561 : : might need an alternative (dwz multi) debug file. filename is either
562 : : the main or debug name from which the Dwarf was created. */
563 : : static void
564 : 10854 : find_debug_altlink (Dwfl_Module *mod, const char *filename)
565 : : {
566 [ - + ]: 10854 : assert (mod->dw != NULL);
567 : :
568 : 10854 : const char *altname;
569 : 10854 : const void *build_id;
570 : 10854 : ssize_t build_id_len = INTUSE(dwelf_dwarf_gnu_debugaltlink) (mod->dw,
571 : : &altname,
572 : : &build_id);
573 : :
574 [ + + ]: 10854 : if (build_id_len > 0)
575 : : {
576 : : /* We could store altfile in the module, but don't really need it. */
577 : 70 : char *altfile = NULL;
578 : 70 : mod->alt_fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
579 : : filename,
580 : : altname,
581 : : 0,
582 : : &altfile);
583 : :
584 : : /* The (internal) callbacks might just set mod->alt_elf directly
585 : : because they open the Elf anyway for sanity checking.
586 : : Otherwise open either the given file name or use the fd
587 : : returned. */
588 : 70 : Dwfl_Error error = open_elf_file (&mod->alt_elf, &mod->alt_fd,
589 : : &altfile);
590 [ + - ]: 70 : if (error == DWFL_E_NOERROR)
591 : : {
592 : 70 : mod->alt = INTUSE(dwarf_begin_elf) (mod->alt_elf,
593 : : DWARF_C_READ, NULL);
594 [ - + ]: 70 : if (mod->alt == NULL)
595 : : {
596 : 0 : elf_end (mod->alt_elf);
597 : 0 : mod->alt_elf = NULL;
598 : 0 : close (mod->alt_fd);
599 : 0 : mod->alt_fd = -1;
600 : : }
601 : : else
602 : 70 : dwarf_setalt (mod->dw, mod->alt);
603 : : }
604 : :
605 : 70 : free (altfile); /* See above, we don't really need it. */
606 : : }
607 : 10854 : }
608 : :
609 : : /* Try to find a symbol table in FILE.
610 : : Returns DWFL_E_NOERROR if a proper one is found.
611 : : Returns DWFL_E_NO_SYMTAB if not, but still sets results for SHT_DYNSYM. */
612 : : static Dwfl_Error
613 : 724 : load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
614 : : Elf_Scn **symscn, Elf_Scn **xndxscn,
615 : : size_t *syments, int *first_global, GElf_Word *strshndx)
616 : : {
617 : 724 : bool symtab = false;
618 : 724 : Elf_Scn *scn = NULL;
619 [ + + ]: 23500 : while ((scn = elf_nextscn (file->elf, scn)) != NULL)
620 : : {
621 : 22776 : GElf_Shdr shdr_mem, *shdr = gelf_getshdr (scn, &shdr_mem);
622 [ + - ]: 22776 : if (shdr != NULL)
623 [ + + - + ]: 22776 : switch (shdr->sh_type)
624 : : {
625 : 526 : case SHT_SYMTAB:
626 [ + - ]: 526 : if (shdr->sh_entsize == 0)
627 : : break;
628 : 526 : symtab = true;
629 : 526 : *symscn = scn;
630 : 526 : *symfile = file;
631 : 526 : *strshndx = shdr->sh_link;
632 : 526 : *syments = shdr->sh_size / shdr->sh_entsize;
633 : 526 : *first_global = shdr->sh_info;
634 [ + - ]: 526 : if (*xndxscn != NULL)
635 : 0 : return DWFL_E_NOERROR;
636 : : break;
637 : :
638 : 378 : case SHT_DYNSYM:
639 [ - + ]: 378 : if (symtab)
640 : : break;
641 : : /* Use this if need be, but keep looking for SHT_SYMTAB. */
642 [ + - ]: 378 : if (shdr->sh_entsize == 0)
643 : : break;
644 : 378 : *symscn = scn;
645 : 378 : *symfile = file;
646 : 378 : *strshndx = shdr->sh_link;
647 : 378 : *syments = shdr->sh_size / shdr->sh_entsize;
648 : 378 : *first_global = shdr->sh_info;
649 : 378 : break;
650 : :
651 : 0 : case SHT_SYMTAB_SHNDX:
652 : 0 : *xndxscn = scn;
653 [ # # ]: 0 : if (symtab)
654 : : return DWFL_E_NOERROR;
655 : : break;
656 : :
657 : : default:
658 : : break;
659 : : }
660 : : }
661 : :
662 [ + + ]: 724 : if (symtab)
663 : : /* We found one, though no SHT_SYMTAB_SHNDX to go with it. */
664 : : return DWFL_E_NOERROR;
665 : :
666 : : /* We found no SHT_SYMTAB, so any SHT_SYMTAB_SHNDX was bogus.
667 : : We might have found an SHT_DYNSYM and set *SYMSCN et al though. */
668 : 198 : *xndxscn = NULL;
669 : 198 : return DWFL_E_NO_SYMTAB;
670 : : }
671 : :
672 : :
673 : : /* Translate addresses into file offsets.
674 : : OFFS[*] start out zero and remain zero if unresolved. */
675 : : static void
676 : 20 : find_offsets (Elf *elf, GElf_Addr main_bias, size_t phnum, size_t n,
677 : : GElf_Addr addrs[n], GElf_Off offs[n])
678 : : {
679 : 20 : size_t unsolved = n;
680 [ + + ]: 176 : for (size_t i = 0; i < phnum; ++i)
681 : : {
682 : 156 : GElf_Phdr phdr_mem;
683 : 156 : GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
684 [ + - + + : 156 : if (phdr != NULL && phdr->p_type == PT_LOAD && phdr->p_memsz > 0)
+ - ]
685 [ + + ]: 240 : for (size_t j = 0; j < n; ++j)
686 [ + + ]: 192 : if (offs[j] == 0
687 [ + + ]: 150 : && addrs[j] >= phdr->p_vaddr + main_bias
688 [ + + ]: 84 : && addrs[j] - (phdr->p_vaddr + main_bias) < phdr->p_filesz)
689 : : {
690 : 36 : offs[j] = addrs[j] - (phdr->p_vaddr + main_bias) + phdr->p_offset;
691 [ + - ]: 36 : if (--unsolved == 0)
692 : : break;
693 : : }
694 : : }
695 : 20 : }
696 : :
697 : : /* This is a string section/segment, so we want to make sure the last
698 : : valid index contains a zero character to terminate a string. */
699 : : static void
700 : 734 : validate_strdata (Elf_Data *symstrdata)
701 : : {
702 : 734 : size_t size = symstrdata->d_size;
703 : 734 : const char *buf = symstrdata->d_buf;
704 [ + - - + ]: 734 : while (size > 0 && *(buf + size - 1) != '\0')
705 : : --size;
706 : 734 : symstrdata->d_size = size;
707 : 734 : }
708 : :
709 : :
710 : : /* Various addresses we might want to pull from the dynamic segment. */
711 : : enum
712 : : {
713 : : i_symtab,
714 : : i_strtab,
715 : : i_hash,
716 : : i_gnu_hash,
717 : : i_max
718 : : };
719 : :
720 : : /* Translate pointers into file offsets. ADJUST is either zero
721 : : in case the dynamic segment wasn't adjusted or mod->main_bias.
722 : : Will set mod->symfile if the translated offsets can be used as
723 : : symbol table. */
724 : : static void
725 : 20 : translate_offs (GElf_Addr adjust,
726 : : Dwfl_Module *mod, size_t phnum,
727 : : GElf_Addr addrs[i_max], GElf_Xword strsz,
728 : : GElf_Ehdr *ehdr)
729 : : {
730 : 20 : GElf_Off offs[i_max] = { 0, };
731 : 20 : find_offsets (mod->main.elf, adjust, phnum, i_max, addrs, offs);
732 : :
733 : : /* Figure out the size of the symbol table. */
734 [ - + ]: 20 : if (offs[i_hash] != 0)
735 : : {
736 : : /* In the original format, .hash says the size of .dynsym. */
737 : :
738 [ # # # # : 0 : size_t entsz = SH_ENTSIZE_HASH (ehdr);
# # ]
739 : 0 : Elf_Data *data = elf_getdata_rawchunk (mod->main.elf,
740 : 0 : offs[i_hash] + entsz, entsz,
741 : : (entsz == 4
742 : : ? ELF_T_WORD : ELF_T_XWORD));
743 [ # # ]: 0 : if (data != NULL)
744 : 0 : mod->syments = (entsz == 4
745 : 0 : ? *(const GElf_Word *) data->d_buf
746 [ # # ]: 0 : : *(const GElf_Xword *) data->d_buf);
747 : : }
748 [ + + + - ]: 20 : if (offs[i_gnu_hash] != 0 && mod->syments == 0)
749 : : {
750 : : /* In the new format, we can derive it with some work. */
751 : :
752 : 10 : const struct
753 : : {
754 : : Elf32_Word nbuckets;
755 : : Elf32_Word symndx;
756 : : Elf32_Word maskwords;
757 : : Elf32_Word shift2;
758 : : } *header;
759 : :
760 : 10 : Elf_Data *data = elf_getdata_rawchunk (mod->main.elf, offs[i_gnu_hash],
761 : : sizeof *header, ELF_T_WORD);
762 [ + - ]: 10 : if (data != NULL)
763 : : {
764 : 10 : header = data->d_buf;
765 : 10 : Elf32_Word nbuckets = header->nbuckets;
766 : 10 : Elf32_Word symndx = header->symndx;
767 : 20 : GElf_Off buckets_at = (offs[i_gnu_hash] + sizeof *header
768 : 10 : + (gelf_getclass (mod->main.elf)
769 : : * sizeof (Elf32_Word)
770 : 10 : * header->maskwords));
771 : :
772 : : // elf_getdata_rawchunk takes a size_t, make sure it
773 : : // doesn't overflow.
774 : : #if SIZE_MAX <= UINT32_MAX
775 : : if (nbuckets > SIZE_MAX / sizeof (Elf32_Word))
776 : : data = NULL;
777 : : else
778 : : #endif
779 : 10 : data = elf_getdata_rawchunk (mod->main.elf, buckets_at,
780 : : nbuckets * sizeof (Elf32_Word),
781 : : ELF_T_WORD);
782 [ + + ]: 10 : if (data != NULL && symndx < nbuckets)
783 : : {
784 : 2 : const Elf32_Word *const buckets = data->d_buf;
785 : 2 : Elf32_Word maxndx = symndx;
786 [ + + ]: 8 : for (Elf32_Word bucket = 0; bucket < nbuckets; ++bucket)
787 : 6 : if (buckets[bucket] > maxndx)
788 : : maxndx = buckets[bucket];
789 : :
790 : 2 : GElf_Off hasharr_at = (buckets_at
791 : : + nbuckets * sizeof (Elf32_Word));
792 : 2 : hasharr_at += (maxndx - symndx) * sizeof (Elf32_Word);
793 : 2 : do
794 : : {
795 : 2 : data = elf_getdata_rawchunk (mod->main.elf,
796 : : hasharr_at,
797 : : sizeof (Elf32_Word),
798 : : ELF_T_WORD);
799 [ + - ]: 2 : if (data != NULL
800 [ + - ]: 2 : && (*(const Elf32_Word *) data->d_buf & 1u))
801 : : {
802 : 2 : mod->syments = maxndx + 1;
803 : 2 : break;
804 : : }
805 : 0 : ++maxndx;
806 : 0 : hasharr_at += sizeof (Elf32_Word);
807 : : }
808 [ # # ]: 0 : while (data != NULL);
809 : : }
810 : : }
811 : : }
812 [ + + + + ]: 20 : if (offs[i_strtab] > offs[i_symtab] && mod->syments == 0)
813 : 16 : mod->syments = ((offs[i_strtab] - offs[i_symtab])
814 : 8 : / gelf_fsize (mod->main.elf,
815 : : ELF_T_SYM, 1, EV_CURRENT));
816 : :
817 [ + + ]: 20 : if (mod->syments > 0)
818 : : {
819 : 10 : mod->symdata = elf_getdata_rawchunk (mod->main.elf,
820 : : offs[i_symtab],
821 : : gelf_fsize (mod->main.elf,
822 : : ELF_T_SYM,
823 : : mod->syments,
824 : : EV_CURRENT),
825 : : ELF_T_SYM);
826 [ + - ]: 10 : if (mod->symdata != NULL)
827 : : {
828 : 10 : mod->symstrdata = elf_getdata_rawchunk (mod->main.elf,
829 : : offs[i_strtab],
830 : : strsz,
831 : : ELF_T_BYTE);
832 [ - + ]: 10 : if (mod->symstrdata == NULL)
833 : 0 : mod->symdata = NULL;
834 : : else
835 : 10 : validate_strdata (mod->symstrdata);
836 : : }
837 [ - + ]: 10 : if (mod->symdata == NULL)
838 : 0 : mod->symerr = DWFL_E (LIBELF, elf_errno ());
839 : : else
840 : : {
841 : 10 : mod->symfile = &mod->main;
842 : 10 : mod->symerr = DWFL_E_NOERROR;
843 : : }
844 : : }
845 : 20 : }
846 : :
847 : : /* Try to find a dynamic symbol table via phdrs. */
848 : : static void
849 : 12 : find_dynsym (Dwfl_Module *mod)
850 : : {
851 : 12 : GElf_Ehdr ehdr_mem;
852 : 12 : GElf_Ehdr *ehdr = gelf_getehdr (mod->main.elf, &ehdr_mem);
853 : :
854 : 12 : size_t phnum;
855 [ + - ]: 12 : if (unlikely (elf_getphdrnum (mod->main.elf, &phnum) != 0))
856 : 12 : return;
857 : :
858 [ + - ]: 52 : for (size_t i = 0; i < phnum; ++i)
859 : : {
860 : 52 : GElf_Phdr phdr_mem;
861 : 52 : GElf_Phdr *phdr = gelf_getphdr (mod->main.elf, i, &phdr_mem);
862 [ + - ]: 52 : if (phdr == NULL)
863 : : break;
864 : :
865 [ + + ]: 52 : if (phdr->p_type == PT_DYNAMIC)
866 : : {
867 : : /* Examine the dynamic section for the pointers we need. */
868 : :
869 : 24 : Elf_Data *data = elf_getdata_rawchunk (mod->main.elf,
870 : 12 : phdr->p_offset, phdr->p_filesz,
871 : : ELF_T_DYN);
872 [ - + ]: 12 : if (data == NULL)
873 : 0 : continue;
874 : :
875 : 12 : GElf_Addr addrs[i_max] = { 0, };
876 : 12 : GElf_Xword strsz = 0;
877 : 12 : size_t n = data->d_size / gelf_fsize (mod->main.elf,
878 : : ELF_T_DYN, 1, EV_CURRENT);
879 [ + - ]: 196 : for (size_t j = 0; j < n; ++j)
880 : : {
881 : 196 : GElf_Dyn dyn_mem;
882 : 196 : GElf_Dyn *dyn = gelf_getdyn (data, j, &dyn_mem);
883 [ + - ]: 196 : if (dyn != NULL)
884 [ + - + + : 196 : switch (dyn->d_tag)
+ + + ]
885 : : {
886 : 10 : case DT_SYMTAB:
887 : 10 : addrs[i_symtab] = dyn->d_un.d_ptr;
888 : 194 : continue;
889 : :
890 : 0 : case DT_HASH:
891 : 0 : addrs[i_hash] = dyn->d_un.d_ptr;
892 : 0 : continue;
893 : :
894 : 10 : case DT_GNU_HASH:
895 : 10 : addrs[i_gnu_hash] = dyn->d_un.d_ptr;
896 : 10 : continue;
897 : :
898 : 10 : case DT_STRTAB:
899 : 10 : addrs[i_strtab] = dyn->d_un.d_ptr;
900 : 10 : continue;
901 : :
902 : 10 : case DT_STRSZ:
903 : 10 : strsz = dyn->d_un.d_val;
904 : 10 : continue;
905 : :
906 : 144 : default:
907 : 144 : continue;
908 : :
909 : : case DT_NULL:
910 : : break;
911 : : }
912 : 12 : break;
913 : : }
914 : :
915 : : /* First try unadjusted, like ELF files from disk, vdso.
916 : : Then try for already adjusted dynamic section, like ELF
917 : : from remote memory. */
918 : 12 : translate_offs (0, mod, phnum, addrs, strsz, ehdr);
919 [ + + ]: 12 : if (mod->symfile == NULL)
920 : 8 : translate_offs (mod->main_bias, mod, phnum, addrs, strsz, ehdr);
921 : :
922 : 12 : return;
923 : : }
924 : : }
925 : : }
926 : :
927 : :
928 : : #if USE_LZMA
929 : : /* Try to find the offset between the main file and .gnu_debugdata. */
930 : : static bool
931 : 76 : find_aux_address_sync (Dwfl_Module *mod)
932 : : {
933 : : /* Don't trust the phdrs in the minisymtab elf file to be setup correctly.
934 : : The address_sync is equal to the main file it is embedded in at first. */
935 : 76 : mod->aux_sym.address_sync = mod->main.address_sync;
936 : :
937 : : /* Adjust address_sync for the difference in entry addresses, attempting to
938 : : account for ELF relocation changes after aux was split. */
939 : 76 : GElf_Ehdr ehdr_main, ehdr_aux;
940 [ + - ]: 76 : if (unlikely (gelf_getehdr (mod->main.elf, &ehdr_main) == NULL)
941 [ - + ]: 76 : || unlikely (gelf_getehdr (mod->aux_sym.elf, &ehdr_aux) == NULL))
942 : 0 : return false;
943 : 76 : mod->aux_sym.address_sync += ehdr_aux.e_entry - ehdr_main.e_entry;
944 : :
945 : : /* The shdrs are setup OK to make find_prelink_address_sync () do the right
946 : : thing, which is possibly more reliable, but it needs .gnu.prelink_undo. */
947 [ + - ]: 76 : if (mod->aux_sym.address_sync != 0)
948 : 76 : return find_prelink_address_sync (mod, &mod->aux_sym) == DWFL_E_NOERROR;
949 : :
950 : : return true;
951 : : }
952 : : #endif
953 : :
954 : : /* Try to find the auxiliary symbol table embedded in the main elf file
955 : : section .gnu_debugdata. Only matters if the symbol information comes
956 : : from the main file dynsym. No harm done if not found. */
957 : : static void
958 : 136 : find_aux_sym (Dwfl_Module *mod __attribute__ ((unused)),
959 : : Elf_Scn **aux_symscn __attribute__ ((unused)),
960 : : Elf_Scn **aux_xndxscn __attribute__ ((unused)),
961 : : GElf_Word *aux_strshndx __attribute__ ((unused)))
962 : : {
963 : : /* Since a .gnu_debugdata section is compressed using lzma don't do
964 : : anything unless we have support for that. */
965 : : #if USE_LZMA
966 : 136 : Elf *elf = mod->main.elf;
967 : :
968 : 136 : size_t shstrndx;
969 [ + - ]: 136 : if (elf_getshdrstrndx (elf, &shstrndx) < 0)
970 : 136 : return;
971 : :
972 : : Elf_Scn *scn = NULL;
973 [ + + ]: 3258 : while ((scn = elf_nextscn (elf, scn)) != NULL)
974 : : {
975 : 3198 : GElf_Shdr shdr_mem;
976 : 3198 : GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
977 [ + - ]: 3198 : if (shdr == NULL)
978 : 0 : return;
979 : :
980 : 3198 : const char *name = elf_strptr (elf, shstrndx, shdr->sh_name);
981 [ + - ]: 3198 : if (name == NULL)
982 : : return;
983 : :
984 [ + + ]: 3198 : if (!strcmp (name, ".gnu_debugdata"))
985 : : break;
986 : : }
987 : :
988 [ + + ]: 136 : if (scn == NULL)
989 : : return;
990 : :
991 : : /* Found the .gnu_debugdata section. Uncompress the lzma image and
992 : : turn it into an ELF image. */
993 : 76 : Elf_Data *rawdata = elf_rawdata (scn, NULL);
994 [ + - ]: 76 : if (rawdata == NULL)
995 : : return;
996 : :
997 : 76 : Dwfl_Error error;
998 : 76 : void *buffer = NULL;
999 : 76 : size_t size = 0;
1000 : 76 : error = __libdw_unlzma (-1, 0, rawdata->d_buf, rawdata->d_size,
1001 : : &buffer, &size);
1002 [ + - ]: 76 : if (error == DWFL_E_NOERROR)
1003 : : {
1004 [ - + ]: 76 : if (unlikely (size == 0))
1005 : 0 : free (buffer);
1006 : : else
1007 : : {
1008 : : /* We don't call __libdwfl_reset_sh_addr here, should we? */
1009 : 76 : mod->aux_sym.elf = elf_memory (buffer, size);
1010 [ - + ]: 76 : if (mod->aux_sym.elf == NULL)
1011 : 0 : free (buffer);
1012 : : else
1013 : : {
1014 : 76 : mod->aux_sym.fd = -1;
1015 : 76 : mod->aux_sym.elf->flags |= ELF_F_MALLOCED;
1016 [ + - ]: 76 : if (open_elf (mod, &mod->aux_sym) != DWFL_E_NOERROR)
1017 : : return;
1018 [ - + ]: 76 : if (! find_aux_address_sync (mod))
1019 : : {
1020 : 0 : elf_end (mod->aux_sym.elf);
1021 : 0 : mod->aux_sym.elf = NULL;
1022 : 0 : return;
1023 : : }
1024 : :
1025 : : /* So far, so good. Get minisymtab table data and cache it. */
1026 : : bool minisymtab = false;
1027 : : scn = NULL;
1028 [ + + ]: 2150 : while ((scn = elf_nextscn (mod->aux_sym.elf, scn)) != NULL)
1029 : : {
1030 : 2074 : GElf_Shdr shdr_mem, *shdr = gelf_getshdr (scn, &shdr_mem);
1031 [ + - ]: 2074 : if (shdr != NULL)
1032 [ + - + ]: 2074 : switch (shdr->sh_type)
1033 : : {
1034 : 76 : case SHT_SYMTAB:
1035 [ + - ]: 76 : if (shdr->sh_entsize == 0)
1036 : 0 : return;
1037 : 76 : minisymtab = true;
1038 : 76 : *aux_symscn = scn;
1039 : 76 : *aux_strshndx = shdr->sh_link;
1040 : 76 : mod->aux_syments = shdr->sh_size / shdr->sh_entsize;
1041 : 76 : mod->aux_first_global = shdr->sh_info;
1042 [ + - ]: 76 : if (*aux_xndxscn != NULL)
1043 : : return;
1044 : : break;
1045 : :
1046 : 0 : case SHT_SYMTAB_SHNDX:
1047 : 0 : *aux_xndxscn = scn;
1048 [ # # ]: 0 : if (minisymtab)
1049 : : return;
1050 : : break;
1051 : :
1052 : : default:
1053 : : break;
1054 : : }
1055 : : }
1056 : :
1057 [ - + ]: 76 : if (minisymtab)
1058 : : /* We found one, though no SHT_SYMTAB_SHNDX to go with it. */
1059 : : return;
1060 : :
1061 : : /* We found no SHT_SYMTAB, so everything else is bogus. */
1062 : 0 : *aux_xndxscn = NULL;
1063 : 0 : *aux_strshndx = 0;
1064 : 0 : mod->aux_syments = 0;
1065 : 0 : elf_end (mod->aux_sym.elf);
1066 : 0 : mod->aux_sym.elf = NULL;
1067 : 0 : return;
1068 : : }
1069 : : }
1070 : : }
1071 : : else
1072 : 0 : free (buffer);
1073 : : #endif
1074 : : }
1075 : :
1076 : : /* Try to find a symbol table in either MOD->main.elf or MOD->debug.elf. */
1077 : : static void
1078 : 2585670 : find_symtab (Dwfl_Module *mod)
1079 : : {
1080 [ + + + + ]: 2585670 : if (mod->symdata != NULL || mod->aux_symdata != NULL /* Already done. */
1081 [ + + ]: 682 : || mod->symerr != DWFL_E_NOERROR) /* Cached previous failure. */
1082 : 2585020 : return;
1083 : :
1084 : 668 : __libdwfl_getelf (mod);
1085 : 668 : mod->symerr = mod->elferr;
1086 [ + + ]: 668 : if (mod->symerr != DWFL_E_NOERROR)
1087 : : return;
1088 : :
1089 : : /* First see if the main ELF file has the debugging information. */
1090 : 662 : Elf_Scn *symscn = NULL, *xndxscn = NULL;
1091 : 662 : Elf_Scn *aux_symscn = NULL, *aux_xndxscn = NULL;
1092 : 662 : GElf_Word strshndx, aux_strshndx = 0;
1093 : 662 : mod->symerr = load_symtab (&mod->main, &mod->symfile, &symscn,
1094 : : &xndxscn, &mod->syments, &mod->first_global,
1095 : : &strshndx);
1096 [ + + - ]: 662 : switch (mod->symerr)
1097 : : {
1098 : : default:
1099 : : return;
1100 : :
1101 : : case DWFL_E_NOERROR:
1102 : : break;
1103 : :
1104 : 196 : case DWFL_E_NO_SYMTAB:
1105 : : /* Now we have to look for a separate debuginfo file. */
1106 : 196 : mod->symerr = find_debuginfo (mod);
1107 [ + + - ]: 196 : switch (mod->symerr)
1108 : : {
1109 : : default:
1110 : : return;
1111 : :
1112 : 62 : case DWFL_E_NOERROR:
1113 : 62 : mod->symerr = load_symtab (&mod->debug, &mod->symfile, &symscn,
1114 : : &xndxscn, &mod->syments,
1115 : : &mod->first_global, &strshndx);
1116 : 62 : break;
1117 : :
1118 : 134 : case DWFL_E_CB: /* The find_debuginfo hook failed. */
1119 : 134 : mod->symerr = DWFL_E_NO_SYMTAB;
1120 : 134 : break;
1121 : : }
1122 : :
1123 [ + + - ]: 196 : switch (mod->symerr)
1124 : : {
1125 : : default:
1126 : : return;
1127 : :
1128 : : case DWFL_E_NOERROR:
1129 : : break;
1130 : :
1131 : 136 : case DWFL_E_NO_SYMTAB:
1132 : : /* There might be an auxiliary table. */
1133 : 136 : find_aux_sym (mod, &aux_symscn, &aux_xndxscn, &aux_strshndx);
1134 : :
1135 [ + + ]: 136 : if (symscn != NULL)
1136 : : {
1137 : : /* We still have the dynamic symbol table. */
1138 : 122 : mod->symerr = DWFL_E_NOERROR;
1139 : 122 : break;
1140 : : }
1141 : :
1142 [ + + ]: 14 : if (aux_symscn != NULL)
1143 : : {
1144 : : /* We still have the auxiliary symbol table. */
1145 : 2 : mod->symerr = DWFL_E_NOERROR;
1146 : 2 : goto aux_cache;
1147 : : }
1148 : :
1149 : : /* Last ditch, look for dynamic symbols without section headers. */
1150 : 12 : find_dynsym (mod);
1151 : 12 : return;
1152 : : }
1153 : : break;
1154 : : }
1155 : :
1156 : : /* This does some sanity checks on the string table section. */
1157 [ - + ]: 648 : if (elf_strptr (mod->symfile->elf, strshndx, 0) == NULL)
1158 : : {
1159 : 0 : elferr:
1160 : 0 : mod->symdata = NULL;
1161 : 0 : mod->syments = 0;
1162 : 0 : mod->first_global = 0;
1163 : 0 : mod->symerr = DWFL_E (LIBELF, elf_errno ());
1164 : 0 : goto aux_cleanup; /* This cleans up some more and tries find_dynsym. */
1165 : : }
1166 : :
1167 : : /* Cache the data; MOD->syments and MOD->first_global were set
1168 : : above. If any of the sections is compressed, uncompress it
1169 : : first. Only the string data section could theoretically be
1170 : : compressed GNU style (as .zdebug_str). Everything else only ELF
1171 : : gabi style (SHF_COMPRESSED). */
1172 : :
1173 : 648 : Elf_Scn *symstrscn = elf_getscn (mod->symfile->elf, strshndx);
1174 [ - + ]: 648 : if (symstrscn == NULL)
1175 : 0 : goto elferr;
1176 : :
1177 : 648 : GElf_Shdr shdr_mem;
1178 : 648 : GElf_Shdr *shdr = gelf_getshdr (symstrscn, &shdr_mem);
1179 [ - + ]: 648 : if (shdr == NULL)
1180 : 0 : goto elferr;
1181 : :
1182 : 648 : size_t shstrndx;
1183 [ - + ]: 648 : if (elf_getshdrstrndx (mod->symfile->elf, &shstrndx) < 0)
1184 : 0 : goto elferr;
1185 : :
1186 : 648 : const char *sname = elf_strptr (mod->symfile->elf, shstrndx, shdr->sh_name);
1187 [ - + ]: 648 : if (sname == NULL)
1188 : 0 : goto elferr;
1189 : :
1190 [ - + ]: 648 : if (startswith (sname, ".zdebug"))
1191 : : /* Try to uncompress, but it might already have been, an error
1192 : : might just indicate, already uncompressed. */
1193 : 0 : elf_compress_gnu (symstrscn, 0, 0);
1194 : :
1195 [ - + ]: 648 : if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
1196 [ # # ]: 0 : if (elf_compress (symstrscn, 0, 0) < 0)
1197 : 0 : goto elferr;
1198 : :
1199 : 648 : mod->symstrdata = elf_getdata (symstrscn, NULL);
1200 [ + - - + ]: 648 : if (mod->symstrdata == NULL || mod->symstrdata->d_buf == NULL)
1201 : 0 : goto elferr;
1202 : : else
1203 : 648 : validate_strdata (mod->symstrdata);
1204 : :
1205 [ + - ]: 648 : if (xndxscn == NULL)
1206 : 648 : mod->symxndxdata = NULL;
1207 : : else
1208 : : {
1209 : 0 : shdr = gelf_getshdr (xndxscn, &shdr_mem);
1210 [ # # ]: 0 : if (shdr == NULL)
1211 : 0 : goto elferr;
1212 : :
1213 [ # # ]: 0 : if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
1214 [ # # ]: 0 : if (elf_compress (xndxscn, 0, 0) < 0)
1215 : 0 : goto elferr;
1216 : :
1217 : 0 : mod->symxndxdata = elf_getdata (xndxscn, NULL);
1218 [ # # # # ]: 0 : if (mod->symxndxdata == NULL || mod->symxndxdata->d_buf == NULL)
1219 : 0 : goto elferr;
1220 : : }
1221 : :
1222 : 648 : shdr = gelf_getshdr (symscn, &shdr_mem);
1223 [ - + ]: 648 : if (shdr == NULL)
1224 : 0 : goto elferr;
1225 : :
1226 [ - + ]: 648 : if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
1227 [ # # ]: 0 : if (elf_compress (symscn, 0, 0) < 0)
1228 : 0 : goto elferr;
1229 : :
1230 : 648 : mod->symdata = elf_getdata (symscn, NULL);
1231 [ + - - + ]: 648 : if (mod->symdata == NULL || mod->symdata->d_buf == NULL)
1232 : 0 : goto elferr;
1233 : :
1234 : : // Sanity check number of symbols.
1235 : 648 : shdr = gelf_getshdr (symscn, &shdr_mem);
1236 [ + - + - ]: 648 : if (shdr == NULL || shdr->sh_entsize == 0
1237 [ + - ]: 648 : || mod->syments > mod->symdata->d_size / shdr->sh_entsize
1238 [ - + ]: 648 : || (size_t) mod->first_global > mod->syments)
1239 : 0 : goto elferr;
1240 : :
1241 : : /* Cache any auxiliary symbol info, when it fails, just ignore aux_sym. */
1242 [ + + ]: 648 : if (aux_symscn != NULL)
1243 : : {
1244 : 74 : aux_cache:
1245 : : /* This does some sanity checks on the string table section. */
1246 [ - + ]: 76 : if (elf_strptr (mod->aux_sym.elf, aux_strshndx, 0) == NULL)
1247 : : {
1248 : 0 : aux_cleanup:
1249 : 0 : mod->aux_syments = 0;
1250 : 0 : elf_end (mod->aux_sym.elf);
1251 : 0 : mod->aux_sym.elf = NULL;
1252 : : /* We thought we had something through shdrs, but it failed...
1253 : : Last ditch, look for dynamic symbols without section headers. */
1254 : 0 : find_dynsym (mod);
1255 : 0 : return;
1256 : : }
1257 : :
1258 : 76 : Elf_Scn *aux_strscn = elf_getscn (mod->aux_sym.elf, aux_strshndx);
1259 [ - + ]: 76 : if (aux_strscn == NULL)
1260 : 0 : goto elferr;
1261 : :
1262 : 76 : shdr = gelf_getshdr (aux_strscn, &shdr_mem);
1263 [ - + ]: 76 : if (shdr == NULL)
1264 : 0 : goto elferr;
1265 : :
1266 : 76 : size_t aux_shstrndx;
1267 [ - + ]: 76 : if (elf_getshdrstrndx (mod->aux_sym.elf, &aux_shstrndx) < 0)
1268 : 0 : goto elferr;
1269 : :
1270 : 152 : sname = elf_strptr (mod->aux_sym.elf, aux_shstrndx,
1271 : 76 : shdr->sh_name);
1272 [ - + ]: 76 : if (sname == NULL)
1273 : 0 : goto elferr;
1274 : :
1275 [ - + ]: 76 : if (startswith (sname, ".zdebug"))
1276 : : /* Try to uncompress, but it might already have been, an error
1277 : : might just indicate, already uncompressed. */
1278 : 0 : elf_compress_gnu (aux_strscn, 0, 0);
1279 : :
1280 [ - + ]: 76 : if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
1281 [ # # ]: 0 : if (elf_compress (aux_strscn, 0, 0) < 0)
1282 : 0 : goto elferr;
1283 : :
1284 : 76 : mod->aux_symstrdata = elf_getdata (aux_strscn, NULL);
1285 [ + - - + ]: 76 : if (mod->aux_symstrdata == NULL || mod->aux_symstrdata->d_buf == NULL)
1286 : 0 : goto aux_cleanup;
1287 : : else
1288 : 76 : validate_strdata (mod->aux_symstrdata);
1289 : :
1290 [ + - ]: 76 : if (aux_xndxscn == NULL)
1291 : 76 : mod->aux_symxndxdata = NULL;
1292 : : else
1293 : : {
1294 : 0 : shdr = gelf_getshdr (aux_xndxscn, &shdr_mem);
1295 [ # # ]: 0 : if (shdr == NULL)
1296 : 0 : goto elferr;
1297 : :
1298 [ # # ]: 0 : if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
1299 [ # # ]: 0 : if (elf_compress (aux_xndxscn, 0, 0) < 0)
1300 : 0 : goto elferr;
1301 : :
1302 : 0 : mod->aux_symxndxdata = elf_getdata (aux_xndxscn, NULL);
1303 [ # # ]: 0 : if (mod->aux_symxndxdata == NULL
1304 [ # # ]: 0 : || mod->aux_symxndxdata->d_buf == NULL)
1305 : 0 : goto aux_cleanup;
1306 : : }
1307 : :
1308 : 76 : shdr = gelf_getshdr (aux_symscn, &shdr_mem);
1309 [ - + ]: 76 : if (shdr == NULL)
1310 : 0 : goto elferr;
1311 : :
1312 [ - + ]: 76 : if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
1313 [ # # ]: 0 : if (elf_compress (aux_symscn, 0, 0) < 0)
1314 : 0 : goto elferr;
1315 : :
1316 : 76 : mod->aux_symdata = elf_getdata (aux_symscn, NULL);
1317 [ + - - + ]: 76 : if (mod->aux_symdata == NULL || mod->aux_symdata->d_buf == NULL)
1318 : 0 : goto aux_cleanup;
1319 : :
1320 : : // Sanity check number of aux symbols.
1321 : 76 : shdr = gelf_getshdr (aux_symscn, &shdr_mem);
1322 [ + - ]: 76 : if (mod->aux_syments > mod->aux_symdata->d_size / shdr->sh_entsize
1323 [ - + ]: 76 : || (size_t) mod->aux_first_global > mod->aux_syments)
1324 : 0 : goto aux_cleanup;
1325 : : }
1326 : : }
1327 : :
1328 : :
1329 : : /* Try to open a libebl backend for MOD. */
1330 : : Dwfl_Error
1331 : : internal_function
1332 : 18255336 : __libdwfl_module_getebl (Dwfl_Module *mod)
1333 : : {
1334 [ + + ]: 18255336 : if (mod->ebl == NULL)
1335 : : {
1336 : 910 : __libdwfl_getelf (mod);
1337 [ + - ]: 910 : if (mod->elferr != DWFL_E_NOERROR)
1338 : : return mod->elferr;
1339 : :
1340 : 910 : mod->ebl = ebl_openbackend (mod->main.elf);
1341 [ + - ]: 910 : if (mod->ebl == NULL)
1342 : : return DWFL_E_LIBEBL;
1343 : : }
1344 : : return DWFL_E_NOERROR;
1345 : : }
1346 : :
1347 : : /* Try to start up libdw on DEBUGFILE. */
1348 : : static Dwfl_Error
1349 : 11162 : load_dw (Dwfl_Module *mod, struct dwfl_file *debugfile)
1350 : : {
1351 [ + + + + ]: 11162 : if (mod->e_type == ET_REL && !debugfile->relocated)
1352 : : {
1353 : 88 : const Dwfl_Callbacks *const cb = mod->dwfl->callbacks;
1354 : :
1355 : : /* The debugging sections have to be relocated. */
1356 [ + - ]: 88 : if (cb->section_address == NULL)
1357 : : return DWFL_E_NOREL;
1358 : :
1359 : 88 : Dwfl_Error error = __libdwfl_module_getebl (mod);
1360 [ + - ]: 88 : if (error != DWFL_E_NOERROR)
1361 : : return error;
1362 : :
1363 : 88 : find_symtab (mod);
1364 : 88 : Dwfl_Error result = mod->symerr;
1365 [ + - ]: 88 : if (result == DWFL_E_NOERROR)
1366 : 88 : result = __libdwfl_relocate (mod, debugfile->elf, true);
1367 [ - + ]: 88 : if (result != DWFL_E_NOERROR)
1368 : 0 : return result;
1369 : : }
1370 : :
1371 : 11162 : mod->dw = INTUSE(dwarf_begin_elf) (debugfile->elf, DWARF_C_READ, NULL);
1372 [ + + ]: 11162 : if (mod->dw == NULL)
1373 : : {
1374 : 308 : int err = INTUSE(dwarf_errno) ();
1375 [ + + ]: 308 : return err == DWARF_E_NO_DWARF ? DWFL_E_NO_DWARF : DWFL_E (LIBDW, err);
1376 : : }
1377 : :
1378 : : /* Do this after dwarf_begin_elf has a chance to process the fd. */
1379 [ + + + + ]: 10854 : if (mod->e_type == ET_REL && !debugfile->relocated)
1380 : : {
1381 : : /* Don't keep the file descriptors around. */
1382 [ - + - - ]: 72 : if (mod->main.fd != -1 && elf_cntl (mod->main.elf, ELF_C_FDREAD) == 0)
1383 : : {
1384 : 0 : close (mod->main.fd);
1385 : 0 : mod->main.fd = -1;
1386 : : }
1387 [ + + + - ]: 72 : if (debugfile->fd != -1 && elf_cntl (debugfile->elf, ELF_C_FDREAD) == 0)
1388 : : {
1389 : 2 : close (debugfile->fd);
1390 : 2 : debugfile->fd = -1;
1391 : : }
1392 : : }
1393 : :
1394 : : /* We might have already closed the fd when we asked dwarf_begin_elf to
1395 : : create an Dwarf. Help out a little in case we need to find an alt,
1396 : : dwo, or dwp file later. */
1397 [ + + + + ]: 10854 : if (mod->dw->elfpath == NULL && mod->elfpath != NULL
1398 [ + - ]: 724 : && debugfile == &mod->main)
1399 : : {
1400 : 724 : mod->dw->elfpath = strdup (mod->elfpath);
1401 : 724 : __libdw_set_debugdir (mod->dw);
1402 : : }
1403 : :
1404 : : /* Until we have iterated through all CU's, we might do lazy lookups. */
1405 : 10854 : mod->lazycu = 1;
1406 : :
1407 : 10854 : return DWFL_E_NOERROR;
1408 : : }
1409 : :
1410 : : /* Try to start up libdw on either the main file or the debuginfo file. */
1411 : : static void
1412 : 24364 : find_dw (Dwfl_Module *mod)
1413 : : {
1414 [ + + ]: 24364 : if (mod->dw != NULL /* Already done. */
1415 [ + + ]: 11590 : || mod->dwerr != DWFL_E_NOERROR) /* Cached previous failure. */
1416 : : return;
1417 : :
1418 : 11118 : __libdwfl_getelf (mod);
1419 : 11118 : mod->dwerr = mod->elferr;
1420 [ + + ]: 11118 : if (mod->dwerr != DWFL_E_NOERROR)
1421 : : return;
1422 : :
1423 : : /* First see if the main ELF file has the debugging information. */
1424 : 11070 : mod->dwerr = load_dw (mod, &mod->main);
1425 [ + + + ]: 11070 : switch (mod->dwerr)
1426 : : {
1427 : 10762 : case DWFL_E_NOERROR:
1428 : : /* main.elf already should have had __libdwfl_reset_sh_addr called. */
1429 : 10762 : mod->debug.elf = mod->main.elf;
1430 : 10762 : mod->debug.address_sync = mod->main.address_sync;
1431 : :
1432 : : /* The Dwarf might need an alt debug file, find that now after
1433 : : everything about the debug file has been setup (the
1434 : : find_debuginfo callback might need it). */
1435 : 10762 : find_debug_altlink (mod, mod->main.name);
1436 : 10762 : return;
1437 : :
1438 : : case DWFL_E_NO_DWARF:
1439 : 306 : break;
1440 : :
1441 : 2 : default:
1442 : 2 : goto canonicalize;
1443 : : }
1444 : :
1445 : : /* Now we have to look for a separate debuginfo file. */
1446 : 306 : mod->dwerr = find_debuginfo (mod);
1447 [ + + - ]: 306 : switch (mod->dwerr)
1448 : : {
1449 : 92 : case DWFL_E_NOERROR:
1450 : 92 : mod->dwerr = load_dw (mod, &mod->debug);
1451 [ + - ]: 92 : if (mod->dwerr == DWFL_E_NOERROR)
1452 : : {
1453 : : /* The Dwarf might need an alt debug file, find that now after
1454 : : everything about the debug file has been setup (the
1455 : : find_debuginfo callback might need it). */
1456 : 92 : find_debug_altlink (mod, mod->debug.name);
1457 : 92 : return;
1458 : : }
1459 : :
1460 : : break;
1461 : :
1462 : 214 : case DWFL_E_CB: /* The find_debuginfo hook failed. */
1463 : 214 : mod->dwerr = DWFL_E_NO_DWARF;
1464 : 214 : return;
1465 : :
1466 : : default:
1467 : : break;
1468 : : }
1469 : :
1470 : 2 : canonicalize:
1471 : 2 : mod->dwerr = __libdwfl_canon_error (mod->dwerr);
1472 : : }
1473 : :
1474 : : Dwarf *
1475 : 24364 : dwfl_module_getdwarf (Dwfl_Module *mod, Dwarf_Addr *bias)
1476 : : {
1477 [ - + ]: 24364 : if (mod == NULL)
1478 : : return NULL;
1479 : :
1480 : 24364 : find_dw (mod);
1481 [ + + ]: 24364 : if (mod->dwerr == DWFL_E_NOERROR)
1482 : : {
1483 : : /* If dwfl_module_getelf was used previously, then partial apply
1484 : : relocation to miscellaneous sections in the debug file too. */
1485 [ + + ]: 23628 : if (mod->e_type == ET_REL
1486 [ + + + + ]: 250 : && mod->main.relocated && ! mod->debug.relocated)
1487 : : {
1488 : 126 : mod->debug.relocated = true;
1489 [ - + ]: 126 : if (mod->debug.elf != mod->main.elf)
1490 : 0 : (void) __libdwfl_relocate (mod, mod->debug.elf, false);
1491 : : }
1492 : :
1493 : 23628 : *bias = dwfl_adjusted_dwarf_addr (mod, 0);
1494 : 23628 : return mod->dw;
1495 : : }
1496 : :
1497 : 736 : __libdwfl_seterrno (mod->dwerr);
1498 : 736 : return NULL;
1499 : : }
1500 : : INTDEF (dwfl_module_getdwarf)
1501 : :
1502 : : int
1503 : 2570558 : dwfl_module_getsymtab (Dwfl_Module *mod)
1504 : : {
1505 [ - + ]: 2570558 : if (mod == NULL)
1506 : : return -1;
1507 : :
1508 : 2570558 : find_symtab (mod);
1509 [ + + ]: 2570558 : if (mod->symerr == DWFL_E_NOERROR)
1510 : : /* We will skip the auxiliary zero entry if there is another one. */
1511 : 2570536 : return (mod->syments + mod->aux_syments
1512 [ + + + + ]: 5140530 : - (mod->syments > 0 && mod->aux_syments > 0 ? 1 : 0));
1513 : :
1514 : 22 : __libdwfl_seterrno (mod->symerr);
1515 : 22 : return -1;
1516 : : }
1517 : : INTDEF (dwfl_module_getsymtab)
1518 : :
1519 : : int
1520 : 15024 : dwfl_module_getsymtab_first_global (Dwfl_Module *mod)
1521 : : {
1522 [ - + ]: 15024 : if (mod == NULL)
1523 : : return -1;
1524 : :
1525 : 15024 : find_symtab (mod);
1526 [ + - ]: 15024 : if (mod->symerr == DWFL_E_NOERROR)
1527 : : {
1528 : : /* All local symbols should come before all global symbols. If
1529 : : we have an auxiliary table make sure all the main locals come
1530 : : first, then all aux locals, then all main globals and finally all
1531 : : aux globals. And skip the auxiliary table zero undefined
1532 : : entry. */
1533 [ + + + + ]: 15024 : int skip_aux_zero = (mod->syments > 0 && mod->aux_syments > 0) ? 1 : 0;
1534 : 15024 : return mod->first_global + mod->aux_first_global - skip_aux_zero;
1535 : : }
1536 : :
1537 : 0 : __libdwfl_seterrno (mod->symerr);
1538 : 0 : return -1;
1539 : : }
1540 : : INTDEF (dwfl_module_getsymtab_first_global)
|