make elf symbols optional

and default to false. Smaller executables  by at least half
also add option for compiler cli
This commit is contained in:
2019-09-03 02:02:21 +03:00
parent 160d860db2
commit 91995dc1b3
5 changed files with 21 additions and 115 deletions

View File

@ -7,7 +7,9 @@ require_relative 'string_table_section'
module Elf
class ObjectWriter
def initialize( linker )
attr_reader :text
def initialize( linker , options = {} )
@linker = linker
target = Elf::Constants::TARGET_ARM
@object = Elf::ObjectFile.new(target)
@ -22,7 +24,15 @@ module Elf
assembler = Risc::TextWriter.new(@linker)
set_text assembler.write_as_string
# for debug add labels for labels
add_debug_symbols(options)
end
# for debug add labels for labels
def add_debug_symbols(options)
debug = options[:debug]
return unless debug
@linker.assemblers.each do |asm|
meth = asm.callable
asm.instructions.each do |label|
@ -34,7 +44,6 @@ module Elf
add_symbol label , Risc::Position.get(code).at
end
end
@linker.object_positions.each do |slot , position|
next if slot.is_a?(Parfait::BinaryCode)
next if slot.class.name.include?("Arm")
@ -48,8 +57,6 @@ module Elf
end
end
attr_reader :text
def set_text(text)
@text.text = text
add_symbol "_start", 0