elf.rb: avoid corrupted elf files

Some elf files like unittest files or memory dumps may not be completely
readable by readelf.

Readelf will fail after the following message:
readelf: Warning: possibly corrupt ELF header - it has a non-zero program header offset, but no program headers

This patches avoid these files when there is a non zero offset but no
program headers
This commit is contained in:
Michka Popoff 2019-02-08 20:44:50 +01:00
parent d8c6f6b120
commit 5c068ef82c

View File

@ -133,8 +133,10 @@ module ELFShim
soname = nil
needed = []
command = ["readelf", "-d", path.expand_path.to_s]
lines = Utils.safe_popen_read(*command).split("\n")
lines = Utils.popen_read(*command, err: :out).split("\n")
lines.each do |s|
next if s.start_with?("readelf: Warning: possibly corrupt ELF header")
filename = s[/\[(.*)\]/, 1]
next if filename.nil?