2014-04-14 17:09:56 +02:00
|
|
|
module Elf
|
|
|
|
class TextSection < Section
|
|
|
|
attr_accessor :text
|
|
|
|
|
|
|
|
def write(io)
|
|
|
|
io << text
|
|
|
|
end
|
|
|
|
|
|
|
|
def type
|
|
|
|
Elf::Constants::SHT_PROGBITS
|
|
|
|
end
|
|
|
|
|
2014-05-16 09:42:25 +02:00
|
|
|
def flags #making the text writable !gogogo
|
|
|
|
Elf::Constants::SHF_WRITE | Elf::Constants::SHF_ALLOC | Elf::Constants::SHF_EXECINSTR
|
2014-04-14 17:09:56 +02:00
|
|
|
end
|
|
|
|
|
2014-09-16 16:16:56 +02:00
|
|
|
def mem_length
|
2014-05-20 09:29:08 +02:00
|
|
|
@text.length
|
|
|
|
end
|
|
|
|
def to_s
|
2014-05-21 18:04:48 +02:00
|
|
|
"[" + @text.bytes.collect{|b| "0x"+ b.to_s(16)}.join(",") + "]"
|
2014-05-20 09:29:08 +02:00
|
|
|
end
|
2014-04-14 17:09:56 +02:00
|
|
|
def alignment
|
|
|
|
4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|