Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions dockerize/depsolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def read_sections(self):
def section(self, name):
'''Return the raw content of the named section from the ELF file.'''
section = self[name]
with open(self.path) as fde:
with open(self.path, 'rb') as fde:
fde.seek(int(section.offset, base=16))
data = fde.read(int(section.size, base=16))
return data
return data.decode('utf-8')

def interpreter(self):
'''Return the value of the `.interp` section of the ELF file.'''
Expand All @@ -80,18 +80,20 @@ def get_deps(self, path):
# to produce the list of library dependencies.
try:
elf = ELFFile(path)
interp = elf.interpreter()
except ValueError:
LOG.debug('%s is not a dynamically linked ELF binary (ignoring)',
path)
return

try:
interp = elf.interpreter()
except KeyError:
LOG.debug('%s does not have a .interp section',
path)
return

self.deps.add(interp)
out = subprocess.check_output([interp, '--list', path])
out = subprocess.check_output([interp, '--list', path]).decode('utf-8')

for line in out.splitlines():
for exp in RE_DEPS:
Expand Down