node/lib/metasm/metasm/disassemble_api.rb
# changes a label to another, updates referring instructions etc
# returns the new label
# the new label must be program-uniq (see @program.new_label)
changes a label to another, updates referring instructions etc
returns the new label
the new label must be program-uniq
changes a label to another updates referring instructions etc returns the new label the new label must be program - uniq
def rename_label(old, new)
		return new if old == new
		raise "label #{new.inspect} exists" if @prog_binding[new]
		each_xref(normalize(old)) { |x|
			next if not di = @decoded[x.origin]
			@cpu.replace_instr_arg_immediate(di.instruction, old, new)
			di.comment.to_a.each { |c| c.gsub!(old, new) }
		}
		e = get_edata_at(old, false)
		if e
			e.add_export new, e.export.delete(old), true
		end
		raise "cant rename nonexisting label #{old}" if not @prog_binding[old]
		@label_alias_cache = nil
		@old_prog_binding[new] = @prog_binding[new] = @prog_binding.delete(old)
		@addrs_todo.each { |at|
			case at[0]
			when old; at[0] = new
			when Expression; at[0] = at[0].bind(old => new)
			end
		}
		if @inv_section_reloc[old]
			@inv_section_reloc[old].each { |b, e_, o, r|
				(0..16).each { |off|
					if di = @decoded[Expression[b]+o-off] and di.bin_length > off
						@cpu.replace_instr_arg_immediate(di.instruction, old, new)
					end
				}
				r.target = r.target.bind(old => new)
			}
			@inv_section_reloc[new] = @inv_section_reloc.delete(old)
		end
		if c_parser and @c_parser.toplevel.symbol[old]
			@c_parser.toplevel.symbol[new] = @c_parser.toplevel.symbol.delete(old)
			@c_parser.toplevel.symbol[new].name = new
		end
		new
	end
def rename_label ( old , new ) return new if old == new raise "label #{new.inspect} exists" if @prog_binding [ new ] each_xref ( normalize ( old ) ) { | x | next if not di = @decoded [ x . origin ] @cpu . replace_instr_arg_immediate ( di . instruction , old , new ) di . comment . to_a . each { | c | c . gsub! ( old , new ) } } e = get_edata_at ( old , false ) if e e . add_export new , e . export . delete ( old ) , true end raise "cant rename nonexisting label #{old}" if not @prog_binding [ old ] @label_alias_cache = nil @old_prog_binding [ new ] = @prog_binding [ new ] = @prog_binding . delete ( old ) @addrs_todo . each { | at | case at [ 0 ] when old ; at [ 0 ] = new when Expression ; at [ 0 ] = at [ 0 ] . bind ( old => new ) end } if @inv_section_reloc [ old ] @inv_section_reloc [ old ] . each { | b , e_ , o , r | ( 0 .. 16 ) . each { | off | if di = @decoded [ Expression [ b ] + o - off ] and di . bin_length > off @cpu . replace_instr_arg_immediate ( di . instruction , old , new ) end } r . target = r . target . bind ( old => new ) } @inv_section_reloc [ new ] = @inv_section_reloc . delete ( old ) end if c_parser and @c_parser . toplevel . symbol [ old ] @c_parser . toplevel . symbol [ new ] = @c_parser . toplevel . symbol . delete ( old ) @c_parser . toplevel . symbol [ new ] . name = new end new end
changes a label to another, updates referring instructions etc
returns the new label
the new label must be program-uniq (see @program.new_label)
changes a label to another updates referring instructions etc returns the new label the new label must be program - uniq ( see @program . new_label )
old
new