metasm/exe_format/elf.rb in metasm-1.0.2 vs metasm/exe_format/elf.rb in metasm-1.0.3
- old
+ new
@@ -7,10 +7,11 @@
require 'metasm/exe_format/main'
module Metasm
class ELF < ExeFormat
MAGIC = "\x7fELF" # 0x7f454c46
+ MAGIC.force_encoding('BINARY') if MAGIC.respond_to?(:force_encoding)
CLASS = { 0 => 'NONE', 1 => '32', 2 => '64', 200 => '64_icc' }
DATA = { 0 => 'NONE', 1 => 'LSB', 2 => 'MSB' }
VERSION = { 0 => 'INVALID', 1 => 'CURRENT' }
ABI = { 0 => 'SYSV', 1 => 'HPUX', 2 => 'NETBSD', 3 => 'LINUX',
6 => 'SOLARIS', 7 => 'AIX', 8 => 'IRIX', 9 => 'FREEBSD',
@@ -393,10 +394,12 @@
21 => 'DTPOFF32', 22 => 'GOTTPOFF', 23 => 'TPOFF32' }
}
DEFAULT_INTERP = '/lib/ld-linux.so.2'
DEFAULT_INTERP64 = '/lib64/ld-linux-x86-64.so.2'
+ DEFAULT_INTERP.force_encoding('BINARY') if DEFAULT_INTERP.respond_to?(:force_encoding)
+ DEFAULT_INTERP64.force_encoding('BINARY') if DEFAULT_INTERP64.respond_to?(:force_encoding)
class SerialStruct < Metasm::SerialStruct
new_int_field :addr, :off, :xword, :sword, :sxword
end
@@ -680,9 +683,10 @@
end
end
class FatELF < ExeFormat
MAGIC = "\xfa\x70\x0e\x1f" # 0xfat..elf
+ MAGIC.force_encoding('BINARY') if MAGIC.respond_to?(:force_encoding)
class SerialStruct < Metasm::SerialStruct
new_int_field :qword
end