version of Python (the same the runners themselves were executed with).
> python setup.py install
+Since **pyelftools** is a work in progress, it's recommended to get the ``tip``
+tag ("trunk") from *Downloads* or just clone the Mercurial repository, to get
+the latest code.
+
How to use it?
--------------
If stream_pos is provided, the stream is seeked to this position before
the parsing is done. Otherwise, the current position of the stream is
used.
+ Note: a bytes object is returned here, because this is what's read from
+ the binary file.
"""
if stream_pos is not None:
stream.seek(stream_pos)
padding = 20 + (8 if self.elffile.elfclass == 32 else 0)
for tag in section.iter_tags():
if tag.entry.d_tag == 'DT_NEEDED':
- parsed = 'Shared library: [%s]' % tag.needed
+ parsed = 'Shared library: [%s]' % bytes2str(tag.needed)
elif tag.entry.d_tag == 'DT_RPATH':
- parsed = 'Library rpath: [%s]' % tag.rpath
+ parsed = 'Library rpath: [%s]' % bytes2str(tag.rpath)
elif tag.entry.d_tag == 'DT_RUNPATH':
- parsed = 'Library runpath: [%s]' % tag.runpath
+ parsed = 'Library runpath: [%s]' % bytes2str(tag.runpath)
elif tag.entry.d_tag == 'DT_SONAME':
- parsed = 'Library soname: [%s]' % tag.soname
+ parsed = 'Library soname: [%s]' % bytes2str(tag.soname)
elif (tag.entry.d_tag.endswith('SZ') or
tag.entry.d_tag.endswith('ENT')):
parsed = '%i (bytes)' % tag['d_val']
if dir_index > 0:
dir = lineprogram['include_directory'][dir_index - 1]
else:
- dir = '.'
+ dir = b'.'
cu_filename = '%s/%s' % (bytes2str(dir), cu_filename)
self._emitline('CU: %s:' % cu_filename)
if options.verbose:
testlog.info('Running in verbose mode')
+ testlog.info('Python executable = %s' % sys.executable)
testlog.info('readelf path = %s' % READELF_PATH)
testlog.info('Given list of files: %s' % args)
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
-import os, subprocess, tempfile
+import os, sys, subprocess, tempfile
from elftools.common.py3compat import bytes2str
"""
popen_cmd = [exe_path] + args
if os.path.splitext(exe_path)[1] == '.py':
- popen_cmd.insert(0, 'python')
+ popen_cmd.insert(0, sys.executable)
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE)
proc_stdout = proc.communicate()[0]
return proc.returncode, bytes2str(proc_stdout)