node/lib/metasm/metasm/exe_format/elf_decode.rb
# interprets tags (convert flags, arrays etc), mark them as self.encoded.export
interprets tags (convert flags, arrays etc), mark them as self.encoded.export
interprets tags ( convert flags arrays etc ) mark them as self . encoded . export
def decode_segments_tags_interpret
		if @tag['STRTAB']
			if not sz = @tag['STRSZ']
				puts "W: Elf: no string table size tag" if $VERBOSE
			else
				if l = add_label('dynamic_strtab', @tag['STRTAB'])
					@tag['STRTAB'] = l
					strtab = @encoded[l, sz].data
				end
			end
		end
		@tag.keys.each { |k|
			case k
			when Integer
			when 'NEEDED'
				if not strtab
					puts "W: Elf: no string table, needed for tag #{k}" if $VERBOSE
					next
				end
				@tag[k].map! { |v| readstr(strtab, v) }
			when 'SONAME', 'RPATH', 'RUNPATH'
				if not strtab
					puts "W: Elf: no string table, needed for tag #{k}" if $VERBOSE
					next
				end
				@tag[k] = readstr(strtab, @tag[k])
			when 'INIT', 'FINI', 'PLTGOT', 'HASH', 'GNU_HASH', 'SYMTAB', 'RELA', 'REL', 'JMPREL'
				@tag[k] = add_label('dynamic_' + k.downcase, @tag[k]) || @tag[k]
			when 'INIT_ARRAY', 'FINI_ARRAY', 'PREINIT_ARRAY'
				next if not l = add_label('dynamic_' + k.downcase, @tag[k])
				if not sz = @tag.delete(k+'SZ')
					puts "W: Elf: tag #{k} has no corresponding size tag" if $VERBOSE
					next
				end
				tab = @encoded[l, sz]
				tab.ptr = 0
				@tag[k] = []
				while tab.ptr < tab.length
					a = decode_addr(tab)
					@tag[k] << (add_label("dynamic_#{k.downcase}_#{@tag[k].length}", a) || a)
				end
			when 'PLTREL';     @tag[k] =  int_to_hash(@tag[k], DYNAMIC_TAG)
			when 'FLAGS';      @tag[k] = bits_to_hash(@tag[k], DYNAMIC_FLAGS)
			when 'FLAGS_1';    @tag[k] = bits_to_hash(@tag[k], DYNAMIC_FLAGS_1)
			when 'FEATURES_1'; @tag[k] = bits_to_hash(@tag[k], DYNAMIC_FEATURES_1)
			end
		}
	end
def decode_segments_tags_interpret if @tag [ 'STRTAB' ] if not sz = @tag [ 'STRSZ' ] puts "W: Elf: no string table size tag" if $VERBOSE else if l = add_label ( 'dynamic_strtab' , @tag [ 'STRTAB' ] ) @tag [ 'STRTAB' ] = l strtab = @encoded [ l , sz ] . data end end end @tag . keys . each { | k | case k when Integer when 'NEEDED' if not strtab puts "W: Elf: no string table, needed for tag #{k}" if $VERBOSE next end @tag [ k ] . map! { | v | readstr ( strtab , v ) } when 'SONAME' , 'RPATH' , 'RUNPATH' if not strtab puts "W: Elf: no string table, needed for tag #{k}" if $VERBOSE next end @tag [ k ] = readstr ( strtab , @tag [ k ] ) when 'INIT' , 'FINI' , 'PLTGOT' , 'HASH' , 'GNU_HASH' , 'SYMTAB' , 'RELA' , 'REL' , 'JMPREL' @tag [ k ] = add_label ( 'dynamic_' + k . downcase , @tag [ k ] ) || @tag [ k ] when 'INIT_ARRAY' , 'FINI_ARRAY' , 'PREINIT_ARRAY' next if not l = add_label ( 'dynamic_' + k . downcase , @tag [ k ] ) if not sz = @tag . delete ( k + 'SZ' ) puts "W: Elf: tag #{k} has no corresponding size tag" if $VERBOSE next end tab = @encoded [ l , sz ] tab . ptr = 0 @tag [ k ] = [ ] while tab . ptr < tab . length a = decode_addr ( tab ) @tag [ k ] << ( add_label ( "dynamic_#{k.downcase}_#{@tag[k].length}" , a ) || a ) end when 'PLTREL' ; @tag [ k ] = int_to_hash ( @tag [ k ] , DYNAMIC_TAG ) when 'FLAGS' ; @tag [ k ] = bits_to_hash ( @tag [ k ] , DYNAMIC_FLAGS ) when 'FLAGS_1' ; @tag [ k ] = bits_to_hash ( @tag [ k ] , DYNAMIC_FLAGS_1 ) when 'FEATURES_1' ; @tag [ k ] = bits_to_hash ( @tag [ k ] , DYNAMIC_FEATURES_1 ) end } end
interprets tags (convert flags, arrays etc), mark them as self.encoded.export
interprets tags ( convert flags arrays etc ) mark them as self . encoded . export
# array of strings # string