From 5237ff9e40bb0e4a87d1268d20edbf7d91e40a37 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 21 Apr 2014 20:59:48 +0300 Subject: [PATCH] move towards simpler relocation model --- lib/asm/arm/addr_table_object.rb | 9 +++++++++ lib/asm/arm/arm_assembler.rb | 7 ------- lib/asm/arm/memory_access_builder.rb | 5 +++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/asm/arm/addr_table_object.rb b/lib/asm/arm/addr_table_object.rb index a56d6046..63faf958 100644 --- a/lib/asm/arm/addr_table_object.rb +++ b/lib/asm/arm/addr_table_object.rb @@ -1,6 +1,15 @@ module Asm 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 def initialize @table = [] diff --git a/lib/asm/arm/arm_assembler.rb b/lib/asm/arm/arm_assembler.rb index 3d8494f4..0c635a37 100644 --- a/lib/asm/arm/arm_assembler.rb +++ b/lib/asm/arm/arm_assembler.rb @@ -14,13 +14,6 @@ module Asm # Unofficial (cant be used for extern relocations) 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) case type when R_ARM_PC24 diff --git a/lib/asm/arm/memory_access_builder.rb b/lib/asm/arm/memory_access_builder.rb index a4b9605f..5b899c66 100644 --- a/lib/asm/arm/memory_access_builder.rb +++ b/lib/asm/arm/memory_access_builder.rb @@ -76,13 +76,14 @@ module Asm (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) | (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) # closest_addrtable = Asm::Arm.closest_addrtable(as) if (@addrtable_reloc_target.is_a?(Asm::LabelRefNode)) 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)) - ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value) +# ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value) end as.add_relocation io.tell, ref_label, Asm::Arm::R_ARM_PC12, Asm::Arm::Instruction::RelocHandler