aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2016-01-28 17:38:43 -0500
committerMike Frysinger <vapier@gentoo.org>2016-01-28 17:38:43 -0500
commit320b76139ae04eea3cbe74c424cda489bbf61882 (patch)
tree273a0ca219dcb1858186dd3e18e6f960aec1f0ce
parentpaxelf: add a helper for accessing e_flags (diff)
downloadpax-utils-320b76139ae04eea3cbe74c424cda489bbf61882.tar.gz
pax-utils-320b76139ae04eea3cbe74c424cda489bbf61882.tar.bz2
pax-utils-320b76139ae04eea3cbe74c424cda489bbf61882.zip
lddtree: handle exceptions thrown when parsing other ELFs
We have a top level exception handler for catching ELF errors, but if we hit a problem with a dependency, we end up diagnosing it as a problem in the first ELF. e.g. If "foo" is linked against "libc.so", and "libc.so" is a linker script, when we try to read the libc.so ELF, it fails, and we end up saying: lddtree: warning: foo: Magic number does not match This makes no sense because "foo" is a proper ELF with the right magic, and we end up halting the whole parsing process. Now we show: lddtree: warning: /usr/lib/libc.so: Magic number does not match foo (interpreter => /some/interp) libc.so => None
-rwxr-xr-xlddtree.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/lddtree.py b/lddtree.py
index 100f475..e663d32 100755
--- a/lddtree.py
+++ b/lddtree.py
@@ -338,9 +338,12 @@ def FindLib(elf, lib, ldpaths, root='/', debug=False):
if os.path.exists(target):
with open(target, 'rb') as f:
- libelf = ELFFile(f)
- if CompatibleELFs(elf, libelf):
- return (target, path)
+ try:
+ libelf = ELFFile(f)
+ if CompatibleELFs(elf, libelf):
+ return (target, path)
+ except exceptions.ELFError as e:
+ warn('%s: %s' % (target, e))
return (None, None)
@@ -475,8 +478,11 @@ def ParseELF(path, root='/', prefix='', ldpaths={'conf':[], 'env':[], 'interp':[
'needed': [],
}
if fullpath:
- lret = ParseELF(realpath, root, prefix, ldpaths, display=fullpath,
- debug=debug, _first=False, _all_libs=_all_libs)
+ try:
+ lret = ParseELF(realpath, root, prefix, ldpaths, display=fullpath,
+ debug=debug, _first=False, _all_libs=_all_libs)
+ except exceptions.ELFError as e:
+ warn('%s: %s' % (realpath, e))
_all_libs[lib]['needed'] = lret['needed']
del elf