node/lib/metasm/metasm/exe_format/elf_decode.rb
def decode_segments
		decode_segments_dynamic
		decode_sections_symbols
		#decode_debug	# too many info, decode on demand
		@segments.each { |s|
			case s.type
			when 'LOAD', 'INTERP'
				sz = s.filesz
				pagepad = (-(s.offset + sz)) % 4096
				s.encoded = @encoded[s.offset, sz] || EncodedData.new
				if s.type == 'LOAD' and sz > 0 and not s.flags.include?('W')
					# align loaded data to the next page boundary for readonly mmap
					# but discard the labels/relocs etc
					s.encoded << @encoded[s.offset+sz, pagepad].data rescue nil
					s.encoded.virtsize = sz+pagepad
				end
				s.encoded.virtsize = s.memsz if s.memsz > s.encoded.virtsize
			end
		}
	end
# decodes the dynamic segment, fills segments.encoded
decodes the dynamic segment, fills segments.encoded
decodes the dynamic segment fills segments . encoded
def decode_segments
		decode_segments_dynamic
		decode_sections_symbols
		@segments.each { |s|
			case s.type
			when 'LOAD', 'INTERP'
				sz = s.filesz
				pagepad = (-(s.offset + sz)) % 4096
				s.encoded = @encoded[s.offset, sz] || EncodedData.new
				if s.type == 'LOAD' and sz > 0 and not s.flags.include?('W')
					s.encoded << @encoded[s.offset+sz, pagepad].data rescue nil
					s.encoded.virtsize = sz+pagepad
				end
				s.encoded.virtsize = s.memsz if s.memsz > s.encoded.virtsize
			end
		}
	end
def decode_segments decode_segments_dynamic decode_sections_symbols @segments . each { | s | case s . type when 'LOAD' , 'INTERP' sz = s . filesz pagepad = ( - ( s . offset + sz ) ) % 4096 s . encoded = @encoded [ s . offset , sz ] || EncodedData . new if s . type == 'LOAD' and sz > 0 and not s . flags . include? ( 'W' ) s . encoded << @encoded [ s . offset + sz , pagepad ] . data rescue nil s . encoded . virtsize = sz + pagepad end s . encoded . virtsize = s . memsz if s . memsz > s . encoded . virtsize end } end
decodes the dynamic segment, fills segments.encoded
decodes the dynamic segment fills segments . encoded
#decode_debug	# too many info, decode on demand # align loaded data to the next page boundary for readonly mmap # but discard the labels/relocs etc