[diffoscope] 01/03: Add fallbacks to elf code section disassembly. (Closes: #879003)
Ximin Luo
infinity0 at debian.org
Tue Nov 28 19:24:02 CET 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository diffoscope.
commit bfbb1223e16d80f688d5236c7451313a661f629d
Author: Mike Hommey <mh at glandium.org>
Date: Fri Oct 20 21:48:24 2017 +0900
Add fallbacks to elf code section disassembly. (Closes: #879003)
Because objdump --line-numbers can be extremely slow, it can be worth
skipping it, and just get a disassembly (especially when the files don't
contain line numbers debug info, where ironically, objdump is slow with
--line-numbers).
The --exclude-command command line option allows to skip some commands,
and one can use that to skip the command that uses --line-numbers, but
in that case, no difference is shown for the code sections.
This change adds a fallback in that case, where objdump is called
without the --line-numbers command, making disassembly faster.
But that can still be too time consuming (especially because the output
can be large, and diffing that can be a long process, so allow to
exclude /that/ too, and fallback to an hexdump in that case.
---
diffoscope/comparators/elf.py | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index 0a7d29b..c572601 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -241,6 +241,11 @@ class ObjdumpDisassembleSection(ObjdumpSection):
return ObjdumpDisassembleSection.RE_SYMBOL_COMMENT.sub(r'\1', line)
+class ObjdumpDisassembleSectionNoLineNumbers(ObjdumpDisassembleSection):
+ def objdump_options(self):
+ return ['--disassemble', '--demangle']
+
+
READELF_COMMANDS = (
ReadelfFileHeader,
ReadelfProgramHeader,
@@ -328,12 +333,20 @@ class ElfSection(File):
class ElfCodeSection(ElfSection):
def compare(self, other, source=None):
+ # Normally disassemble with line numbers, but if the command is
+ # excluded, fallback to disassembly, and if that is also excluded,
+ # fallback to a hexdump.
return Difference.from_command(
ObjdumpDisassembleSection,
self.path,
other.path,
command_args=[self._name],
- )
+ ) or Difference.from_command(
+ ObjdumpDisassembleSectionNoLineNumbers,
+ self.path,
+ other.path,
+ command_args=[self._name],
+ ) or super().compare(other, source)
class ElfStringSection(ElfSection):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list