aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* lddtree: add docstring for all classesMike Frysinger2023-12-141-0/+2
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: reformat with blackMike Frysinger2022-09-281-209/+294
| | | | | | Largely this is just single quotes -> double quotes. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: avoid shadowing function argsMike Frysinger2022-09-281-8/+8
| | | | | | | pylint warns about redefining |lib| here, and it's right -- the code is a little hard to follow because of it. So give it a diff name. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: simplify join logicMike Frysinger2022-09-281-2/+3
| | | | | | No need to create a list to past to join when we can pass a generator. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: add typing info to more placesMike Frysinger2022-09-281-26/+61
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: switch to f-strings in most placesMike Frysinger2022-09-281-17/+18
| | | | | | These are a bit more readable than % formatting. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: Add logging for ELFParseErrorManoj Gupta2022-09-281-1/+5
| | | | | | | | | Add logging inside parseELF to print the bad file if the parser fails with ELFParseError. Bug: https://issuetracker.google.com/issues/203821449 Signed-off-by: Manoj Gupta <manojgupta@chromium.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: specify utf-8 encoding with text filesMike Frysinger2022-09-211-2/+2
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: sort importsMike Frysinger2022-09-211-2/+2
| | | | | | Should be no functional change. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: update CrOS copyright lineMike Frysinger2022-09-211-1/+1
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: add --skip-missingJae Hoon Kim2022-03-091-1/+5
| | | | | | | | | | | | | | | | Allow explicitly ignoring missing files. $ lddtree --root=/build/$BOARD --copy-to-tree=. --copy-non-elfs /sbin/lvm /sbin/lvmdump lddtree: warning: /build/brya/sbin/lvm: did not match any paths $ echo $? 1 lddtree --root=/build/$BOARD --copy-to-tree=. --copy-non-elfs --skip-missing /sbin/lvm /sbin/lvmdump lddtree: warning: /build/brya/sbin/lvm: did not match any paths $ echo $? 0 Signed-off-by: Jae Hoon Kim <kimjae@chromium.org> Signed-off-by: Mike Frysinger <vapier@chromiium.org>
* lddtree: add argcomplete support if availableMike Frysinger2021-12-171-0/+8
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: respect (destination) root with --argv0 interp probingMike Frysinger2021-04-191-1/+1
| | | | | | | | | | | This is important because the path in this func reflects where the interpreter is going to be living, not where it's being copied from. These are often the same paths (relatively speaking), but when we're copying from a cross-compiler sysroot, or when using --libdir so the target paths are rewritten, the interp path probably does not line up with whatever happens to live in the active rootfs. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: add --cwd optionMike Frysinger2021-04-161-20/+30
| | | | | | | | Rather than rely on ambient environmental settings (the cwd), allow users to override the cwd explicitly when processing paths. Bug: https://bugs.gentoo.org/653586 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: handle relative ldpathsMike Frysinger2021-04-161-5/+16
| | | | | | | | | Tweak the ldpath logic to handle all relative paths relative to the cwd instead of the root. Such ELFs are uncommon and weird, but not invalid, so might as well. Bug: https://bugs.gentoo.org/653586 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: handle ${ORIGIN} like $ORIGINMike Frysinger2021-04-161-0/+2
| | | | | Bug: https://bugs.gentoo.org/653586 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: use ldso's --argv0 when availableMike Frysinger2021-04-151-6/+20
| | | | | | | | | Newer glibc has a --argv0 option in current releases to explicitly set argv[0]. This is useful for the generated shell wrappers as we need to rename it (with an .elf suffix) and that can either confuse the output or break tools that inspect their argv[0] strictly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: apply functools cache to some repeated filesystem callsMike Frysinger2021-04-151-0/+3
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: don't crash when interp is missingMike Frysinger2021-04-151-1/+7
| | | | | | | | | | | Easy way to reproduce is to copy a cross-compile ELF like: $ ./lddtree.py --copy-to-tree $PWD/foo /usr/share/qemu/s390-ccw.img lddtree.py: warning: /usr/share/qemu/s390-ccw.img: [Errno 2] No such file or directory: '/lib/ld64.so.1' We have checks for missing libs already, but interps are full paths and thus bypass the resolution logic. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: require Python 3.6+Mike Frysinger2021-04-151-13/+3
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree: re-enable long line checksMike Frysinger2021-04-151-2/+7
| | | | | | | | | Adjust our line length to be 100 cols. This matches what the code has largely been using already, and it fits better with modern systems. People can still write to 80 cols as makes sense, but we'll consider that a soft limit with 100 cols as the upper hard limit. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* pylintrc: adjust python code to 4 space indentMike Frysinger2021-04-151-635/+635
| | | | | | | | | | | This aligns with the latest Google/PEP standards. This doesn't add any pylint warnings as we've been disabling long lines in here for a long time. We don't do any other reformatting to try and cut down on git log/diff noise. Looking at this with --word-diff=color shows only whitespace changes. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Fix typo in module docstringv1.2.7Georg Brandl2020-10-051-1/+1
| | | | | Closes: https://github.com/gentoo/pax-utils/pull/4 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* lddtree: Put ldso interpreter library path at endManoj Gupta2020-03-261-1/+2
| | | | | | | | | | | | | | Put ldso interpreter library path at end of libpaths search. It is supposed to be a final fallback path in case library search was incomplete. As a side effect, it currently mitigates the incorrect libbfd being loaded for aarch64 standalone toolchain. Bug: https://crbug.com/917193 Reviewed-on: https://crrev.com/c/1920643 Signed-off-by: Manoj Gupta <manojgupta@chromium.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* pylintrc: enable more warningsMike Frysinger2020-03-261-1/+1
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lddtree.py: resolve python location through PATHSergei Trofimovich2020-02-161-1/+1
| | | | | | This allows running testsuite as-is on prefix. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* lddtree.py: use errno properlyOleksandr Natalenko2018-11-191-1/+1
| | | | | | | | | | | | os.errno interface is removed [1], thus should not be used. In fact, it is not used in other places of lddtree.py, so fix this one too, because it breaks --copy-to-tree on systems with Python 3.7. [1] https://bugs.python.org/issue33666 Bug: https://bugs.gentoo.org/671522 Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* lddtree: move parser logic into a funcMike Frysinger2017-02-161-2/+8
| | | | This keeps the main func a bit cleaner.
* pylint: add a helper to keep python code cleanMike Frysinger2017-02-161-5/+11
| | | | Fix up some lddtree logic at the same time so it's warning free.
* lddtree.py: work around pyelftools API changeMike Gilbert2016-11-081-0/+2
| | | | | | | Section names now get returned as strings rather than bytes. See 108eaea9 upstream. Bug: https://bugs.gentoo.org/599082
* lddtree: always inhibit the cacheMike Frysinger2016-05-131-0/+1
| | | | | | Make sure that the wrapped binaries don't use the host's ld.so.cache. This probably shouldn't show up since we're using --library-path, but in case that doesn't stop things, explicitly disable the search.
* lddtree: handle exceptions thrown when parsing other ELFsMike Frysinger2016-01-281-5/+11
| | | | | | | | | | | | | | | 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
* lddtree.py: fix glob handling w/ld.so.confMike Frysinger2015-08-201-1/+5
| | | | | | | | glibc's glob handling of ld.so.conf includes ends up sorting the results (since the glob func sorts by default), but python does not. We need to sort things explicitly ourselves. Reported-by: Tomasz Buchert <tomasz@debian.org>
* lddtree: handle direct ldso linkage betterv1.0.5Mike Frysinger2015-07-201-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | If the ELF we're showing is linked directly against the ELF which is used as the ELF interp (i.e. the ldso), make sure we don't list it twice. We want to see it "twice" in the pretty form: $ ./lddtree.py /bin/bash /bin/bash (interpreter => /lib/ld-linux-armhf.so.3) <= here libreadline.so.6 => /lib/libreadline.so.6 libncurses.so.5 => /lib/libncurses.so.5 libc.so.6 => /lib/libc.so.6 ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3 <= here But not in the list form (as that is used by scripts): $ ./lddtree.py -l /bin/bash /bin/bash /lib/ld-linux-armhf.so.3 <= only here /lib/libreadline.so.6 /lib/libncurses.so.5 /lib/libc.so.6 We also reconcile a few differences wrt interp display and the sh/py implementations. Reported-by: Tomasz Buchert <tomasz@debian.org>
* lddtree.py: convert to arparseMike Frysinger2015-06-041-93/+91
|
* lddtree.py: dereference the interp symlink to handle desynced ABIs betterv1.0.2Mike Frysinger2015-03-101-4/+14
| | | | | | | | | | | | | | | | On aarch64/s390x, the interp is always placed in /lib/ while the libs are normally placed in /lib64/. If the interp is a symlink (which it normally is here), then dereference it to locate the lib paths automatically. This also fixes up some bad lstrip logic in the /usr path expansion. We could update lddtree.sh with a similar fix, but it would take more work as it doesn't have the readlink helper to properly walk symlinks according to an alternative root. Plus, it already uses strings to try and extract the paths the ldso was compiled against, and that seems to work in these cases. Reported-by: Jakub Čajka <jcajka@redhat.com> URL: https://bugzilla.redhat.com/1162184
* migrate to gitv1.0Mike Frysinger2015-03-021-3/+1
|
* lddtree.py: if we could not find the lib for copying, issue a warning and ↵Mike Frysinger2014-11-201-2/+5
| | | | skip the path
* lddtree.py: plumb down --debug into ParseLdSoConfMike Frysinger2014-11-201-7/+13
|
* lddtree.py: adjust style to fix pylint warningsMike Frysinger2014-11-201-67/+68
|
* lddtree.py: when parsing libs, make sure to pass down the realpath tooMike Frysinger2014-08-011-4/+4
|
* lddtree.py: drop TODO since we should handle symlinks nowMike Frysinger2014-08-011-4/+2
|
* lddtree.py: save the original path as well as the full path for symlinksMike Frysinger2014-07-301-19/+30
| | | | SONAMEs are usually symlinks, so we need to manually dereference them to get to the right file, but we want to save the original name so we can copy them to the right place
* lddtree: do symlink resolution on args on the command lineMike Frysinger2014-07-301-7/+25
| | | | This is needed when given a path which itself is an absolute symlink. If we deref it as-is, we end up poking into / instead of $ROOT.
* lddtree.py: when searching for libs, make sure we resolve symlinks inside ↵Mike Frysinger2014-07-301-5/+38
| | | | the root before checking if they exist
* lddtree.py: update ParseELF arg list after previous commitMike Frysinger2014-07-301-3/+3
|
* lddtree.py: rework debug handling and add a bit more throughout the processingMike Frysinger2014-07-301-16/+33
|
* lddtree.py: use basename of argv[0] for warnings as it looks nicerMike Frysinger2014-07-301-3/+3
|
* lddtree.py: update copyrightMike Frysinger2014-07-301-4/+5
|
* lddtree.py: initial prefix support by Benda Xu #488460v0.8Mike Frysinger2014-03-201-9/+17
|