move towards simpler relocation model
This commit is contained in:
parent
1b8f15a3fc
commit
5237ff9e40
@ -1,6 +1,15 @@
|
|||||||
module Asm
|
module Asm
|
||||||
module Arm
|
module Arm
|
||||||
|
|
||||||
|
# TODO actually find the closest somehow (DROPPED for now)
|
||||||
|
def self.closest_addrtable(as)
|
||||||
|
as.objects.find do |obj|
|
||||||
|
obj.is_a?(Asm::Arm::AddrTableObject)
|
||||||
|
end || (raise Asm::AssemblyError.new('could not find addrtable to use', nil))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#this has been DROPPED for now (didn't work) and we can do without it
|
||||||
class AddrTableObject
|
class AddrTableObject
|
||||||
def initialize
|
def initialize
|
||||||
@table = []
|
@table = []
|
||||||
|
@ -14,13 +14,6 @@ module Asm
|
|||||||
# Unofficial (cant be used for extern relocations)
|
# Unofficial (cant be used for extern relocations)
|
||||||
R_ARM_PC12 = 0xF0
|
R_ARM_PC12 = 0xF0
|
||||||
|
|
||||||
# TODO actually find the closest somehow
|
|
||||||
def self.closest_addrtable(as)
|
|
||||||
as.objects.find do |obj|
|
|
||||||
obj.is_a?(Asm::Arm::AddrTableObject)
|
|
||||||
end || (raise Asm::AssemblyError.new('could not find addrtable to use', nil))
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.write_resolved_relocation(io, addr, type)
|
def self.write_resolved_relocation(io, addr, type)
|
||||||
case type
|
case type
|
||||||
when R_ARM_PC24
|
when R_ARM_PC24
|
||||||
|
@ -76,13 +76,14 @@ module Asm
|
|||||||
(byte_access << 12+4+4+1+1) | (add_offset << 12+4+4+1+1+1) |
|
(byte_access << 12+4+4+1+1) | (add_offset << 12+4+4+1+1+1) |
|
||||||
(pre_post_index << 12+4+4+1+1+1+1) | (i << 12+4+4+1+1+1+1+1) |
|
(pre_post_index << 12+4+4+1+1+1+1) | (i << 12+4+4+1+1+1+1+1) |
|
||||||
(inst_class << 12+4+4+1+1+1+1+1+1) | (cond << 12+4+4+1+1+1+1+1+1+2)
|
(inst_class << 12+4+4+1+1+1+1+1+1) | (cond << 12+4+4+1+1+1+1+1+1+2)
|
||||||
|
# move towards simpler model
|
||||||
if (@use_addrtable_reloc)
|
if (@use_addrtable_reloc)
|
||||||
# closest_addrtable = Asm::Arm.closest_addrtable(as)
|
# closest_addrtable = Asm::Arm.closest_addrtable(as)
|
||||||
if (@addrtable_reloc_target.is_a?(Asm::LabelRefNode))
|
if (@addrtable_reloc_target.is_a?(Asm::LabelRefNode))
|
||||||
obj = generator.object_for_label(@addrtable_reloc_target.label, inst)
|
obj = generator.object_for_label(@addrtable_reloc_target.label, inst)
|
||||||
ref_label = closest_addrtable.add_label(obj)
|
# ref_label = closest_addrtable.add_label(obj)
|
||||||
elsif (@addrtable_reloc_target.is_a?(Asm::NumLiteralNode))
|
elsif (@addrtable_reloc_target.is_a?(Asm::NumLiteralNode))
|
||||||
ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value)
|
# ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value)
|
||||||
end
|
end
|
||||||
as.add_relocation io.tell, ref_label, Asm::Arm::R_ARM_PC12,
|
as.add_relocation io.tell, ref_label, Asm::Arm::R_ARM_PC12,
|
||||||
Asm::Arm::Instruction::RelocHandler
|
Asm::Arm::Instruction::RelocHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user