node/lib/metasm/metasm/exe_format/elf_encode.rb
# reads the existing segment/sections.encoded and populate @relocations from the encoded.reloc hash
reads the existing segment/sections.encoded and populate @relocations from the encoded.reloc hash
reads the existing segment / sections . encoded and populate @relocations from the encoded . reloc hash
def create_relocations
		@relocations = []
		arch_create_reloc_func = "arch_#{@header.machine.downcase}_create_reloc"
		if not respond_to? arch_create_reloc_func
			puts "Elf: create_reloc: unhandled architecture #{@header.machine}" if $VERBOSE
			return
		end
		curaddr = label_at(@encoded, 0, 'elf_start')
		binding = {'_DYNAMIC' => 0, '_GOT' => 0}	
		@sections.each { |s|
			next if not s.encoded
			binding.update s.encoded.binding(curaddr)
			curaddr = Expression[curaddr, :+, s.encoded.virtsize]
		}
		@sections.each { |s|
			next if not s.encoded
			s.encoded.reloc.each { |off, rel|
				t = rel.target.bind(binding).reduce
				next if not t.kind_of? Expression	 segment_encode only
				send(arch_create_reloc_func, s, off, binding)
			}
		}
	end
def create_relocations @relocations = [ ] arch_create_reloc_func = "arch_#{@header.machine.downcase}_create_reloc" if not respond_to? arch_create_reloc_func puts "Elf: create_reloc: unhandled architecture #{@header.machine}" if $VERBOSE return end curaddr = label_at ( @encoded , 0 , 'elf_start' ) binding = { '_DYNAMIC' => 0 , '_GOT' => 0 } @sections . each { | s | next if not s . encoded binding . update s . encoded . binding ( curaddr ) curaddr = Expression [ curaddr , :+ , s . encoded . virtsize ] } @sections . each { | s | next if not s . encoded s . encoded . reloc . each { | off , rel | t = rel . target . bind ( binding ) . reduce next if not t . kind_of? Expression send ( arch_create_reloc_func , s , off , binding ) } } end
reads the existing segment/sections.encoded and populate @relocations from the encoded.reloc hash
reads the existing segment / sections . encoded and populate @relocations from the encoded . reloc hash
# create a fake binding with all our own symbols # not foolproof, should work in most cases # XXX # XXX segment_encode only