[diffoscope] 02/02: Only pass --decompress to readelf when the option is supported
Jérémy Bobbio
lunar at moszumanska.debian.org
Sat Jan 23 23:32:00 CET 2016
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository diffoscope.
commit d6c70d78c827ea906155568cb558410fe591cce1
Author: Jérémy Bobbio <lunar at debian.org>
Date: Sat Jan 23 22:31:50 2016 +0000
Only pass --decompress to readelf when the option is supported
---
diffoscope/comparators/elf.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index a7f6202..828e0f5 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -126,6 +126,16 @@ class ReadelfDebugDump(Readelf):
class ReadElfSection(Readelf):
+ @staticmethod
+ def base_options():
+ if not hasattr(ReadElfSection, '_base_options'):
+ options = []
+ help_output = subprocess.check_output(['readelf', '--help'], shell=False, stderr=subprocess.DEVNULL).decode('us-ascii', errors='replace')
+ if '--decompress' in help_output:
+ options.append('--decompress')
+ ReadElfSection._base_options = options
+ return ReadElfSection._base_options
+
def __init__(self, path, section_name, *args, **kwargs):
self._path = path
self._section_name = section_name
@@ -136,11 +146,11 @@ class ReadElfSection(Readelf):
return self._section_name
def readelf_options(self):
- return ['--decompress', '--hex-dump={}'.format(self.section_name)]
+ return ReadElfSection.base_options() + ['--hex-dump={}'.format(self.section_name)]
class ReadelfStringSection(ReadElfSection):
def readelf_options(self):
- return ['--decompress', '--string-dump={}'.format(self.section_name)]
+ return ReadElfSection.base_options() + ['--string-dump={}'.format(self.section_name)]
class ObjdumpSection(Command):
def __init__(self, path, section_name, *args, **kwargs):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list