node/lib/metasm/metasm/disassemble.rb
def add_section(encoded, base)
		encoded, base = base, encoded if base.kind_of? EncodedData
		case base
		when ::Integer
		when ::String
			raise "invalid section base #{base.inspect} - not at section start" if encoded.export[base] and encoded.export[base] != 0
			if ed = get_edata_at(base)
				ed.del_export(base)
			end
			encoded.add_export base, 0
		else raise "invalid section base #{base.inspect} - expected string or integer"
		end

		@sections[base] = encoded
		@label_alias_cache = nil
		encoded.binding(base).each { |k, v|
			@old_prog_binding[k] = @prog_binding[k] = v.reduce
		}

		# update section_edata.reloc
		# label -> list of relocs that refers to it
		@inv_section_reloc ||= {}
		@sections.each { |b, e|
			e.reloc.each { |o, r|
				r.target.externals.grep(::String).each { |ext| (@inv_section_reloc[ext] ||= []) << [b, e, o, r] }
			}
		}

		self
	end
# adds a section, updates prog_binding
# base addr is an Integer or a String (label name for offset 0)
adds a section, updates prog_binding
base addr is an Integer or a String (label name for offset 0)
adds a section updates prog_binding base addr is an Integer or a String ( label name for offset 0 )
def add_section(encoded, base)
		encoded, base = base, encoded if base.kind_of? EncodedData
		case base
		when ::Integer
		when ::String
			raise "invalid section base #{base.inspect} - not at section start" if encoded.export[base] and encoded.export[base] != 0
			if ed = get_edata_at(base)
				ed.del_export(base)
			end
			encoded.add_export base, 0
		else raise "invalid section base #{base.inspect} - expected string or integer"
		end
		@sections[base] = encoded
		@label_alias_cache = nil
		encoded.binding(base).each { |k, v|
			@old_prog_binding[k] = @prog_binding[k] = v.reduce
		}
		@inv_section_reloc ||= {}
		@sections.each { |b, e|
			e.reloc.each { |o, r|
				r.target.externals.grep(::String).each { |ext| (@inv_section_reloc[ext] ||= []) << [b, e, o, r] }
			}
		}
		self
	end
def add_section ( encoded , base ) encoded , base = base , encoded if base . kind_of? EncodedData case base when :: Integer when :: String raise "invalid section base #{base.inspect} - not at section start" if encoded . export [ base ] and encoded . export [ base ] != 0 if ed = get_edata_at ( base ) ed . del_export ( base ) end encoded . add_export base , 0 else raise "invalid section base #{base.inspect} - expected string or integer" end @sections [ base ] = encoded @label_alias_cache = nil encoded . binding ( base ) . each { | k , v | @old_prog_binding [ k ] = @prog_binding [ k ] = v . reduce } @inv_section_reloc ||= { } @sections . each { | b , e | e . reloc . each { | o , r | r . target . externals . grep ( :: String ) . each { | ext | ( @inv_section_reloc [ ext ] ||= [ ] ) << [ b , e , o , r ] } } } self end
adds a section, updates prog_binding
base addr is an Integer or a String (label name for offset 0)
adds a section updates prog_binding base addr is an Integer or a String ( label name for offset 0 )
# update section_edata.reloc # label -> list of relocs that refers to it
encoded
base