From 631038dfbd9a1290a60b543cc0d35e7f98bc7610 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 30 Dec 2016 13:15:08 +0200 Subject: [PATCH] add another test (still failing) --- lib/elf/object_writer.rb | 16 ++++++++-------- test/elf/test_all.rb | 1 + test/elf/test_zero.rb | 12 ++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 test/elf/test_zero.rb diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index 9fa393e7..dc795e12 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -20,12 +20,12 @@ module Elf assembler = Register::Assembler.new(Register.machine) set_text assembler.write_as_string - # for debug add labels to the block positions - Register.machine.space.types.values.each do |clazz| - clazz.instance_methods.each do |f| + # for debug add labels for labels + Register.machine.space.types.values.each do |type| + type.instance_methods.each do |f| f.instructions.each_label do |label| - add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position - end + add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position + end end end @@ -37,9 +37,9 @@ module Elf label = "#{slot.class.name}::#{slot.position.to_s(16)}" end label += "=#{slot}" if slot.is_a?(Symbol) or slot.is_a?(String) - add_symbol label , slot.position + add_symbol label , slot.position if slot.is_a?(Parfait::TypedMethod) - add_symbol slot.name.to_s , slot.binary.position + add_symbol slot.name.to_s , slot.binary.position end end end @@ -50,7 +50,7 @@ module Elf @text.text = text add_symbol "_start", 0 end - + def add_symbol(name, offset, linkage = Elf::Constants::STB_GLOBAL) return add_symbol( name + "_" , offset ) if @symbol_table.has_name(name) @symbol_table.add_func_symbol name, offset, @text, linkage diff --git a/test/elf/test_all.rb b/test/elf/test_all.rb index fe02d821..a76fcf75 100644 --- a/test/elf/test_all.rb +++ b/test/elf/test_all.rb @@ -1 +1,2 @@ require_relative "test_hello" +require_relative "test_zero" diff --git a/test/elf/test_zero.rb b/test/elf/test_zero.rb new file mode 100644 index 00000000..6d9d22fe --- /dev/null +++ b/test/elf/test_zero.rb @@ -0,0 +1,12 @@ +require_relative "../helper" + +class TestZeroCode < MiniTest::Test + + def test_string_put + machine = Register.machine.boot + machine.collect + machine.translate_arm +# writer = Elf::ObjectWriter.new +# writer.save "test/zero.o" + end +end