2014-04-14 18:09:56 +03: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 10:42:25 +03:00
|
|
|
def flags #making the text writable !gogogo
|
|
|
|
Elf::Constants::SHF_WRITE | Elf::Constants::SHF_ALLOC | Elf::Constants::SHF_EXECINSTR
|
2014-04-14 18:09:56 +03:00
|
|
|
end
|
|
|
|
|
2014-09-17 12:04:54 +03:00
|
|
|
def length
|
2014-05-20 10:29:08 +03:00
|
|
|
@text.length
|
|
|
|
end
|
|
|
|
def to_s
|
2014-05-21 19:04:48 +03:00
|
|
|
"[" + @text.bytes.collect{|b| "0x"+ b.to_s(16)}.join(",") + "]"
|
2014-05-20 10:29:08 +03:00
|
|
|
end
|
2014-04-14 18:09:56 +03:00
|
|
|
def alignment
|
|
|
|
4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|