fix double label names

This commit is contained in:
Torsten Ruger 2015-11-14 22:53:01 +02:00
parent 278eccbed5
commit cc9b515752
4 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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