1
2
3
4 package joeq.Assembler;
5
6 import java.io.DataOutput;
7 import java.io.IOException;
8 import joeq.Memory.HeapAddress;
9 import jwutil.util.Assert;
10
11 /***
12 * ExternalReference
13 *
14 * @author John Whaley <jwhaley@alum.mit.edu>
15 * @version $Id: ExternalReference.java 1941 2004-09-30 03:37:06Z joewhaley $
16 */
17 public class ExternalReference extends Reloc {
18
19 private HeapAddress heap_from;
20 private int symbol_ndx;
21 private String external_name;
22
23 /*** Creates new ExternalReference */
24 public ExternalReference(HeapAddress heap_from, String external_name) {
25 this.heap_from = heap_from;
26 this.external_name = external_name;
27 }
28
29 public void setSymbolIndex(int ndx) { Assert._assert(ndx != 0); this.symbol_ndx = ndx; }
30
31 public void dumpCOFF(DataOutput out) throws IOException {
32 Assert._assert(symbol_ndx != 0);
33 out.writeInt(heap_from.to32BitValue());
34 out.writeInt(symbol_ndx);
35 out.writeChar(Reloc.RELOC_ADDR32);
36 }
37
38 public HeapAddress getAddress() { return heap_from; }
39 public int getSymbolIndex() { return symbol_ndx; }
40 public String getName() { return external_name; }
41
42 public void patch() { Assert.UNREACHABLE(); }
43
44 public String toString() {
45 return "from heap:"+heap_from.stringRep()+" to external:"+external_name+" (symndx "+symbol_ndx+")";
46 }
47
48 }