summaryrefslogtreecommitdiff
path: root/toolkit/library/dependentlibs.py
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-11-13 11:46:33 +0000
committerMoonchild <moonchild@palemoon.org>2023-11-13 11:46:33 +0000
commita36a691826d9ea9ad4c564f2d27905f267a5e53d (patch)
treed4507995775ce9fff688d937693f911b85c0bf13 /toolkit/library/dependentlibs.py
parent9816215ea7461dfbb1707809344b5d569ad615e3 (diff)
parent98f59fb96c80bb8664e0931eaead9c70898ed5a5 (diff)
downloaduxp-a36a691826d9ea9ad4c564f2d27905f267a5e53d.tar.gz
Merge pull request 'Use elfdump on SunOS instead of readelf.' (#2380) from athenian200/UXP:sunos-elfdump-fix into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/2380
Diffstat (limited to 'toolkit/library/dependentlibs.py')
-rw-r--r--toolkit/library/dependentlibs.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/toolkit/library/dependentlibs.py b/toolkit/library/dependentlibs.py
index f2135d7c30..958fe5ef1d 100644
--- a/toolkit/library/dependentlibs.py
+++ b/toolkit/library/dependentlibs.py
@@ -50,6 +50,23 @@ def dependentlibs_mingw_objdump(lib):
proc.wait()
return deps
+def dependentlibs_elfdump(lib):
+ '''Returns the list of dependencies declared in the given ELF .so'''
+ proc = subprocess.Popen(['elfdump', '-N', '.dynamic', lib], stdout = subprocess.PIPE)
+ deps = []
+ for line in proc.stdout:
+ # Each line has the following format:
+ # index TYPE tag value
+ tmp = line
+ if len(tmp) > 3 and 'NEEDED' in tmp:
+ # NEEDED lines look like:
+ # [1] NEEDED 0x0000001 libname
+ match = re.search(r'(lib\w+.so.*)', tmp)
+ if match:
+ deps.append(match.group(1))
+ proc.wait()
+ return deps
+
def dependentlibs_readelf(lib):
'''Returns the list of dependencies declared in the given ELF .so'''
proc = subprocess.Popen([substs.get('TOOLCHAIN_PREFIX', '') + 'readelf', '-d', lib], stdout = subprocess.PIPE)
@@ -118,7 +135,10 @@ def dependentlibs(lib, libpaths, func):
def gen_list(output, lib):
libpaths = [os.path.join(substs['DIST'], 'bin')]
binary_type = get_type(lib)
- if binary_type == ELF:
+ if substs['OS_ARCH'] == 'SunOS':
+ # If we're on SunOS, we're using ELF, but can't rely on readelf.
+ func = dependentlibs_elfdump
+ elif binary_type == ELF:
func = dependentlibs_readelf
elif binary_type == MACHO:
func = dependentlibs_otool