|
17 | 17 | import errno
|
18 | 18 | import logging
|
19 | 19 | import functools
|
20 |
| -from typing import List, Dict, Optional, Any |
| 20 | +from typing import List, Dict, Optional, Any, Tuple |
21 | 21 |
|
22 |
| -from elftools.elf.elffile import ELFFile # type: ignore |
| 22 | +from elftools.elf.elffile import ELFFile |
23 | 23 |
|
24 | 24 | log = logging.getLogger(__name__)
|
25 | 25 | __all__ = ['lddtree']
|
@@ -75,7 +75,7 @@ def dedupe(items: List[str]) -> List[str]:
|
75 | 75 | return [seen.setdefault(x, x) for x in items if x not in seen]
|
76 | 76 |
|
77 | 77 |
|
78 |
| -def parse_ld_paths(str_ldpaths, root='', path=None) -> List[str]: |
| 78 | +def parse_ld_paths(str_ldpaths: str, path: str, root: str = '') -> List[str]: |
79 | 79 | """Parse the colon-delimited list of paths and apply ldso rules to each
|
80 | 80 |
|
81 | 81 | Note the special handling as dictated by the ldso:
|
@@ -204,7 +204,7 @@ def load_ld_paths(root: str = '/', prefix: str = '') -> Dict[str, List[str]]:
|
204 | 204 | return ldpaths
|
205 | 205 |
|
206 | 206 |
|
207 |
| -def compatible_elfs(elf1, elf2): |
| 207 | +def compatible_elfs(elf1: ELFFile, elf2: ELFFile) -> bool: |
208 | 208 | """See if two ELFs are compatible
|
209 | 209 |
|
210 | 210 | This compares the aspects of the ELF to see if they're compatible:
|
@@ -232,7 +232,8 @@ def compatible_elfs(elf1, elf2):
|
232 | 232 | elf1.header['e_machine'] == elf2.header['e_machine'])
|
233 | 233 |
|
234 | 234 |
|
235 |
| -def find_lib(elf, lib, ldpaths, root='/'): |
| 235 | +def find_lib(elf: ELFFile, lib: str, ldpaths: List[str], |
| 236 | + root: str = '/') -> Tuple[Optional[str], Optional[str]]: |
236 | 237 | """Try to locate a ``lib`` that is compatible to ``elf`` in the given
|
237 | 238 | ``ldpaths``
|
238 | 239 |
|
@@ -370,13 +371,13 @@ def lddtree(path: str,
|
370 | 371 | if t.entry.d_tag == 'DT_RPATH':
|
371 | 372 | rpaths = parse_ld_paths(
|
372 | 373 | t.rpath,
|
373 |
| - root=root, |
374 |
| - path=path) |
| 374 | + path=path, |
| 375 | + root=root) |
375 | 376 | elif t.entry.d_tag == 'DT_RUNPATH':
|
376 | 377 | runpaths = parse_ld_paths(
|
377 | 378 | t.runpath,
|
378 |
| - root=root, |
379 |
| - path=path) |
| 379 | + path=path, |
| 380 | + root=root) |
380 | 381 | elif t.entry.d_tag == 'DT_NEEDED':
|
381 | 382 | libs.append(t.needed)
|
382 | 383 | if runpaths:
|
@@ -412,7 +413,7 @@ def lddtree(path: str,
|
412 | 413 | 'path': fullpath,
|
413 | 414 | 'needed': [],
|
414 | 415 | }
|
415 |
| - if fullpath: |
| 416 | + if realpath and fullpath: |
416 | 417 | lret = lddtree(realpath,
|
417 | 418 | root,
|
418 | 419 | prefix,
|
|
0 commit comments