[diffoscope] 02/02: Remove debug symbols decompressing since objdump now supports compressed debug symbols.

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Sun Feb 26 04:50:01 CET 2017


This is an automated email from the git hooks/post-receive script.

siamezzze-guest pushed a commit to branch siamezzze/elf
in repository diffoscope.

commit 5701e67a16255672c0cd3470e8168bab8b3acac8
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Sun Feb 26 05:09:48 2017 +0200

    Remove debug symbols decompressing since objdump now supports compressed debug symbols.
    
    When installing detached symbols was introduced in eb070310e23e44deb6b0caaa7d022d72b13406a6,
    objdump was not able to process compressed debug symbols, so we had to uncompress them into
    a new file.
    
    Since then, the related bug (#812089) was fixed, and we can now just link the debug symbols
    into the .debug directory. In addition to simplifying the logic, that should fix
    (at least some) readelf errors like "Error: no .dynamic section in the dynamic segment",
    reported in #849407.
---
 diffoscope/comparators/elf.py | 35 +----------------------------------
 tests/comparators/test_elf.py |  1 +
 2 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index e6cc533..6a48308 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -487,40 +487,7 @@ class ElfContainer(Container):
         )
         os.makedirs(os.path.dirname(dest_path), exist_ok=True)
 
-        def objcopy(*args):
-            subprocess.check_call(
-                ('objcopy',) + args,
-                shell=False,
-                stderr=subprocess.DEVNULL,
-        )
-
-        # If #812089 was fixed, we would just do os.link(debug_file.path,
-        # dest_path) but for now, we need to do more complicated thingsā€¦
-        # 1. Use objcopy to create a file with only the original .gnu_debuglink
-        # section as we will have to update it to get the CRC right.
-        debuglink_path = get_named_temporary_file(
-            prefix='{}.debuglink.'.format(self.source.path),
-        ).name
-
-        objcopy('--only-section=.gnu_debuglink', self.source.path, debuglink_path)
-
-        # 2. Monkey-patch the ElfSection object created for the .gnu_debuglink
-        # to change the path to point to this new file
-        section = self._sections['.gnu_debuglink']
-        class MonkeyPatchedElfSection(section.__class__):
-            @property
-            def path(self):
-                return debuglink_path
-        section.__class__ = MonkeyPatchedElfSection
-
-        # 3. Create a file with the debug symbols in uncompressed form
-        objcopy('--decompress-debug-sections', debug_file.path, dest_path)
-
-        # 4. Update the .gnu_debuglink to this new file so we get the CRC right
-        objcopy('--remove-section=.gnu_debuglink', self.source.path)
-        objcopy('--add-gnu-debuglink={}'.format(dest_path), self.source.path)
-
-        logger.debug('Installed debug symbols at %s', dest_path)
+        os.link(debug_file.path, dest_path)
 
     def get_member_names(self):
         return self._sections.keys()
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index a75d04e..d97c666 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -127,6 +127,7 @@ def test_differences_with_dbgsym(dbgsym_differences):
     assert bin_details.source1 == './usr/bin/test'
     assert bin_details.details[1].source1.startswith('objdump')
     assert 'test-cases/dbgsym/package/test.c:2' in bin_details.details[1].unified_diff
+    assert len(bin_details.details[2].comments) == 0
 
 @skip_unless_tools_exist('readelf', 'objdump', 'objcopy')
 @skip_if_binutils_does_not_support_x86()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list