From a3f2d08801c5a54048faca52f422bcededf81b2a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 1 Feb 2015 05:21:39 +0100 Subject: Bug 1125 - Make ELF Reader 'jogamp.common.os.elf' Stateless ELF Reader 'jogamp.common.os.elf' currently uses Platform's pre-determined OS_TYPE and CPUType. It also uses the host platforms MachineDescription, hence can not read ELF files from other machines. This also forbids Platform to determine CPUType etc w/o having a valid 'os.arch' property. +++ ElfHeader should be split in - ElfHeaderPart1 (CPUType independent) - ElfHeaderPart2 (CPUType dependent) Fix shall make the ELF Reader self containing by only using ELF CPUType data, etc. This requires customization of struct parsing, where MachineDescription.Static index shall be - defined in ElfHeaderPart1 using e_Ident's CPUType. - used in ElfHeaderPart2 and all its struct types. --- src/java/jogamp/common/os/elf/IOUtils.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/java/jogamp/common/os/elf/IOUtils.java') diff --git a/src/java/jogamp/common/os/elf/IOUtils.java b/src/java/jogamp/common/os/elf/IOUtils.java index 62b47db..454a325 100644 --- a/src/java/jogamp/common/os/elf/IOUtils.java +++ b/src/java/jogamp/common/os/elf/IOUtils.java @@ -30,7 +30,6 @@ package jogamp.common.os.elf; import java.io.IOException; import java.io.RandomAccessFile; -import com.jogamp.common.os.Platform; import com.jogamp.common.util.Bitstream; class IOUtils { @@ -61,17 +60,12 @@ class IOUtils { in.seek(newPos); } - static int readUInt32(final byte[] in, final int offset) { - final int v = Bitstream.uint32LongToInt(Bitstream.readUInt32(!Platform.isLittleEndian(), in, offset)); + static int readUInt32(final boolean isBigEndian, final byte[] in, final int offset) { + final int v = Bitstream.uint32LongToInt(Bitstream.readUInt32(isBigEndian, in, offset)); if( 0 > v ) { throw new IllegalArgumentException("Read uint32 value "+toHexString(v)+" > int32-max "+toHexString(MAX_INT_VALUE)); } return v; - /** Need to fix endian for below path .. - checkBounds(in, offset, 4); - final byte[] uint = new byte[] { 0, 0, 0, 0, in[offset+0], in[offset+1], in[offset+2], in[offset+3] }; - final ByteBuffer b = ByteBuffer.wrap(uint, 0, 8).order(ByteOrder.nativeOrder()); - return b.asLongBuffer().get(0); */ } /** -- cgit v1.2.3