fix init jump bug
the label for the jump was not translated correctly call needs to go through to_cpu to create single instance on the way init order slightly changed
This commit is contained in:
parent
3b6ff3d94f
commit
dd2c2cb975
@ -9,8 +9,6 @@ module Elf
|
|||||||
class ObjectWriter
|
class ObjectWriter
|
||||||
def initialize( machine )
|
def initialize( machine )
|
||||||
@machine = machine
|
@machine = machine
|
||||||
@machine.position_all
|
|
||||||
@machine.create_binary
|
|
||||||
target = Elf::Constants::TARGET_ARM
|
target = Elf::Constants::TARGET_ARM
|
||||||
@object = Elf::ObjectFile.new(target)
|
@object = Elf::ObjectFile.new(target)
|
||||||
sym_strtab = Elf::StringTableSection.new(".strtab")
|
sym_strtab = Elf::StringTableSection.new(".strtab")
|
||||||
|
@ -50,7 +50,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def translate_cpu(translator)
|
def translate_cpu(translator)
|
||||||
@cpu_instructions = translator.translate(@risc_instructions)
|
@cpu_instructions = @risc_instructions.to_cpu(translator)
|
||||||
nekst = @risc_instructions.next
|
nekst = @risc_instructions.next
|
||||||
while(nekst)
|
while(nekst)
|
||||||
cpu = nekst.to_cpu(translator) # returning nil means no replace
|
cpu = nekst.to_cpu(translator) # returning nil means no replace
|
||||||
|
@ -20,7 +20,7 @@ module Risc
|
|||||||
@booted = false
|
@booted = false
|
||||||
@constants = []
|
@constants = []
|
||||||
end
|
end
|
||||||
attr_reader :constants , :risc_init , :cpu_init , :binary_init
|
attr_reader :constants , :cpu_init , :binary_init
|
||||||
attr_reader :booted , :translated
|
attr_reader :booted , :translated
|
||||||
|
|
||||||
# translate to arm, ie instantiate an arm translator and pass it to translate
|
# translate to arm, ie instantiate an arm translator and pass it to translate
|
||||||
@ -36,9 +36,9 @@ module Risc
|
|||||||
# this means translating the initial jump (cpu_init into binary_init)
|
# this means translating the initial jump (cpu_init into binary_init)
|
||||||
# and then translating all methods
|
# and then translating all methods
|
||||||
def translate( translator )
|
def translate( translator )
|
||||||
methods = Parfait.object_space.collect_methods
|
methods = Parfait.object_space.get_all_methods
|
||||||
translate_methods( methods , translator )
|
translate_methods( methods , translator )
|
||||||
@cpu_init = translator.translate( @risc_init )
|
@cpu_init = risc_init.to_cpu(translator)
|
||||||
@binary_init = Parfait::BinaryCode.new(1)
|
@binary_init = Parfait::BinaryCode.new(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,6 +55,10 @@ module Risc
|
|||||||
@objects ||= Collector.collect_space
|
@objects ||= Collector.collect_space
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# lazy init risc_init
|
||||||
|
def risc_init
|
||||||
|
@risc_init ||= Branch.new( "__initial_branch__" , Parfait.object_space.get_init.risc_instructions )
|
||||||
|
end
|
||||||
# add a constant (which get created during compilatio and need to be linked)
|
# add a constant (which get created during compilatio and need to be linked)
|
||||||
def add_constant(const)
|
def add_constant(const)
|
||||||
raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object)
|
raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object)
|
||||||
@ -73,7 +77,7 @@ module Risc
|
|||||||
translate_arm unless @translated
|
translate_arm unless @translated
|
||||||
#need the initial jump at 0 and then functions
|
#need the initial jump at 0 and then functions
|
||||||
cpu_init.set_position( 0 )
|
cpu_init.set_position( 0 )
|
||||||
Positioned.set_position(cpu_init.first , 0)
|
#Positioned.set_position(cpu_init.first , 0)
|
||||||
Positioned.set_position(binary_init,0)
|
Positioned.set_position(binary_init,0)
|
||||||
at = position_objects( binary_init.padded_length )
|
at = position_objects( binary_init.padded_length )
|
||||||
# and then everything code
|
# and then everything code
|
||||||
@ -99,7 +103,7 @@ module Risc
|
|||||||
def position_code_from( at )
|
def position_code_from( at )
|
||||||
objects.each do |id , method|
|
objects.each do |id , method|
|
||||||
next unless method.is_a? Parfait::TypedMethod
|
next unless method.is_a? Parfait::TypedMethod
|
||||||
log.debug "CODE1 #{method.name}:#{at}"
|
log.debug "POS1 #{method.name}:#{at.to_s(16)}"
|
||||||
method.cpu_instructions.set_position( at )
|
method.cpu_instructions.set_position( at )
|
||||||
before = at
|
before = at
|
||||||
nekst = method.binary
|
nekst = method.binary
|
||||||
@ -108,7 +112,7 @@ module Risc
|
|||||||
at += nekst.padded_length
|
at += nekst.padded_length
|
||||||
nekst = nekst.next
|
nekst = nekst.next
|
||||||
end
|
end
|
||||||
log.debug "CODE2 #{method.name}:#{at} len: #{at - before}"
|
log.debug "POS2 #{method.name}:#{at.to_s(16)} len: #{(at - before).to_s(16)}"
|
||||||
end
|
end
|
||||||
at
|
at
|
||||||
end
|
end
|
||||||
@ -121,6 +125,10 @@ module Risc
|
|||||||
writer = BinaryWriter.new(method.binary)
|
writer = BinaryWriter.new(method.binary)
|
||||||
writer.assemble(method.cpu_instructions)
|
writer.assemble(method.cpu_instructions)
|
||||||
end
|
end
|
||||||
|
puts "CPU init"
|
||||||
|
puts cpu_init.first.inspect[0...130]
|
||||||
|
puts Parfait.object_space.get_init.risc_instructions.inspect[0...130]
|
||||||
|
puts Parfait.object_space.get_init.cpu_instructions.inspect[0...130]
|
||||||
BinaryWriter.new(binary_init).assemble(cpu_init)
|
BinaryWriter.new(binary_init).assemble(cpu_init)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -129,7 +137,6 @@ module Risc
|
|||||||
@objects = nil
|
@objects = nil
|
||||||
@translated = false
|
@translated = false
|
||||||
boot_parfait!
|
boot_parfait!
|
||||||
@risc_init = Branch.new( "__initial_branch__" , Parfait.object_space.get_init.risc_instructions )
|
|
||||||
@booted = true
|
@booted = true
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,7 @@ module Vool
|
|||||||
machine = Risc.machine.boot
|
machine = Risc.machine.boot
|
||||||
self.ruby_to_vool(source)
|
self.ruby_to_vool(source)
|
||||||
machine.position_all
|
machine.position_all
|
||||||
|
machine.create_binary
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user