adds hand coded fibo, works
This commit is contained in:
@ -6,9 +6,9 @@ require 'elf/string_table_section'
|
||||
module Elf
|
||||
|
||||
class ObjectWriter
|
||||
def initialize(target)
|
||||
def initialize(program , target)
|
||||
@object = Elf::ObjectFile.new(target)
|
||||
|
||||
@program = program
|
||||
sym_strtab = Elf::StringTableSection.new(".strtab")
|
||||
@object.add_section sym_strtab
|
||||
@symbol_table = Elf::SymbolTableSection.new(".symtab", sym_strtab)
|
||||
@ -16,6 +16,17 @@ module Elf
|
||||
|
||||
@text = Elf::TextSection.new(".text")
|
||||
@object.add_section @text
|
||||
|
||||
program.link_at( 0 , program.context )
|
||||
|
||||
binary = program.assemble(StringIO.new )
|
||||
|
||||
blocks = program.functions.collect{ |f| [f.entry , f.exit , f.body] }
|
||||
blocks += [program.entry , program.exit , program.main]
|
||||
blocks.flatten.each do |b|
|
||||
add_symbol b.name.to_s , b.position
|
||||
end
|
||||
set_text binary.string
|
||||
end
|
||||
|
||||
def set_text(text)
|
||||
|
Reference in New Issue
Block a user