asm
Class Module
java.lang.Object
|
+--asm.Module
- public class Module
- extends java.lang.Object
Used to represent a single object file.
Object file format:
- 0
- Object file magic number
- 4
- Symbol table size.
- 8
- Reference table size.
- 12
- Data segment size
- 16
- Text segment size
- Symbol Table:
- This includes just the global symbols defined in this module, w/ a
format something like "foo 16 bar 128 baz 32" It maps symbol to an
offset into the segment. (We should actually put _all_ symbols in
here.)
- Reference Table:
- This is another symbol table, but it maps symbols to LISTS of
offsets (references): "print 256 260 alloc 60 globalVariable 8"
- Data:
- Just a bunch of binary data.
- Text:
- Just a bunch of binary instructions.
- Version:
- $Id: Module.java,v 1.9 2003/01/22 05:35:08 dugan Exp $
Constructor Summary |
Module(java.lang.String fileName)
|
Method Summary |
int |
getOffset(java.lang.String label)
|
java.util.ArrayList |
getReferences(java.lang.String label)
Answer an arraylist of the references made by this module. |
static void |
main(java.lang.String[] args)
|
void |
patch(int offset,
java.lang.String label,
java.util.ArrayList definingModules)
Patch the instruction in this module at the given offset that makes
the reference to the given label, defined in the given module. |
void |
print(java.io.PrintStream out,
boolean printText)
|
void |
printSyms(java.io.PrintWriter out)
Arguably somewhat broken: right now only prints symbols that
are ever "targeted", that is, are the targets for jumps or branches. |
void |
read(java.io.DataInputStream s)
|
void |
read(java.lang.String fileName)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
bare
public static boolean bare
symTabSize
int symTabSize
refTabSize
int refTabSize
dataSize
int dataSize
textSize
int textSize
refTable
java.util.Map refTable
symTable
java.util.Map symTable
targets
java.util.Set targets
data
byte[] data
text
byte[] text
textOffset
int textOffset
dataOffset
int dataOffset
fileName
java.lang.String fileName
Module
public Module(java.lang.String fileName)
throws java.io.IOException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
getReferences
public java.util.ArrayList getReferences(java.lang.String label)
- Answer an arraylist of the references made by this module.
patch
public void patch(int offset,
java.lang.String label,
java.util.ArrayList definingModules)
- Patch the instruction in this module at the given offset that makes
the reference to the given label, defined in the given module.
This method will check this module first to see if it also defines
the label -- hence local labels will be resolved correctly. FIX:
Currently, only patches the low 2 bytes of all instructions -- so
this means that long jumps aren't handled correctly. Also, currently
the only instructions that are "patched" are: J, JAL, BEQ, BNE,
BLEZ, BGTZ, LW, SW, ADDI, ORI.
getOffset
public int getOffset(java.lang.String label)
read
public void read(java.io.DataInputStream s)
throws java.io.IOException
java.io.IOException
read
public void read(java.lang.String fileName)
throws java.io.IOException
java.io.IOException
printSyms
public void printSyms(java.io.PrintWriter out)
- Arguably somewhat broken: right now only prints symbols that
are ever "targeted", that is, are the targets for jumps or branches.
print
public void print(java.io.PrintStream out,
boolean printText)
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception