Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: Assembler/x86/Heap2CodeReference.java


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