node/lib/metasm/metasm/exe_format/elf_encode.rb
def encode_segments_symbols(strtab)
		return if @symbols.length <= 1

		if not dynsym = @sections.find { |s| s.type == 'DYNSYM' }
			dynsym = Section.new
			dynsym.name = '.dynsym'
			dynsym.type = 'DYNSYM'
			dynsym.entsize = Symbol.size(self)
			dynsym.addralign = 4
			dynsym.flags = ['ALLOC']
			dynsym.info = @symbols[1..-1].find_all { |s| s.bind == 'LOCAL' }.length + 1
			dynsym.link = strtab
			encode_add_section dynsym
		end
		dynsym.encoded = EncodedData.new
		@symbols.each { |s| dynsym.encoded << s.encode(self, strtab.encoded) }	# needs all section indexes, as will be in the final section header

		@tag['SYMTAB'] = label_at(dynsym.encoded, 0)
		@tag['SYMENT'] = Symbol.size(self)

		encode_check_section_size dynsym

		dynsym
	end
# encodes the symbol table
# should have a stable self.sections array (only append allowed after this step)
encodes the symbol table
should have a stable self.sections array (only append allowed after this step)
encodes the symbol table should have a stable self . sections array ( only append allowed after this step )
def encode_segments_symbols(strtab)
		return if @symbols.length <= 1
		if not dynsym = @sections.find { |s| s.type == 'DYNSYM' }
			dynsym = Section.new
			dynsym.name = '.dynsym'
			dynsym.type = 'DYNSYM'
			dynsym.entsize = Symbol.size(self)
			dynsym.addralign = 4
			dynsym.flags = ['ALLOC']
			dynsym.info = @symbols[1..-1].find_all { |s| s.bind == 'LOCAL' }.length + 1
			dynsym.link = strtab
			encode_add_section dynsym
		end
		dynsym.encoded = EncodedData.new
		@symbols.each { |s| dynsym.encoded << s.encode(self, strtab.encoded) }	
		@tag['SYMTAB'] = label_at(dynsym.encoded, 0)
		@tag['SYMENT'] = Symbol.size(self)
		encode_check_section_size dynsym
		dynsym
	end
def encode_segments_symbols ( strtab ) return if @symbols . length <= 1 if not dynsym = @sections . find { | s | s . type == 'DYNSYM' } dynsym = Section . new dynsym . name = '.dynsym' dynsym . type = 'DYNSYM' dynsym . entsize = Symbol . size ( self ) dynsym . addralign = 4 dynsym . flags = [ 'ALLOC' ] dynsym . info = @symbols [ 1 .. - 1 ] . find_all { | s | s . bind == 'LOCAL' } . length + 1 dynsym . link = strtab encode_add_section dynsym end dynsym . encoded = EncodedData . new @symbols . each { | s | dynsym . encoded << s . encode ( self , strtab . encoded ) } @tag [ 'SYMTAB' ] = label_at ( dynsym . encoded , 0 ) @tag [ 'SYMENT' ] = Symbol . size ( self ) encode_check_section_size dynsym dynsym end
encodes the symbol table
should have a stable self.sections array (only append allowed after this step)
encodes the symbol table should have a stable self . sections array ( only append allowed after this step )
# needs all section indexes, as will be in the final section header
strtab