From 54dad81646a10391c076d7346278735f41948c3f Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 21 Nov 2017 14:57:15 -0800 Subject: [PATCH] deploy-ng: Add RPATH to search_path when parsing ELF files --- direct/src/showutil/dist.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/direct/src/showutil/dist.py b/direct/src/showutil/dist.py index 7a43982a22..a480ccb871 100644 --- a/direct/src/showutil/dist.py +++ b/direct/src/showutil/dist.py @@ -428,7 +428,7 @@ class build_apps(distutils.core.Command): elif magic == b'\x7FELF': # Elf magic. Used on (among others) Linux and FreeBSD. - deps = self._read_dependencies_elf(fp) + deps = self._read_dependencies_elf(fp, os.path.dirname(source_path), search_path) elif magic in (b'\xFE\xED\xFA\xCE', b'\xCE\xFA\xED\xFE', b'\xFE\xED\xFA\xCF', b'\xCF\xFA\xED\xFE'): @@ -448,7 +448,7 @@ class build_apps(distutils.core.Command): for dep in deps: self.add_dependency(dep, target_dir, search_path, base) - def _read_dependencies_elf(self, elf): + def _read_dependencies_elf(self, elf, origin, search_path): """ Having read the first 4 bytes of the ELF file, fetches the dependent libraries and returns those as a list. """ @@ -499,13 +499,16 @@ class build_apps(distutils.core.Command): elif tag == 15 or tag == 29: # An RPATH or RUNPATH entry. string = string_tables[link][val : string_tables[link].find(b'\0', val)] - rpath += string.split(b':') + rpath += [ + os.path.normpath(i.decode('utf-8').replace('$ORIGIN', origin)) + for i in string.split(b':') + ] data = elf.read(entsize) tag, val = struct.unpack_from(dynamic_struct, data) elf.close() - #TODO: should we respect the RPATH? Clear it? Warn about it? + search_path += rpath return needed def _read_dependencies_macho(self, fp):