rubyx/lib/asm/arm/addr_table_object.rb

39 lines
937 B
Ruby
Raw Normal View History

2014-04-21 16:27:05 +02:00
module Asm
module Arm
class AddrTableObject
def initialize
@table = []
@const = []
end
2014-04-21 16:27:05 +02:00
# TODO don't create new entry if there's already an entry for the same label/const
def add_label(label)
d = [label, Asm::LabelObject.new]
@table << d
d[1]
end
2014-04-21 16:27:05 +02:00
def add_const(const)
d = [const, Asm::LabelObject.new]
@const << d
d[1]
end
2014-04-21 16:27:05 +02:00
def assemble(io, as)
@table.each do |pair|
target_label, here_label = *pair
here_label.assemble io, as
as.add_relocation io.tell, target_label, Asm::Arm::R_ARM_ABS32,
Asm::Arm::Instruction::RelocHandler
io.write_uint32 0
end
@const.each do |pair|
const, here_label = *pair
here_label.assemble io, as
io.write_uint32 const
end
end
end
end
2014-04-21 16:27:05 +02:00
end