Source code: Assembler/x86/Code2HeapReference.java
1 // Code2HeapReference.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 Memory.CodeAddress;
10 import Memory.HeapAddress;
11
12 /**
13 * Code2HeapReference
14 *
15 * @author John Whaley <jwhaley@alum.mit.edu>
16 * @version $Id: Code2HeapReference.java,v 1.10 2003/05/12 10:04:52 joewhaley Exp $
17 */
18 public class Code2HeapReference extends Reloc {
19
20 private CodeAddress from_codeloc;
21 private HeapAddress to_heaploc;
22
23 /** Creates new Code2HeapReference */
24 public Code2HeapReference(CodeAddress from_codeloc, HeapAddress to_heaploc) {
25 this.from_codeloc = from_codeloc; this.to_heaploc = to_heaploc;
26 }
27
28 public CodeAddress getFrom() { return from_codeloc; }
29 public HeapAddress getTo() { return to_heaploc; }
30
31 public void patch() { from_codeloc.poke(to_heaploc); }
32
33 public void dumpCOFF(DataOutput out) throws IOException {
34 out.writeInt(from_codeloc.to32BitValue()); // r_vaddr
35 out.writeInt(1); // r_symndx
36 out.writeChar(Reloc.RELOC_ADDR32); // r_type
37 }
38
39 public String toString() {
40 return "from code:"+from_codeloc.stringRep()+" to heap:"+to_heaploc.stringRep();
41 }
42
43 }