Sha256: c96300325e82df2f79d1f6c0d7400e1c61fa02896c5a5ef43da019302ee8d2ef

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

require_relative 'elf'
module Elf
  module Writer2
    class StringTable < BinData::Record
      array :strtab, :initial_length => 1 do
        stringz :initial_value => ""
      end
      def initialize 
        @strings = {} #TODO: Do substring matching, compress the string
        #table.
        def add_string(string) 
          unless @strings.include? string
            @strings[string] = self.strtab.num_bytes
            self.strtab << BinData::Stringz(string)
          end
          @strings[string]
        end
      end
      class OutputLayout < BinData::Record
      end
      
      
    end
  end
end
a= Elf::Writer2::StringTable.new
a.add_string("Hello")
pp a.to_binary_string
binding.pry

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elf-mithril-0.0.5 lib/mithril/writer2.rb
elf-mithril-0.0.4 lib/mithril/writer2.rb
elf-mithril-0.0.1 lib/mithril/writer2.rb