Added new test file and fixing some problems related to it. not completely working yet
authorEli Bendersky <eliben@gmail.com>
Fri, 16 Dec 2011 11:05:54 +0000 (13:05 +0200)
committerEli Bendersky <eliben@gmail.com>
Fri, 16 Dec 2011 11:05:54 +0000 (13:05 +0200)
elftools/dwarf/lineprogram.py
tests/run_readelf_tests.py
tests/testfiles/penalty_32_gcc.o.elf [new file with mode: 0644]

index 361511f65b71a76d00d878487017cc6405f916e5..45bca2dc510714eecbdce598a5a1d3719e523bee 100644 (file)
@@ -6,6 +6,7 @@
 # Eli Bendersky (eliben@gmail.com)
 # This code is in the public domain
 #-------------------------------------------------------------------------------
+import os
 import copy
 from collections import namedtuple
 
@@ -181,6 +182,10 @@ class LineProgram(object):
                         self.structs.Dwarf_lineprog_file_entry, self.stream)
                     self['file_entry'].append(operand)
                     add_entry_old_state(ex_opcode, [operand], is_extended=True)
+                else:
+                    # Unknown, but need to roll forward the stream because the
+                    # length is specified
+                    self.stream.seek(inst_len, os.SEEK_CUR)
             else: # 0 < opcode < opcode_base
                 # Standard opcode
                 if opcode == DW_LNS_copy:
@@ -197,7 +202,7 @@ class LineProgram(object):
                                            self.stream)
                     state.line += operand
                 elif opcode == DW_LNS_set_file:
-                    operand = struct_parse(self.structs.Dwarf_sleb128(''),
+                    operand = struct_parse(self.structs.Dwarf_uleb128(''),
                                            self.stream)
                     state.file = operand
                     add_entry_old_state(opcode, [operand])
index 5a5fbd7fd4790cb7ed875d5655b857e9b319c31b..61cfbee4e1d100c034ab35704a6beb562bd1a1c9 100755 (executable)
@@ -104,7 +104,8 @@ def compare_output(s1, s2):
             elif 'of the .debug_frame section' in line:
                 filter_out = False
             if not filter_out:
-                yield line
+                if not line.startswith('unknown: length'):
+                    yield line
         
     lines1 = prepare_lines(s1)
     lines2 = prepare_lines(s2)
diff --git a/tests/testfiles/penalty_32_gcc.o.elf b/tests/testfiles/penalty_32_gcc.o.elf
new file mode 100644 (file)
index 0000000..4c5c5de
Binary files /dev/null and b/tests/testfiles/penalty_32_gcc.o.elf differ