aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-04-06 10:18:07 +0800
committerfanquake <fanquake@gmail.com>2021-05-04 20:48:00 +0800
commit2aa1631822b2fdbc6cf7a3dcd99adaf4d2745ed4 (patch)
tree353fd92fd7edb8a5d2a19751014be5aa98438e5e /contrib
parente93ac26b8563576345c13e83c777dd39e7616b1e (diff)
downloadbitcoin-2aa1631822b2fdbc6cf7a3dcd99adaf4d2745ed4.tar.xz
contrib: use LIEF in PE symbol checks
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/devtools/symbol-check.py18
1 files changed, 3 insertions, 15 deletions
diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py
index a4ada73573..d740a94560 100755
--- a/contrib/devtools/symbol-check.py
+++ b/contrib/devtools/symbol-check.py
@@ -53,7 +53,6 @@ IGNORE_EXPORTS = {
'environ', '_environ', '__environ',
}
CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt')
-OBJDUMP_CMD = os.getenv('OBJDUMP', '/usr/bin/objdump')
# Allowed NEEDED libraries
ELF_ALLOWED_LIBRARIES = {
@@ -213,23 +212,12 @@ def check_MACHO_libraries(filename) -> bool:
ok = False
return ok
-def pe_read_libraries(filename) -> List[str]:
- p = subprocess.Popen([OBJDUMP_CMD, '-x', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
- (stdout, stderr) = p.communicate()
- if p.returncode:
- raise IOError('Error opening file')
- libraries = []
- for line in stdout.splitlines():
- if 'DLL Name:' in line:
- tokens = line.split(': ')
- libraries.append(tokens[1])
- return libraries
-
def check_PE_libraries(filename) -> bool:
ok: bool = True
- for dylib in pe_read_libraries(filename):
+ binary = lief.parse(filename)
+ for dylib in binary.libraries:
if dylib not in PE_ALLOWED_LIBRARIES:
- print('{} is not in ALLOWED_LIBRARIES!'.format(dylib))
+ print(f'{dylib} is not in ALLOWED_LIBRARIES!')
ok = False
return ok