/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* Analyzes ELF (Executable and Linking Format) files.
* Created on September 23, 2005
*
* @author Chandan
* @author Trond Norbye
*/
static {
}
/**
* Creates a new instance of ELFAnalyzer
* @param factory the factory to use to obtain default settings
*/
super(factory);
content = new StringBuilder();
}
/**
* {@inheritDoc}
*/
if (in instanceof FileInputStream) {
}
} else {
@SuppressWarnings("resource")
try {
}
} finally {
}
}
}
/**
* Parse the given ELF input stream.
* @param f stream to parse
* @throws IOException
*/
try {
return;
}
return ;
}
int ri = 0;
if (sectionName != null) {
}
}
}
boolean lastPrintable = false;
for (int i = 0; i < ri; i++) {
byte c;
while (size-- > 0) {
if (isReadable(c)) {
lastPrintable = true;
} else if (lastPrintable) {
lastPrintable = false;
}
}
}
sb.trimToSize();
} finally {
}
}
private static boolean isReadable(int c) {
return c > ' ' && c <= 127;
}
if (tab == 0) {
return null;
}
byte c;
}
}
/**
* {@inheritDoc}
*/
return plainfull;
}
}
/**
* Write a cross referenced HTML file.
* @param out Writer to write
*/
}
private static class ELFHeader {
// Elf32 Addr = readInt
// elf32 half = readUnsignedShort
// Off = int
// Sword = int
// Word = int
// un = unsignedBtye
@SuppressWarnings("unused")
public int ei_version;
public int e_entry;
public int e_phoff;
public int e_shoff;
public int e_flags;
public int e_ehsize;
public int e_phentsize;
public int e_phnum;
public int e_shentsize;
public int e_shnum;
public int e_shstrndx;
throw new IllegalArgumentException("Not an ELF file");
}
} else {
}
}
+ "\ne_shstrndx: " + e_shstrndx);
}
}
private static class ELFSection {
/** Section header table entry unused */
@SuppressWarnings("unused")
/** Program data */
@SuppressWarnings("unused")
/** Symbol table */
@SuppressWarnings("unused")
/** String table */
/** Relocation entries with addends */
@SuppressWarnings("unused")
/** Symbol hash table */
@SuppressWarnings("unused")
/** Dynamic linking information */
@SuppressWarnings("unused")
/** Notes */
@SuppressWarnings("unused")
/** Program space with no data (bss) */
@SuppressWarnings("unused")
/** Relocation entries, no addends */
@SuppressWarnings("unused")
/** Reserved */
@SuppressWarnings("unused")
/** Dynamic linker symbol table */
@SuppressWarnings("unused")
/** Array of constructors */
@SuppressWarnings("unused")
/** Array of destructors */
@SuppressWarnings("unused")
/** Array of pre-constructors */
@SuppressWarnings("unused")
/** Section group */
@SuppressWarnings("unused")
/** Extended section indeces */
@SuppressWarnings("unused")
/** Number of defined types. */
@SuppressWarnings("unused")
/** Start OS-specific */
@SuppressWarnings("unused")
/** Prelink library list */
@SuppressWarnings("unused")
/** Checksum for DSO content */
@SuppressWarnings("unused")
/** Sun-specific low bound */
@SuppressWarnings("unused")
@SuppressWarnings("unused")
/** Sun-specific high bound */
@SuppressWarnings("unused")
/** End OS-specific type */
@SuppressWarnings("unused")
/** Start of processor-specific */
@SuppressWarnings("unused")
/** End of processor-specific */
@SuppressWarnings("unused")
/** Start of application-specific */
@SuppressWarnings("unused")
/** End of application-specific */
@SuppressWarnings("unused")
public int sh_name;
public int sh_type;
public int sh_flags;
public int sh_addr;
public int sh_offset;
public int sh_size;
public int sh_link;
public int sh_info;
public int sh_addralign;
public int sh_entsize;
}
+ sh_entsize);
}
}
private static enum ELFIdentification {
private final int value;
}
public int value() {
return this.value;
}
}
private static enum EI_Class {
"None", "32", "64"
};
private final int value;
}
switch (value) {
case 0: return ELFCLASSNONE;
case 1: return ELFCLASS32;
case 2: return ELFCLASS64;
default:
throw new IllegalArgumentException("Invalid EI_CLASS value:"
+ value);
}
}
}
}
private static enum EI_Data {
switch (value) {
case 0: return ELFDATANONE;
case 1: return ELFDATA2LSB;
case 2: return ELFDATA2MSB;
default:
throw new IllegalArgumentException("Invalid EI_DATA value:"
+ value);
}
}
}
private static enum E_Type {
"None", "Relocable", "Executable", "Shared object", "Core"
};
private final int value;
}
switch (value) {
case 0: return ET_NONE;
case 1: return ET_REL;
case 2: return ET_EXEC;
case 3: return ET_DYN;
case 4: return ET_CORE;
default:
return ET_UNKNOWN;
}
}
public int value() {
return this.value;
}
return "Unknown";
}
}
}
private static enum E_Machine {
"No machine", "AT&T WE 32100", "SPARC", "Intel 80386",
"Intel 80860", "MIPS RS3000"
};
private final int value;
}
switch (value) {
case 0: return EM_NONE;
case 1: return EM_M32;
case 2: return EM_SPARC;
case 3: return EM_386;
case 4: return EM_68K;
case 5: return EM_88K;
case 7: return EM_860;
case 8: return EM_MIPS;
default:
return EM_UNKNOWN;
}
}
public int value() {
return this.value;
}
return "Unknown";
}
}
}
private static enum E_Version {
"Invalid", "Current"
};
private final int value;
}
switch (value) {
case 0: return EV_NONE;
case 1: return EV_CURRENT;
default:
throw new IllegalArgumentException("Illegal (or unknown) "
+ "version number: " + value);
}
}
}
}
}