figuring relocations
This commit is contained in:
parent
4e075e3a81
commit
6226521abb
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user