diff options
author | Sven Gothel <[email protected]> | 2015-02-02 00:22:29 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-02-02 00:22:29 +0100 |
commit | 7db9df61142694965b50f2e0553d4c9e5668439b (patch) | |
tree | 411c69a61d0f693acd55a65f458a2d2b75b84db8 /src/java/jogamp/common/os/elf/ElfHeaderPart1.java | |
parent | 234819d531cdf20842cd0b3302935b187b2012d6 (diff) |
Bug 1126 - Remove static query requirement of MachineDescriptor, find matching StaticConfig at runtime; Fix PPC (Bug 1056) and MIPSLE (Bug 1014) issues.
Currently the StaticConfig is being queried
via the key[OSType, CPUType ..]
as pre-determined by Java properties or the ELF parser.
This adds complication to maintain different platforms
and the key query might not even be sufficient.
The MachineDescriptor's StaticConfig only purpose shall be
to speed-up native data size and offset/alignment retrieval.
This is done by using the StaticConfig index within
all StaticConfig[]s as a lookup-index for the precomputed
struct's size and offset tables.
+++
Solution:
Rename: MachineDescriptor -> MachineDataInfo
Rename: MachineDescriptorRuntime -> MachineDataInfoRuntime
After having defined os.and.arch (OSType, CPUType and ABIType)
w/ the optional help of the now self containing ELF Reader (Bug 1125),
the native gluegen-rt library gets loaded enabling JNI methods.
It is satisfactory to retrieve MachineDataInfo
at runtime w/ JNI and find the matching/compatible StaticConfig.
Only in case none is found, the program needs to abort.
Otherwise the found MachineDataInfo.StaticConfig and MachineDataInfo
are stored for further use (see above).
This removes above complication and key to StaticConfig mapping.
New platforms simply need to add a new unique entry into the
StaticConfig[] table.
++
Also fixes Bug 1056 (PPC), thanks to tmancill [@] debian [.] org,
and Bug 1014 (MIPSLE), thanks to Dejan Latinovic.
Parts of the patch for Bug 1014 from Dejan Latinovic are included.
also solved by this change set.
Diffstat (limited to 'src/java/jogamp/common/os/elf/ElfHeaderPart1.java')
-rw-r--r-- | src/java/jogamp/common/os/elf/ElfHeaderPart1.java | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/java/jogamp/common/os/elf/ElfHeaderPart1.java b/src/java/jogamp/common/os/elf/ElfHeaderPart1.java index ec926e9..4f5b135 100644 --- a/src/java/jogamp/common/os/elf/ElfHeaderPart1.java +++ b/src/java/jogamp/common/os/elf/ElfHeaderPart1.java @@ -32,9 +32,9 @@ import java.io.RandomAccessFile; import java.nio.ByteBuffer; import jogamp.common.Debug; -import jogamp.common.os.MachineDescriptionRuntime; +import jogamp.common.os.MachineDataInfoRuntime; -import com.jogamp.common.os.MachineDescription; +import com.jogamp.common.os.MachineDataInfo; import com.jogamp.common.os.Platform.ABIType; import com.jogamp.common.os.Platform.CPUType; import com.jogamp.common.os.Platform.OSType; @@ -49,8 +49,9 @@ import static jogamp.common.os.elf.IOUtils.readBytes; * <p> * References: * <ul> - * <li>http://linux.die.net/man/5/elf</li> * <li>http://www.sco.com/developers/gabi/latest/contents.html</li> + * <li>https://en.wikipedia.org/wiki/Executable_and_Linkable_Format</li> + * <li>http://linux.die.net/man/5/elf</li> * <li>http://infocenter.arm.com/ * <ul> * <li>ARM IHI 0044E, current through ABI release 2.09</li> @@ -327,7 +328,7 @@ public class ElfHeaderPart1 { public final CPUType cpuType; public final ABIType abiType; - public final MachineDescription.StaticConfig machDesc; + public final MachineDataInfo.StaticConfig machDesc; /** * Note: The input stream shall stay untouch to be able to read sections! @@ -387,15 +388,20 @@ public class ElfHeaderPart1 { abiType = ABIType.GENERIC_ABI; break; case EM_MIPS: - cpuName = "mips"; + // Can be little-endian or big-endian and 32 or 64 bits + if( 64 == getArchClassBits() ) { + cpuName = isLittleEndian() ? "mips64le" : "mips64"; + } else { + cpuName = isLittleEndian() ? "mipsle" : "mips"; + } abiType = ABIType.GENERIC_ABI; break; - case EM_MIPS_X: - cpuName = "mips-x"; + case EM_MIPS_RS3_LE: + cpuName = "mipsle-rs3"; // FIXME: Only little-endian? abiType = ABIType.GENERIC_ABI; break; - case EM_MIPS_RS3_LE: - cpuName = "mips-rs3-le"; + case EM_MIPS_X: + cpuName = isLittleEndian() ? "mipsle-x" : "mips-x"; // Can be little-endian abiType = ABIType.GENERIC_ABI; break; case EM_PPC: @@ -406,12 +412,15 @@ public class ElfHeaderPart1 { cpuName = "ppc64"; abiType = ABIType.GENERIC_ABI; break; - case EM_SH: // Hitachi SuperH ? + case EM_SH: + cpuName = "superh"; + abiType = ABIType.GENERIC_ABI; + break; default: throw new IllegalArgumentException("CPUType and ABIType could not be determined"); } cpuType = CPUType.query(cpuName.toLowerCase()); - machDesc = MachineDescriptionRuntime.get(osType, cpuType, isLittleEndian()); + machDesc = MachineDataInfoRuntime.guessStaticMachineDataInfo(osType, cpuType); if(DEBUG) { System.err.println("ELF-1: cpuName "+cpuName+" -> "+cpuType+", "+abiType+", machDesc "+machDesc.toShortString()); } |