figuring relocations

This commit is contained in:
Torsten Ruger 2014-04-20 02:28:57 +03:00
parent 4e075e3a81
commit 6226521abb
3 changed files with 6 additions and 9 deletions

View File

@ -25,6 +25,9 @@ module Asm
case type
when R_ARM_PC24
diff = addr - io.tell - 8
if (diff.abs > (1 << 25))
raise Asm::AssemblyError.new('offset too large for R_ARM_PC24 relocation', nil)
end
packed = [diff >> 2].pack('l')
io << packed[0,3]
when R_ARM_ABS32
@ -33,8 +36,7 @@ module Asm
when R_ARM_PC12
diff = addr - io.tell - 8
if (diff.abs > 2047)
raise Asm::AssemblyError.new('offset too large for R_ARM_PC12 relocation',
nil)
raise Asm::AssemblyError.new('offset too large for R_ARM_PC12 relocation', nil)
end
val = diff.abs

View File

@ -4,7 +4,7 @@ require_relative 'generator_label'
require 'asm/nodes'
require 'stream_reader'
require 'stringio'
require "asm/data_object"
class Asm::Arm::CodeGenerator
def initialize
@ -82,7 +82,7 @@ class Asm::Arm::CodeGenerator
if (lbl = @externs.find { |extern| extern.name == sym })
lbl
else
@externs << lbl = GeneratorExternLabel.new(sym)
@externs << lbl = Asm::Arm::GeneratorExternLabel.new(sym)
@asm.add_object lbl
lbl
end

View File

@ -8,7 +8,6 @@ module Asm
def initialize
@objects = []
@label_objects = []
@label_callbacks = []
@relocations = []
end
attr_reader :relocations, :objects
@ -21,10 +20,6 @@ module Asm
@relocations << Asm::Relocation.new(*args)
end
def register_label_callback(label, io_pos, &block)
@label_callbacks << [label, io_pos, block]
end
def assemble(io)
@objects.each do |obj|
obj.assemble io, self