[Git][reproducible-builds/diffoscope][master] Catch failures to disassemble and rescue all other differences. (reproducible-builds/diffoscope!29)
Chris Lamb
gitlab at salsa.debian.org
Wed Jul 17 13:49:12 UTC 2019
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
efd5f959 by Marc Herbert at 2019-07-17T13:48:43Z
Catch failures to disassemble and rescue all other differences. (reproducible-builds/diffoscope!29)
When trying and failing to disassemble an ELF library from an architecture not
supported by objdump, catch that particular failure and don't let it revert the
*entire* diff to hexdump, throwing the entire kindergarten class with the
bathwater. Fallback on hexdump _only_ for the problematic text section and
rescue all the rest. Example:
Before:
diffoscope build?/app/libapp.a
--- build1/app/libapp.a
+++ build2/app/libapp.a
│┄ Command `objdump --line-numbers --disassemble --demangle --reloc
│┄ --section=.text build1/app/libapp.a` exited with return code 1. Output:
│┄ objdump: can't disassemble for architecture UNKNOWN!
│┄
│┄ objdump: section '.text' mentioned in a -j option, but not found
│┄ in any input file
│┄
@@ -1,22 +1,22 @@
00000000: 213c 6172 6368 3e0a 2f20 2020 2020 2020 !<arch>./
00000010: 2020 2020 2020 2020 3135 3633 3333 3638 15633368
-00000020: 3830 2020 3020 2020 2020 3020 2020 2020 80 0 0
+00000020: 3931 2020 3020 2020 2020 3020 2020 2020 91 0 0
00000030: 3020 2020 2020 2020 3134 2020 2020 2020 0 14
00000040: 2020 600a 0000 0001 0000 0052 6d61 696e `........Rmain
00000050: 0000 6d61 696e 2e63 2e6f 626a 2f20 2020 ..main.c.obj/
00000060: 2020 3020 2020 2020 2020 2020 2020 3020 0 0
00000070: 2020 2020 3020 2020 2020 3634 3420 2020 0 644
00000080: 2020 3130 3332 2020 2020 2020 600a 7f45 1032 `..E
00000090: 4c46 0101 0100 0000 0000 0000 0000 0100 LF..............
000000a0: 2800 0100 0000 0000 0000 0000 0000 2802 (.............(.
000000b0: 0000 0000 0005 3400 0000 0000 2800 0c00 ......4.....(...
000000c0: 0b00 0149 0248 fff7 febf 0000 0000 0b00 ...I.H..........
000000d0: 0000 6d70 7332 5f61 6e33 3835 0048 656c ..mps2_an385.Hel
-000000e0: 6c6f 2057 6f72 6c64 2120 2573 0a00 0047 lo World! %s...G
+000000e0: 6c6f 2058 6f72 6c64 2120 2573 0a00 0047 lo Xorld! %s...G
000000f0: 4343 3a20 2863 726f 7373 746f 6f6c 2d4e CC: (crosstool-N
00000100: 4720 312e 3234 2e30 2d72 6332 2d64 6972 G 1.24.0-rc2-dir
00000110: 7479 2920 382e 332e 3000 412c 0000 0061 ty) 8.3.0.A,...a
00000120: 6561 6269 0001 2200 0000 0537 2d4d 0006 eabi.."....7-M..
00000130: 0a07 4d09 0212 0414 0115 0117 0318 0119 ..M.............
00000140: 011a 011e 0422 0100 0000 0000 0000 0000 ....."..........
00000150: 0000 0000 0000 0000 0000 0100 0000 0000 ................
- After:
2019-07-17 04:15:40 E: diffoscope.comparators.elf:
Command '['objdump', '--line-numbers', '--disassemble', '--demangle',
'--reloc', '--section=.text.main', 'build1/app/libapp.a']' returned
non-zero exit status 1.
2019-07-17 04:15:40 E: diffoscope.comparators.elf:
Command '['objdump', '--disassemble', '--demangle',
'--section=.text.main', 'build1/app/libapp.a']' returned non-zero exit
status 1.
--- build1/app/libapp.a
+++ build2/app/libapp.a
├── file list
│ @@ -1,2 +1,2 @@
│ ----------- 0 0 0 14 2019-07-17 04:14:40.000000 /
│ +---------- 0 0 0 14 2019-07-17 04:14:51.000000 /
│ ?rw-r--r-- 0 0 0 1032 1970-01-01 00:00:00.000000 main.c.obj
├── readelf --wide --decompress --string-dump=.rodata.main.str1.1 {}
│ @@ -1,7 +1,7 @@
│
│ File: lib.a(main.c.obj)
│
│ String dump of section '.rodata.main.str1.1':
│ [ 0] mps2_an385
│ - [ b] Hello World! %s^J
│ + [ b] Hello Xorld! %s^J
Signed-off-by: Marc Herbert <marc.herbert at gmail.com>
Signed-off-by: Chris Lamb <lamby at debian.org>
- - - - -
1 changed file:
- diffoscope/comparators/elf.py
Changes:
=====================================
diffoscope/comparators/elf.py
=====================================
@@ -339,25 +339,37 @@ 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.
- diff, excluded = Difference.from_command_exc(
- ObjdumpDisassembleSection,
- self.path,
- other.path,
- command_args=[self._name],
- )
- if not excluded:
+ # Disassemble with line numbers, but if the command is excluded or
+ # fails, fallback to disassembly. If that is also excluded or failing,
+ # only then fallback to a hexdump.
+ diff = None
+ try:
+ diff, excluded = Difference.from_command_exc(
+ ObjdumpDisassembleSection,
+ self.path,
+ other.path,
+ command_args=[self._name],
+ )
+ # eg. When failing to disassemble a different architecture.
+ except subprocess.CalledProcessError as e:
+ logger.error(e)
+
+ if diff and not excluded:
return diff
- diff, excluded = Difference.from_command_exc(
- ObjdumpDisassembleSectionNoLineNumbers,
- self.path,
- other.path,
- command_args=[self._name],
- )
- if not excluded:
+
+ try:
+ diff, excluded = Difference.from_command_exc(
+ ObjdumpDisassembleSectionNoLineNumbers,
+ self.path,
+ other.path,
+ command_args=[self._name],
+ )
+ except subprocess.CalledProcessError as e:
+ logger.error(e)
+
+ if diff and not excluded:
return diff
+
return super().compare(other, source)
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/efd5f9591226138075d4a2921c2b4ed8e761910c
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/efd5f9591226138075d4a2921c2b4ed8e761910c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20190717/11a4108c/attachment.html>
More information about the rb-commits
mailing list