From e2c006b5adacbef5e23f5f55e4b1d935a546bac6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 15 Dec 2016 18:08:55 +0200 Subject: [PATCH] minor --- lib/elf/object_writer.rb | 5 ++++- test/elf/test_hello.rb | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index b4844a76..9fa393e7 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -21,7 +21,7 @@ module Elf set_text assembler.write_as_string # for debug add labels to the block positions - Register.machine.space.classes.values.each do |clazz| + Register.machine.space.types.values.each do |clazz| clazz.instance_methods.each do |f| f.instructions.each_label do |label| add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position @@ -43,11 +43,14 @@ module Elf end end end + attr_reader :text + def set_text(text) @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_hello.rb b/test/elf/test_hello.rb index 31e48c4a..997d62f8 100644 --- a/test/elf/test_hello.rb +++ b/test/elf/test_hello.rb @@ -9,7 +9,7 @@ class HelloTest < MiniTest::Test machine.collect machine.translate_arm writer = Elf::ObjectWriter.new - writer.save "hello.o" + writer.save "test/hello.o" end def test_string_put @@ -17,7 +17,6 @@ class HelloTest < MiniTest::Test s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "Hello again\\n"))))))))) -#FIXME: some more assembly tests need to get to the bottom of this one check end end