From f5670e877d64035a3e7dbbb971d88fb15a6872b4 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Thu, 24 Nov 2011 09:05:44 +0200 Subject: [PATCH] fixes in readelf. added --debug-dump=info to the tests --- scripts/readelf.py | 1 + tests/run_readelf_tests.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/readelf.py b/scripts/readelf.py index 2de7cb6..8a76c6f 100755 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -536,6 +536,7 @@ class ReadElf(object): if die.has_children: die_depth += 1 + self._emitline() def _emit(self, s=''): """ Emit an object to output diff --git a/tests/run_readelf_tests.py b/tests/run_readelf_tests.py index 27a2bf4..9142c1d 100755 --- a/tests/run_readelf_tests.py +++ b/tests/run_readelf_tests.py @@ -8,6 +8,7 @@ # This code is in the public domain #------------------------------------------------------------------------------- import os, sys +import re from difflib import SequenceMatcher import logging import subprocess @@ -49,7 +50,9 @@ def run_test_on_file(filename): """ success = True testlog.info("Running test on file '%s'" % filename) - for option in ['-e', '-s', '-r', '-x.text', '-p.shstrtab']: + for option in [ + '-e', '-s', '-r', '-x.text', '-p.shstrtab', + '--debug-dump=info']: testlog.info("..option='%s'" % option) # stdouts will be a 2-element list: output of readelf and output # of scripts/readelf.py @@ -104,14 +107,26 @@ def compare_output(s1, s2): if lines1[i].split() != lines2[i].split(): sm = SequenceMatcher() sm.set_seqs(lines1[i], lines2[i]) + changes = sm.get_opcodes() if flag_after_symtable: # Detect readelf's adding @ with lib and version after # symbol name. - changes = sm.get_opcodes() if ( len(changes) == 2 and changes[1][0] == 'delete' and lines1[i][changes[1][1]] == '@'): continue + elif 'dw_op' in lines1[i] and 'reg' in lines1[i]: + # readelf decodes register names, we don't do that. + no_worries = False + for change in changes: + if ( change[0] == 'delete' and + re.search('\(\w+', lines1[i][change[1]:change[2]])): + no_worries = True + if no_worries: + continue + else: + print changes + print lines1[i][changes[3][1]:changes[3][2]] errmsg = 'Mismatch on line #%s:\n>>%s<<\n>>%s<<\n' % ( i, lines1[i], lines2[i]) return False, errmsg -- 2.30.2