Top Description Inners Fields Constructors Methods
com.sun.jna

pack-priv Class ELFAnalyser

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .RandomAccessFile, .UnsupportedEncodingException, java.math.BigInteger, java.nio.Buffer, .ByteBuffer, .ByteOrder, java.util.ArrayList, .Arrays, .Collections, .HashMap, .LinkedList, .List, .Map

Analyse an ELF file for platform specific attributes.

Primary use-case: Detect whether the java binary is arm hardfloat or softfloat.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private static final int
private static final int
EF_ARM_ABI_FLOAT_HARD

e_flags mask if executable file conforms to hardware floating-point procedure-call standard (arm ABI version 5)

private static final int
EF_ARM_ABI_FLOAT_SOFT

e_flags mask if executable file conforms to software floating-point procedure-call standard (arm ABI version 5)

private static final int
private static final int
private boolean
private static final byte[]
ELF_MAGIC

Generic ELF header

private final String

Constructor Summary

AccessConstructor and Description
private
ELFAnalyser(String filename)

Method Summary

Modifier and TypeMethod and Description
public static ELFAnalyser
analyse(String filename)

public String

Returns:

filename of the parsed file
getFilename
()

public boolean

Returns:

true if the parsed file was detected to be for a 64bit architecture and pointers are expected to be 8byte wide
is64Bit
()

public boolean

Returns:

true if the parsed file was detected to be build for the arm architecture
isArm
()

public boolean

Returns:

true if file was detected to specify, that FP parameters/result passing conforms to AAPCS, VFP variant (hardfloat)
isArmEabiAapcsVfp
()

public boolean
public boolean

Returns:

true if file was detected to conform to the hardware floating-point procedure-call standard via ELF flags
isArmHardFloatFlag
()

public boolean

Returns:

true if file was detected to conform to the software floating-point procedure-call standard via ELF flags
isArmSoftFloatFlag
()

public boolean

Returns:

true if the parsed file is detected to be big endian, false if the file is little endian
isBigEndian
()

public boolean

Returns:

true if the parsed file was detected to be an ELF file
isELF
()

private static Map<Integer, Map<ELFAnalyser.ArmAeabiAttributesTag, Object>>
private static Map<Integer, Map<ELFAnalyser.ArmAeabiAttributesTag, Object>>
private void
private static Map<ELFAnalyser.ArmAeabiAttributesTag, Object>
private static String
readNTBS(ByteBuffer buffer, Integer position)

private static BigInteger
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_64Bitback to summary
private boolean _64Bit
armback to summary
private boolean arm
armEabiAapcsVfpback to summary
private boolean armEabiAapcsVfp
armHardFloatFlagback to summary
private boolean armHardFloatFlag
armSoftFloatFlagback to summary
private boolean armSoftFloatFlag
bigEndianback to summary
private boolean bigEndian
E_MACHINE_ARMback to summary
private static final int E_MACHINE_ARM
EF_ARM_ABI_FLOAT_HARDback to summary
private static final int EF_ARM_ABI_FLOAT_HARD

e_flags mask if executable file conforms to hardware floating-point procedure-call standard (arm ABI version 5)

EF_ARM_ABI_FLOAT_SOFTback to summary
private static final int EF_ARM_ABI_FLOAT_SOFT

e_flags mask if executable file conforms to software floating-point procedure-call standard (arm ABI version 5)

EI_CLASS_64BITback to summary
private static final int EI_CLASS_64BIT
EI_DATA_BIG_ENDIANback to summary
private static final int EI_DATA_BIG_ENDIAN
ELFback to summary
private boolean ELF
ELF_MAGICback to summary
private static final byte[] ELF_MAGIC

Generic ELF header

filenameback to summary
private final String filename

Constructor Detail

ELFAnalyserback to summary
private ELFAnalyser(String filename)

Method Detail

analyseback to summary
public static ELFAnalyser analyse(String filename) throws IOException
getFilenameback to summary
public String getFilename()
Returns:String

filename of the parsed file

is64Bitback to summary
public boolean is64Bit()
Returns:boolean

true if the parsed file was detected to be for a 64bit architecture and pointers are expected to be 8byte wide

isArmback to summary
public boolean isArm()
Returns:boolean

true if the parsed file was detected to be build for the arm architecture

isArmEabiAapcsVfpback to summary
public boolean isArmEabiAapcsVfp()
Returns:boolean

true if file was detected to specify, that FP parameters/result passing conforms to AAPCS, VFP variant (hardfloat)

isArmHardFloatback to summary
public boolean isArmHardFloat()
isArmHardFloatFlagback to summary
public boolean isArmHardFloatFlag()
Returns:boolean

true if file was detected to conform to the hardware floating-point procedure-call standard via ELF flags

isArmSoftFloatFlagback to summary
public boolean isArmSoftFloatFlag()
Returns:boolean

true if file was detected to conform to the software floating-point procedure-call standard via ELF flags

isBigEndianback to summary
public boolean isBigEndian()
Returns:boolean

true if the parsed file is detected to be big endian, false if the file is little endian

isELFback to summary
public boolean isELF()
Returns:boolean

true if the parsed file was detected to be an ELF file

parseAEABIback to summary
private static Map<Integer, Map<ELFAnalyser.ArmAeabiAttributesTag, Object>> parseAEABI(ByteBuffer buffer)
parseArmAttributesback to summary
private static Map<Integer, Map<ELFAnalyser.ArmAeabiAttributesTag, Object>> parseArmAttributes(ByteBuffer bb)
parseEabiAapcsVfpback to summary
private void parseEabiAapcsVfp(ByteBuffer headerData, RandomAccessFile raf) throws IOException
parseFileAttributeback to summary
private static Map<ELFAnalyser.ArmAeabiAttributesTag, Object> parseFileAttribute(ByteBuffer bb)
readNTBSback to summary
private static String readNTBS(ByteBuffer buffer, Integer position)
readULEB128back to summary
private static BigInteger readULEB128(ByteBuffer buffer)
runDetectionback to summary
private void runDetection() throws IOException
com.sun.jna back to summary

pack-priv Class ELFAnalyser.ArmAeabiAttributesTag

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
private final String
private static final Map<String, ELFAnalyser.ArmAeabiAttributesTag>
public static final ELFAnalyser.ArmAeabiAttributesTag
private final ELFAnalyser.ArmAeabiAttributesTag.ParameterType
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag
private static final List<ELFAnalyser.ArmAeabiAttributesTag>
public static final ELFAnalyser.ArmAeabiAttributesTag
private final int
private static final Map<Integer, ELFAnalyser.ArmAeabiAttributesTag>
public static final ELFAnalyser.ArmAeabiAttributesTag
public static final ELFAnalyser.ArmAeabiAttributesTag

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static ELFAnalyser.ArmAeabiAttributesTag
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public static ELFAnalyser.ArmAeabiAttributesTag
public static ELFAnalyser.ArmAeabiAttributesTag
getByValue(int value)

public String
public ELFAnalyser.ArmAeabiAttributesTag.ParameterType
private static ELFAnalyser.ArmAeabiAttributesTag.ParameterType
getParameterType(int value)

public static List<ELFAnalyser.ArmAeabiAttributesTag>
public int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ABI_align8_preservedback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_align8_preserved
ABI_align_neededback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_align_needed
ABI_enum_sizeback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_enum_size
ABI_FP_16bit_formatback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_16bit_format
ABI_FP_denormalback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_denormal
ABI_FP_exceptionsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_exceptions
ABI_FP_number_modelback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_number_model
ABI_FP_optimization_goalsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_optimization_goals
ABI_FP_roundingback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_rounding
ABI_FP_user_exceptionsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_FP_user_exceptions
ABI_HardFP_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_HardFP_use
ABI_optimization_goalsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_optimization_goals
ABI_PCS_GOT_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_PCS_GOT_use
ABI_PCS_R9_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_PCS_R9_use
ABI_PCS_RO_databack to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_PCS_RO_data
ABI_PCS_RW_databack to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_PCS_RW_data
ABI_PCS_wchar_tback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_PCS_wchar_t
ABI_VFP_argsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_VFP_args
ABI_WMMX_argsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ABI_WMMX_args
Advanced_SIMD_archback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag Advanced_SIMD_arch
also_compatible_withback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag also_compatible_with
ARM_ISA_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag ARM_ISA_use
compatibilityback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag compatibility
conformanceback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag conformance
CPU_archback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag CPU_arch
CPU_arch_profileback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag CPU_arch_profile
CPU_nameback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag CPU_name
CPU_raw_nameback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag CPU_raw_name
CPU_unaligned_accessback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag CPU_unaligned_access
DIV_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag DIV_use
Fileback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag File
FP_archback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag FP_arch
FP_HP_extensionback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag FP_HP_extension
MPextension_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag MPextension_use
MPextension_use2back to summary
public static final ELFAnalyser.ArmAeabiAttributesTag MPextension_use2
nameback to summary
private final String name
nameMapback to summary
private static final Map<String, ELFAnalyser.ArmAeabiAttributesTag> nameMap
nodefaultsback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag nodefaults
parameterTypeback to summary
private final ELFAnalyser.ArmAeabiAttributesTag.ParameterType parameterType
PCS_configback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag PCS_config
Sectionback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag Section
Symbolback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag Symbol
T2EE_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag T2EE_use
tagsback to summary
private static final List<ELFAnalyser.ArmAeabiAttributesTag> tags
THUMB_ISA_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag THUMB_ISA_use
valueback to summary
private final int value
valueMapback to summary
private static final Map<Integer, ELFAnalyser.ArmAeabiAttributesTag> valueMap
Virtualization_useback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag Virtualization_use
WMMX_archback to summary
public static final ELFAnalyser.ArmAeabiAttributesTag WMMX_arch

Constructor Detail

ArmAeabiAttributesTagback to summary
public ArmAeabiAttributesTag(int value, String name, ELFAnalyser.ArmAeabiAttributesTag.ParameterType parameterType)

Method Detail

addTagback to summary
private static ELFAnalyser.ArmAeabiAttributesTag addTag(int value, String name, ELFAnalyser.ArmAeabiAttributesTag.ParameterType type)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getByNameback to summary
public static ELFAnalyser.ArmAeabiAttributesTag getByName(String name)
getByValueback to summary
public static ELFAnalyser.ArmAeabiAttributesTag getByValue(int value)
getNameback to summary
public String getName()
getParameterTypeback to summary
public ELFAnalyser.ArmAeabiAttributesTag.ParameterType getParameterType()
getParameterTypeback to summary
private static ELFAnalyser.ArmAeabiAttributesTag.ParameterType getParameterType(int value)
getTagsback to summary
public static List<ELFAnalyser.ArmAeabiAttributesTag> getTags()
getValueback to summary
public int getValue()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
com.sun.jna back to summary

public final Enum ELFAnalyser.ArmAeabiAttributesTag.ParameterType

extends Enum<ELFAnalyser.ArmAeabiAttributesTag.ParameterType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ELFAnalyser.ArmAeabiAttributesTag.ParameterType
public static final ELFAnalyser.ArmAeabiAttributesTag.ParameterType
public static final ELFAnalyser.ArmAeabiAttributesTag.ParameterType

Constructor Summary

AccessConstructor and Description
private

Constructor Detail

ParameterTypeback to summary
private ParameterType()

Method Detail

valueOfback to summary
public static ELFAnalyser.ArmAeabiAttributesTag.ParameterType valueOf(String name)
valuesback to summary
public static ELFAnalyser.ArmAeabiAttributesTag.ParameterType[] values()
com.sun.jna back to summary

pack-priv Class ELFAnalyser.ELFSectionHeaderEntry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int
private String
private final int
private final int
private final int
private final int

Constructor Summary

AccessConstructor and Description
public
ELFSectionHeaderEntry(boolean _64bit, ByteBuffer sectionHeaderData)

Method Summary

Modifier and TypeMethod and Description
public int
public String
public int
public int
public int
public int
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

flagsback to summary
private final int flags
nameback to summary
private String name
nameOffsetback to summary
private final int nameOffset
offsetback to summary
private final int offset
sizeback to summary
private final int size
typeback to summary
private final int type

Constructor Detail

ELFSectionHeaderEntryback to summary
public ELFSectionHeaderEntry(boolean _64bit, ByteBuffer sectionHeaderData)

Method Detail

getFlagsback to summary
public int getFlags()
getNameback to summary
public String getName()
getNameOffsetback to summary
public int getNameOffset()
getOffsetback to summary
public int getOffset()
getSizeback to summary
public int getSize()
getTypeback to summary
public int getType()
setNameback to summary
public void setName(String name)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
com.sun.jna back to summary

pack-priv Class ELFAnalyser.ELFSectionHeaders

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final List<ELFAnalyser.ELFSectionHeaderEntry>

Constructor Summary

AccessConstructor and Description
public
ELFSectionHeaders(boolean _64bit, boolean bigEndian, ByteBuffer headerData, RandomAccessFile raf)

Method Summary

Modifier and TypeMethod and Description
public List<ELFAnalyser.ELFSectionHeaderEntry>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final List<ELFAnalyser.ELFSectionHeaderEntry> entries

Constructor Detail

ELFSectionHeadersback to summary
public ELFSectionHeaders(boolean _64bit, boolean bigEndian, ByteBuffer headerData, RandomAccessFile raf) throws IOException

Method Detail

getEntriesback to summary
public List<ELFAnalyser.ELFSectionHeaderEntry> getEntries()