From cc9b5157524d26a3dd23f877148432a3b5c09f10 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 14 Nov 2015 22:53:01 +0200 Subject: [PATCH] fix double label names --- lib/elf/object_writer.rb | 1 + lib/elf/symbol_table_section.rb | 4 ++++ lib/register/instructions/label.rb | 3 +++ lib/soml/compiler.rb | 5 +++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index 98d43625..09dab7e1 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -49,6 +49,7 @@ module Elf 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 end diff --git a/lib/elf/symbol_table_section.rb b/lib/elf/symbol_table_section.rb index f43c202e..a8fa5244 100644 --- a/lib/elf/symbol_table_section.rb +++ b/lib/elf/symbol_table_section.rb @@ -18,6 +18,10 @@ module Elf end end + def has_name(name) + @strtab.index_for(name) + end + def index_for_name(name) @symbols.each_with_index { |sym, idx| if (sym[0] == name) diff --git a/lib/register/instructions/label.rb b/lib/register/instructions/label.rb index 926b3fd7..a76a810b 100644 --- a/lib/register/instructions/label.rb +++ b/lib/register/instructions/label.rb @@ -17,6 +17,9 @@ module Register def to_s "Label: #{@name} (#{self.next.class})" end + def sof_reference_name + "Label: #{@name}" + end # a method start has a label of the form Class.method , test for that def is_method diff --git a/lib/soml/compiler.rb b/lib/soml/compiler.rb index f90aada7..682613d5 100644 --- a/lib/soml/compiler.rb +++ b/lib/soml/compiler.rb @@ -83,9 +83,10 @@ module Soml # return self for chaining def init_method source = "_init_method" - @method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}") + name = "#{method.for_class.name}.#{method.name}" + @method.instructions = Register::Label.new(source, name) @current = enter = method.instructions - add_code Register::Label.new( source, "return") + add_code Register::Label.new( source, "return #{name}") #load the return address into pc, affecting return. (other cpus have commands for this, but not arm) add_code Register::FunctionReturn.new( source , Register.message_reg , Register.resolve_index(:message , :return_address) ) @current = enter