joeq.Linker.ELF
Class ELFRandomAccessFile

java.lang.Object
  extended by joeq.Linker.ELF.ELFRandomAccessFile
All Implemented Interfaces:
ELF, ELFConstants

public class ELFRandomAccessFile
extends Object

Version:
$Id: ELFRandomAccessFile.java,v 1.9 2004/09/30 03:35:33 joewhaley Exp $
Author:
John Whaley

Field Summary
protected  int e_entry
           
protected  int e_flags
           
protected  int e_machine
           
protected  int e_type
           
protected  int e_version
           
protected  byte ei_class
           
protected  byte ei_data
           
protected  RandomAccessFile file
           
protected  List program_headers
           
protected  Section.StrTabSection section_header_string_table
           
protected  List section_headers
           
protected  List sections
           
 
Fields inherited from interface joeq.Linker.ELF.ELFConstants
ELFCLASS32, ELFCLASS64, ELFCLASSNONE, ELFDATA2LSB, ELFDATA2MSB, ELFDATANONE, ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, EM_386, EM_68K, EM_860, EM_88K, EM_M32, EM_MIPS, EM_MIPS_RS4_BE, EM_SPARC, ET_CORE, ET_DYN, ET_EXEC, ET_HIPROC, ET_LOPROC, ET_NONE, ET_REL, EV_CURRENT, EV_NONE, PT_DYNAMIC, PT_HIPROC, PT_INTERP, PT_LOAD, PT_LOPROC, PT_NOTE, PT_NULL, PT_PHDR, PT_SHLIB, R_386_32, R_386_NONE, R_386_PC32, SHF_ALLOC, SHF_EXECINSTR, SHF_MASKPROC, SHF_WRITE, SHN_ABS, SHN_COMMON, SHN_HIPROC, SHN_HIRESERVE, SHN_INVALID, SHN_LOPROC, SHN_LORESERVE, SHN_UNDEF, SHT_DYNAMIC, SHT_DYNSYM, SHT_HASH, SHT_HIPROC, SHT_HIUSER, SHT_LOPROC, SHT_LOUSER, SHT_NOBITS, SHT_NOTE, SHT_NULL, SHT_PROGBITS, SHT_REL, SHT_RELA, SHT_SHLIB, SHT_STRTAB, SHT_SYMTAB, STB_GLOBAL, STB_HIPROC, STB_LOCAL, STB_LOPROC, STB_WEAK, STT_FILE, STT_FUNC, STT_HIPROC, STT_LOPROC, STT_NOTYPE, STT_OBJECT, STT_SECTION
 
Constructor Summary
ELFRandomAccessFile(byte data, int type, int machine, int entry, RandomAccessFile file)
           
ELFRandomAccessFile(RandomAccessFile file)
           
 
Method Summary
 void addProgramHeader(ProgramHeader p)
          Adds the given ELF program header to this object.
 void addSection(Section s)
          Adds the given ELF section to this object.
static int getHeaderSize()
           
 Section getSection(int i)
           
 Section.StrTabSection getSectionHeaderStringTable()
          Returns the section header string table, if one has been defined.
 int getSectionIndex(Section s)
           
 List getSections()
          Returns the list of ELF sections in this object.
 boolean isBigEndian()
          Returns true if this ELF object is big-endian.
 boolean isLittleEndian()
          Returns true if this ELF object is little-endian.
 int read_addr()
           
 byte read_byte()
           
 void read_bytes(byte[] b)
           
 int read_half()
           
 int read_off()
           
 int read_sword()
           
 int read_word()
           
 void removeProgramHeader(ProgramHeader p)
          Removes the given ELF program header from this object.
 void removeSection(Section s)
          Removes the given ELF section from this object.
 void set_position(int offset)
           
 void setBigEndian()
           
 void setLittleEndian()
           
 void setSectionHeaderStringTable(Section.StrTabSection shstrtab)
          Sets the section header string table to be the given section.
 void write_addr(int v)
           
 void write_byte(byte v)
           
 void write_bytes(byte[] v)
           
 void write_half(int v)
           
 void write_off(int v)
           
 void write_sectionname(String s)
           
 void write_sword(int v)
           
 void write_word(int v)
           
 void write()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected RandomAccessFile file

section_headers

protected List section_headers

ei_class

protected byte ei_class

ei_data

protected byte ei_data

e_type

protected int e_type

e_machine

protected int e_machine

e_version

protected int e_version

e_entry

protected int e_entry

e_flags

protected int e_flags

program_headers

protected List program_headers

sections

protected List sections

section_header_string_table

protected Section.StrTabSection section_header_string_table
Constructor Detail

ELFRandomAccessFile

public ELFRandomAccessFile(RandomAccessFile file)
                    throws IOException
Throws:
IOException

ELFRandomAccessFile

public ELFRandomAccessFile(byte data,
                           int type,
                           int machine,
                           int entry,
                           RandomAccessFile file)
Method Detail

getSection

public Section getSection(int i)
Specified by:
getSection in interface ELF

write_byte

public void write_byte(byte v)
                throws IOException
Throws:
IOException

write_bytes

public void write_bytes(byte[] v)
                 throws IOException
Throws:
IOException

write_half

public void write_half(int v)
                throws IOException
Throws:
IOException

write_word

public void write_word(int v)
                throws IOException
Throws:
IOException

write_sword

public void write_sword(int v)
                 throws IOException
Throws:
IOException

write_off

public void write_off(int v)
               throws IOException
Throws:
IOException

write_addr

public void write_addr(int v)
                throws IOException
Throws:
IOException

write_sectionname

public void write_sectionname(String s)
                       throws IOException
Throws:
IOException

set_position

public void set_position(int offset)
                  throws IOException
Throws:
IOException

read_byte

public byte read_byte()
               throws IOException
Throws:
IOException

read_bytes

public void read_bytes(byte[] b)
                throws IOException
Throws:
IOException

read_half

public int read_half()
              throws IOException
Throws:
IOException

read_word

public int read_word()
              throws IOException
Throws:
IOException

read_sword

public int read_sword()
               throws IOException
Throws:
IOException

read_off

public int read_off()
             throws IOException
Throws:
IOException

read_addr

public int read_addr()
              throws IOException
Throws:
IOException

getSectionHeaderStringTable

public Section.StrTabSection getSectionHeaderStringTable()
Description copied from interface: ELF
Returns the section header string table, if one has been defined. Or null otherwise.

Specified by:
getSectionHeaderStringTable in interface ELF
Returns:
section header string table

setSectionHeaderStringTable

public void setSectionHeaderStringTable(Section.StrTabSection shstrtab)
Description copied from interface: ELF
Sets the section header string table to be the given section.

Specified by:
setSectionHeaderStringTable in interface ELF
Parameters:
shstrtab - new section header string table

getSectionIndex

public int getSectionIndex(Section s)

getSections

public List getSections()
Description copied from interface: ELF
Returns the list of ELF sections in this object.

Specified by:
getSections in interface ELF
Returns:
list of ELF sections in this object

addSection

public void addSection(Section s)
Description copied from interface: ELF
Adds the given ELF section to this object.

Specified by:
addSection in interface ELF
Parameters:
s - section to add

removeSection

public void removeSection(Section s)
Description copied from interface: ELF
Removes the given ELF section from this object.

Specified by:
removeSection in interface ELF
Parameters:
s - section to remove

addProgramHeader

public void addProgramHeader(ProgramHeader p)
Description copied from interface: ELF
Adds the given ELF program header to this object.

Specified by:
addProgramHeader in interface ELF
Parameters:
p - program header to add

removeProgramHeader

public void removeProgramHeader(ProgramHeader p)
Description copied from interface: ELF
Removes the given ELF program header from this object.

Specified by:
removeProgramHeader in interface ELF
Parameters:
p - program header to remove

isLittleEndian

public boolean isLittleEndian()
Description copied from interface: ELF
Returns true if this ELF object is little-endian.

Specified by:
isLittleEndian in interface ELF
Returns:
true if this ELF object is little-endian

isBigEndian

public boolean isBigEndian()
Description copied from interface: ELF
Returns true if this ELF object is big-endian.

Specified by:
isBigEndian in interface ELF
Returns:
true if this ELF object is big-endian

setLittleEndian

public void setLittleEndian()
Specified by:
setLittleEndian in interface ELF

setBigEndian

public void setBigEndian()
Specified by:
setBigEndian in interface ELF

write

public void write()
           throws IOException
Specified by:
write in interface ELF
Throws:
IOException

getHeaderSize

public static int getHeaderSize()


Copyright © 2001-2005 John Whaley. All Rights Reserved.