Source code: Assembler/x86/DirectBindCall.java
1 // DirectBindCall.java, created Tue Feb 27 2:59:43 2001 by joewhaley
2 // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3 // Licensed under the terms of the GNU LGPL; see COPYING for details.
4 package Assembler.x86;
5
6 import java.io.DataOutput;
7 import java.io.IOException;
8
9 import Allocator.DefaultCodeAllocator;
10 import Clazz.jq_CompiledCode;
11 import Clazz.jq_Method;
12 import Memory.CodeAddress;
13 import Util.Assert;
14
15 /**
16 * DirectBindCall
17 *
18 * @author John Whaley <jwhaley@alum.mit.edu>
19 * @version $Id: DirectBindCall.java,v 1.11 2003/05/12 10:04:52 joewhaley Exp $
20 */
21 public class DirectBindCall extends Reloc {
22
23 private CodeAddress source;
24 private jq_Method target;
25
26 public DirectBindCall(CodeAddress source, jq_Method target) {
27 this.source = source; this.target = target;
28 }
29
30 public void patch() {
31 patchTo(target.getDefaultCompiledVersion());
32 }
33
34 public void patchTo(jq_CompiledCode cc) {
35 Assert._assert(cc != null);
36 DefaultCodeAllocator.patchRelativeOffset(source, cc.getEntrypoint());
37 }
38
39 public CodeAddress getSource() { return source; }
40 public jq_Method getTarget() { return target; }
41
42 public String toString() {
43 return "from code:"+source.stringRep()+" to method:"+target;
44 }
45
46 public void dumpCOFF(DataOutput out) throws IOException {
47 out.writeInt(source.to32BitValue()); // r_vaddr
48 out.writeInt(0); // r_symndx
49 out.writeChar(Reloc.RELOC_ADDR32); // r_type
50 }
51
52 }