Class: Elf::Writer::StringTable
- Inherits:
-
Object
- Object
- Elf::Writer::StringTable
- Defined in:
- lib/mithril/writer.rb
Overview
Replace with compacting string table
Instance Attribute Summary collapse
-
#buf ⇒ Object
readonly
Returns the value of attribute buf.
Instance Method Summary collapse
-
#add_string(string) ⇒ Object
table.
-
#initialize ⇒ StringTable
constructor
A new instance of StringTable.
Constructor Details
#initialize ⇒ StringTable
Returns a new instance of StringTable.
30 31 32 33 34 35 36 37 |
# File 'lib/mithril/writer.rb', line 30 def initialize @buf = StringIO.new("\0") @buf.seek 1 @strings = {} #TODO: Do substring matching, compress the string #table. # Actually, make all string tables except dynstr one, might save # a bit end |
Instance Attribute Details
#buf ⇒ Object (readonly)
Returns the value of attribute buf.
29 30 31 |
# File 'lib/mithril/writer.rb', line 29 def buf @buf end |
Instance Method Details
#add_string(string) ⇒ Object
table. Actually, make all string tables except dynstr one, might save a bit
38 39 40 41 42 43 44 45 |
# File 'lib/mithril/writer.rb', line 38 def add_string(string) unless @strings.include? string @strings[string] = @buf.tell.tap {|x| BinData::Stringz::new(string).write(@buf) } end @strings[string] end |