actually remoe the unused relocation stuff
This commit is contained in:
parent
89a92f80c9
commit
bc60e1d265
@ -116,47 +116,5 @@ module Asm
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Relocation constants
|
||||
# Note that in this assembler, a relocation simply means any
|
||||
# reference to a label that can only be determined at assembly time
|
||||
# or later (as in the normal meaning)
|
||||
|
||||
R_ARM_PC24 = 0x01
|
||||
R_ARM_ABS32 = 0x02
|
||||
|
||||
# Unofficial (cant be used for extern relocations)
|
||||
R_ARM_PC12 = 0xF0
|
||||
|
||||
def self.write_resolved_relocation(io, addr, type)
|
||||
case type
|
||||
when R_ARM_PC24
|
||||
diff = addr - io.tell - 8
|
||||
if (diff.abs > (1 << 25))
|
||||
raise Asm::AssemblyError.new('offset too large for R_ARM_PC24 relocation')
|
||||
end
|
||||
packed = [diff >> 2].pack('l')
|
||||
io << packed[0,3]
|
||||
when R_ARM_ABS32
|
||||
packed = [addr].pack('l')
|
||||
io << packed
|
||||
when R_ARM_PC12
|
||||
diff = addr - io.tell - 8
|
||||
if (diff.abs > 2047)
|
||||
raise Asm::AssemblyError.new('offset too large for R_ARM_PC12 relocation')
|
||||
end
|
||||
|
||||
val = diff.abs
|
||||
sign = (diff>0)?1:0
|
||||
|
||||
curr = io.read_uint32
|
||||
io.seek(-4, IO::SEEK_CUR)
|
||||
|
||||
io.write_uint32 (curr & ~0b00000000100000000000111111111111) |
|
||||
val | (sign << 23)
|
||||
else
|
||||
raise 'unknown relocation type'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,8 +41,6 @@ module Asm
|
||||
4
|
||||
end
|
||||
|
||||
RelocHandler = nil # Asm::Arm.method(:write_resolved_relocation)
|
||||
|
||||
def assemble(io, as)
|
||||
s = @s ? 1 : 0
|
||||
case opcode
|
||||
@ -102,8 +100,8 @@ module Asm
|
||||
elsif (arg.is_a?(Asm::LabelObject) or arg.is_a?(Asm::Label))
|
||||
#not yet tested/supported
|
||||
# arg = @ast_asm.object_for_label(arg.label, self) if arg.is_a?(Asm::Label)
|
||||
# as.add_relocation(io.tell, arg, Asm::R_ARM_PC24, RelocHandler)
|
||||
#write 0 "for now" and let relocation happen
|
||||
raise "not coded #{arg.inspect}"
|
||||
io << "\x00\x00\x00"
|
||||
else
|
||||
raise "else not coded #{arg.inspect}"
|
||||
|
@ -68,18 +68,6 @@ module Asm
|
||||
(byte_access << 12+4+4+1+1) | (add_offset << 12+4+4+1+1+1) |
|
||||
(pre_post_index << 12+4+4+1+1+1+1) | (i << 12+4+4+1+1+1+1+1) |
|
||||
(inst_class << 12+4+4+1+1+1+1+1+1) | (cond << 12+4+4+1+1+1+1+1+1+2)
|
||||
# move towards simpler model
|
||||
if (@use_addrtable_reloc)
|
||||
# closest_addrtable = Asm::Arm.closest_addrtable(as)
|
||||
if (@addrtable_reloc_target.is_a?(Asm::Label))
|
||||
obj = generator.object_for_label(@addrtable_reloc_target.label, inst)
|
||||
# ref_label = closest_addrtable.add_label(obj)
|
||||
elsif (@addrtable_reloc_target.is_a?(Asm::NumLiteral))
|
||||
# ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value)
|
||||
end
|
||||
as.add_relocation io.tell, ref_label, Asm::R_ARM_PC12,
|
||||
Asm::Instruction::RelocHandler
|
||||
end
|
||||
io.write_uint32 val
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,6 @@ require 'elf/object_file'
|
||||
require 'elf/symbol_table_section'
|
||||
require 'elf/text_section'
|
||||
require 'elf/string_table_section'
|
||||
require 'elf/relocation_table_section'
|
||||
|
||||
module Asm
|
||||
|
||||
@ -17,9 +16,6 @@ module Asm
|
||||
|
||||
@text = Elf::TextSection.new(".text")
|
||||
@object.add_section @text
|
||||
|
||||
# @reloc_table = Elf::RelocationTableSection.new(".text.rel", @symbol_table, @text)
|
||||
# @object.add_section @reloc_table
|
||||
end
|
||||
|
||||
def set_text(text)
|
||||
@ -31,14 +27,6 @@ module Asm
|
||||
@symbol_table.add_func_symbol name, offset, @text, linkage
|
||||
end
|
||||
|
||||
# def add_reloc_symbol(name)
|
||||
# @symbol_table.add_func_symbol name, 0, nil, Elf::Constants::STB_GLOBAL
|
||||
# end
|
||||
|
||||
# def add_reloc(offset, label, type)
|
||||
# @reloc_table.add_reloc offset, label, type
|
||||
# end
|
||||
|
||||
def save(filename)
|
||||
to = File.open(filename, 'wb')
|
||||
@object.write to
|
||||
|
@ -1,41 +0,0 @@
|
||||
module Elf
|
||||
class RelocationTableSection < Section
|
||||
def initialize(name, symtab, text_section)
|
||||
super(name)
|
||||
|
||||
@symtab = symtab
|
||||
@text_section = text_section
|
||||
|
||||
@relocs = []
|
||||
end
|
||||
|
||||
def add_reloc(offset, name, type)
|
||||
@relocs << [offset, name, type]
|
||||
end
|
||||
|
||||
def type
|
||||
Elf::Constants::SHT_REL
|
||||
end
|
||||
|
||||
def ent_size
|
||||
8
|
||||
end
|
||||
|
||||
def link
|
||||
@symtab.index
|
||||
end
|
||||
|
||||
def info
|
||||
@text_section.index
|
||||
end
|
||||
|
||||
def write(io)
|
||||
@relocs.each { |reloc|
|
||||
name_idx = @symtab.index_for_name(reloc[1])
|
||||
io.write_uint32 reloc[0]
|
||||
# +1 because entry number 0 is und
|
||||
io.write_uint32 reloc[2] | ((name_idx+1) << 8)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user