for rel in section.iter_relocations():
hexwidth = 8 if self.elffile.elfclass == 32 else 12
- symbol = symtable.get_symbol(rel['r_info_sym'])
- self._emit('%s %s %-17.17s %s %s%s' % (
+ self._emit('%s %s %-17.17s' % (
self._format_hex(rel['r_offset'],
fieldsize=hexwidth, lead0x=False),
self._format_hex(rel['r_info'],
fieldsize=hexwidth, lead0x=False),
describe_reloc_type(
- rel['r_info_type'], self.elffile['e_machine']),
+ rel['r_info_type'], self.elffile['e_machine'])))
+
+ if rel['r_info_sym'] == 0:
+ self._emitline()
+ continue
+
+ symbol = symtable.get_symbol(rel['r_info_sym'])
+ self._emit(' %s %s%s' % (
self._format_hex(
symbol['st_value'],
fullhex=True, lead0x=False),
' ' if self.elffile.elfclass == 32 else '',
- symbol.name,
- ))
-
+ symbol.name))
if section.is_RELA():
self._emit(' %s %x' % (
'+' if rel['r_addend'] >= 0 else '-',
for i in range(linebytes):
c = data[dataptr + i]
- if c >= ' ' and ord(c) <= 0x7f:
+ if c >= ' ' and ord(c) < 0x7f:
self._emit(c)
else:
self._emit('.')
return False
stdouts.append(stdout)
testlog.info('....comparing output...')
- success, errmsg = compare_output(*stdouts)
- if success:
+ rc, errmsg = compare_output(*stdouts)
+ if rc:
testlog.info('.......................SUCCESS')
else:
success = False
for i in range(len(lines1)):
if 'Symbol table' in lines1[i]:
flag_after_symtable = True
+
# Compare ignoring whitespace
if lines1[i].split() != lines2[i].split():
+ sm = SequenceMatcher()
+ sm.set_seqs(lines1[i], lines2[i])
if flag_after_symtable:
- sm = SequenceMatcher()
- sm.set_seqs(lines1[i], lines2[i])
# Detect readelf's adding @ with lib and version after
# symbol name.
changes = sm.get_opcodes()
if not is_in_rootdir():
die('Please run me from the root dir of pyelftools!')
+ # If file names are given as command-line arguments, only these files
+ # are taken as inputs. Otherwise, autodiscovery is performed.
+ #
+ if len(sys.argv) > 1:
+ filenames = sys.argv[1:]
+ else:
+ filenames = list(discover_testfiles('tests/testfiles'))
+
success = True
- for filename in discover_testfiles('tests/testfiles'):
+ for filename in filenames:
success = success and run_test_on_file(filename)
if success: