Class: Elf::Parser::Parser
- Inherits:
-
Object
- Object
- Elf::Parser::Parser
- Defined in:
- lib/mithril/parser.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(string) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(string) ⇒ Parser
Returns a new instance of Parser.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mithril/parser.rb', line 33 def initialize(string) @data = StringIO.new(string) @file = ElfFile.new ident = ElfStructs::ElfIdentification.read(@data) print ident.snapshot.inspect raise RuntimeError.new "Invalid ELF version #{ident.id_version}" if ident.id_version != ElfFlags::Version::EV_CURRENT case ident.id_class when ElfFlags::IdentClass::ELFCLASS64 @file.bits = 64 when ElfFlags::IdentClass::ELFCLASS32 @file.bits = 32 else RuntimeError.new "Invalid ELF class #{ident.id_class}" end case ident.id_data when ElfFlags::IdentData::ELFDATA2LSB @file.endian = :little when ElfFlags::IdentData::ELFDATA2MSB @file.endian = :big else RuntimeError.new "Invalid ELF endianness #{ident.id_data}" end @versions = {} @reladyn_indices = [] @factory = ElfStructFactory.instance(@file.endian,@file.bits) parse_with_factory() end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
32 33 34 |
# File 'lib/mithril/parser.rb', line 32 def file @file end |