Here's a proposed workaround.
Mike
>From 7332267397e9055aa67b84a9fc6496548c420ea6 Mon Sep 17 00:00:00 2001
From: Mike Hommey <[email protected]>
Date: Fri, 20 Oct 2017 21:48:24 +0900
Subject: [PATCH] Add fallbacks to elf code section disassembly.
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):
--
2.14.1