diff options
author | Sven Gothel <[email protected]> | 2013-02-08 19:21:10 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-02-08 19:21:10 +0100 |
commit | 371e1dbff6f5f255ab27ed0ab32368abb06eed82 (patch) | |
tree | 06cdfc232298a9305d7aaaa501fd831726ab52f2 /src/java/jogamp/common/os/elf | |
parent | 60409268e1d43be26b656b191d6684037f943123 (diff) |
Bug 681: Use ELF Header + ARM EABI Section Parsing in PlatformPropsImpl to to distinguish ARM soft-float/hard-float (part-2)
+ /**
+ * Returns the {@link ABIType} of the current platform using given {@link CPUType cpuType}
+ * and {@link OSType osType} as a hint.
+ * <p>
+ * Note the following queries are performed:
+ * <ul>
+ * <li> not {@link CPUFamily#ARM} -> {@link ABIType#GENERIC_ABI} </li>
+ * <li> else
+ * <ul>
+ * <li> not {@link OSType#LINUX} -> {@link ABIType#EABI_GNU_ARMEL} </li>
+ * <li> else
+ * <ul>
+ * <li> Elf ARM Tags -> {@link ABIType#EABI_GNU_ARMEL}, {@link ABIType#EABI_GNU_ARMHF} </li>
+ * </ul></li>
+ * </ul></li>
+ * </ul>
+ * </p>
+ * <p>
+ * Elf ARM Tags are read using {@link ElfHeader}, .. and {@link SectionArmAttributes#abiVFPArgsAcceptsVFPVariant(byte)}.
+ * </p>
+ *
+ * @param cpuType
+ * @param osType
+ * @return
+ */
+ private static final ABIType queryABITypeImpl(CPUType cpuType, OSType osType) {
Diffstat (limited to 'src/java/jogamp/common/os/elf')
-rw-r--r-- | src/java/jogamp/common/os/elf/ElfHeader.java | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/src/java/jogamp/common/os/elf/ElfHeader.java b/src/java/jogamp/common/os/elf/ElfHeader.java index 85bdcf0..3b82a69 100644 --- a/src/java/jogamp/common/os/elf/ElfHeader.java +++ b/src/java/jogamp/common/os/elf/ElfHeader.java @@ -34,6 +34,7 @@ import java.nio.ByteBuffer; import static jogamp.common.os.elf.IOUtils.readBytes; import static jogamp.common.os.elf.IOUtils.seek; import static jogamp.common.os.elf.IOUtils.shortToInt; +import static jogamp.common.os.elf.IOUtils.toHexString; /** * ELF ABI Header @@ -370,6 +371,8 @@ public class ElfHeader { /** Public access to the {@link SectionHeader} */ public final SectionHeader[] sht; + private final String string; + /** * Note: The input stream shall stay untouch to be able to read sections! * @@ -397,6 +400,7 @@ public class ElfHeader { throw new IllegalArgumentException("Buffer is not an ELF Header"); } sht = readSectionHeaderTable(in); + string = toStringImpl(); } public final short getSize() { return d.getE_ehsize(); } @@ -415,29 +419,34 @@ public class ElfHeader { } /** - * Returns the processor's data encoding, - * 1 for {@link #ELFDATA2LSB}, 2 for for {@link #ELFDATA2MSB} - * and 0 for for {@link #ELFDATANONE} + * Returns the processor's data encoding, i.e. + * {@link #ELFDATA2LSB}, {@link #ELFDATA2MSB} or {@link #ELFDATANONE}; */ - public final int getDataEncodingMode() { - switch( d.getE_ident()[EI_DATA] ) { - case ELFDATA2LSB: return 1; - case ELFDATA2MSB: return 2; - default: return 0; - } + public final byte getDataEncodingMode() { + return d.getE_ident()[EI_DATA]; + } + + /** Returns the ELF file version, should be {@link #EV_CURRENT}. */ + public final byte getVersion() { + return d.getE_ident()[EI_VERSION]; } - /** 3 == Linux */ + /** Returns the operating system and ABI for this file, 3 == Linux. Note: Often not used. */ public final byte getOSABI() { return d.getE_ident()[EI_OSABI]; } + + /** Returns the version of the {@link #getOSABI() OSABI} for this file. */ + public final byte getOSABIVersion() { + return d.getE_ident()[EI_ABIVERSION]; + } - /** Returns the object file type */ + /** Returns the object file type, e.g. {@link #ET_EXEC}, .. */ public final short getType() { return d.getE_type(); } - /** Returns the required architecture for the file */ + /** Returns the required architecture for the file, e.g. {@link #EM_386}, .. */ public final short getMachine() { return d.getE_machine(); } @@ -518,6 +527,37 @@ public class ElfHeader { return null; } + public final String toString() { + return string; + } + + private final String toStringImpl() { + final String machineS; + if( isArm() ) { + machineS=", arm"; + } else if( isIntel() ) { + machineS=", intel"; + } else { + machineS=""; + } + final int enc = getDataEncodingMode(); + final String encS; + switch(enc) { + case 1: encS = "LSB"; break; + case 2: encS = "MSB"; break; + default: encS = "NON"; break; + } + final int armABI = getArmABI(); + final String armFlagsS; + if( 0 != armABI ) { + armFlagsS=", arm[abi "+armABI+", lGCC "+getArmLegacyGCCFlags()+", float "+getArmFloatMode()+"]"; + } else { + armFlagsS=""; + } + return "ElfHeader[vers "+getVersion()+", machine["+getMachine()+machineS+"], bits "+getArchClassBits()+", enc "+encS+ + ", abi[os "+getOSABI()+", vers "+getOSABIVersion()+"], flags["+toHexString(getFlags())+armFlagsS+"], type "+getType()+", sh-num "+sht.length+"]"; + } + final SectionHeader[] readSectionHeaderTable(RandomAccessFile in) throws IOException, IllegalArgumentException { // positioning { |