diff options
author | Sven Gothel <[email protected]> | 2015-02-01 05:21:39 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-02-01 05:21:39 +0100 |
commit | a3f2d08801c5a54048faca52f422bcededf81b2a (patch) | |
tree | 96e83956b62ae3e25043ccc67f4cb1c2c1f232a1 /make | |
parent | 0deceee37d943faa7c34971388863a27f395d6a5 (diff) |
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.
Diffstat (limited to 'make')
-rw-r--r-- | make/elf-header.cfg | 56 | ||||
-rwxr-xr-x | make/scripts/runtest.sh | 4 | ||||
-rw-r--r-- | make/stub_includes/os/elf_header.h | 5 |
3 files changed, 61 insertions, 4 deletions
diff --git a/make/elf-header.cfg b/make/elf-header.cfg index 05c7d79..53da3f6 100644 --- a/make/elf-header.cfg +++ b/make/elf-header.cfg @@ -6,7 +6,61 @@ HierarchicalNativeOutput false #Implements Sym32 Sym #Implements Sym64 Sym -EmitStruct Ehdr +# ELF-1 (part-1) is independent of CPUType/ABI +# hence can use an arbitrary MachineDescriptor index +# for reading the struct Ehdr_p1 ! +StructMachineDescriptorIndex Ehdr_p1 private static final int mdIdx = 0; + +# The following sub structures shall use an mdIdx +# defined by ELF-1 header code, set w/ ctor! +StructMachineDescriptorIndex Ehdr_p2 private final int mdIdx; +StructMachineDescriptorIndex Shdr private final int mdIdx; + +ManuallyImplement Ehdr_p2.size +ManuallyImplement Ehdr_p2.create +ManuallyImplement Ehdr_p2.Ehdr_p2 +ManuallyImplement Shdr.size +ManuallyImplement Shdr.create +ManuallyImplement Shdr.Shdr + +CustomJavaCode Ehdr_p2 public static int size(final int mdIdx) { +CustomJavaCode Ehdr_p2 return Ehdr_p2_size[mdIdx]; +CustomJavaCode Ehdr_p2 } +CustomJavaCode Ehdr_p2 +CustomJavaCode Ehdr_p2 public static Ehdr_p2 create(final int mdIdx) { +CustomJavaCode Ehdr_p2 return create(mdIdx, Buffers.newDirectByteBuffer(size(mdIdx))); +CustomJavaCode Ehdr_p2 } +CustomJavaCode Ehdr_p2 +CustomJavaCode Ehdr_p2 public static Ehdr_p2 create(final int mdIdx, final java.nio.ByteBuffer buf) { +CustomJavaCode Ehdr_p2 return new Ehdr_p2(mdIdx, buf); +CustomJavaCode Ehdr_p2 } +CustomJavaCode Ehdr_p2 +CustomJavaCode Ehdr_p2 Ehdr_p2(final int mdIdx, final java.nio.ByteBuffer buf) { +CustomJavaCode Ehdr_p2 this.mdIdx = mdIdx; +CustomJavaCode Ehdr_p2 this.md = MachineDescription.StaticConfig.values()[mdIdx].md; +CustomJavaCode Ehdr_p2 this.accessor = new StructAccessor(buf); +CustomJavaCode Ehdr_p2 } + +CustomJavaCode Shdr public static int size(final int mdIdx) { +CustomJavaCode Shdr return Shdr_size[mdIdx]; +CustomJavaCode Shdr } +CustomJavaCode Shdr +CustomJavaCode Shdr public static Shdr create(final int mdIdx) { +CustomJavaCode Shdr return create(mdIdx, Buffers.newDirectByteBuffer(size(mdIdx))); +CustomJavaCode Shdr } +CustomJavaCode Shdr +CustomJavaCode Shdr public static Shdr create(final int mdIdx, final java.nio.ByteBuffer buf) { +CustomJavaCode Shdr return new Shdr(mdIdx, buf); +CustomJavaCode Shdr } +CustomJavaCode Shdr +CustomJavaCode Shdr Shdr(final int mdIdx, final java.nio.ByteBuffer buf) { +CustomJavaCode Shdr this.mdIdx = mdIdx; +CustomJavaCode Shdr this.md = MachineDescription.StaticConfig.values()[mdIdx].md; +CustomJavaCode Shdr this.accessor = new StructAccessor(buf); +CustomJavaCode Shdr } + +EmitStruct Ehdr_p1 +EmitStruct Ehdr_p2 EmitStruct Shdr #EmitStruct Sym32 #EmitStruct Sym64 diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index 6a5bee9..d353987 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -81,7 +81,7 @@ function onetest() { echo } # -onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG +#onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestSystemPropsAndEnvs 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestVersionNumber 2>&1 | tee -a $LOG @@ -126,7 +126,7 @@ onetest com.jogamp.common.GlueGenVersion 2>&1 | tee -a $LOG #onetest com.jogamp.common.nio.TestByteBufferInputStream 2>&1 | tee -a $LOG #onetest com.jogamp.common.nio.TestByteBufferOutputStream 2>&1 | tee -a $LOG #onetest com.jogamp.common.nio.TestByteBufferCopyStream 2>&1 | tee -a $LOG -#onetest com.jogamp.common.os.TestElfReader01 2>&1 | tee -a $LOG +onetest com.jogamp.common.os.TestElfReader01 $* 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.PCPPTest 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG diff --git a/make/stub_includes/os/elf_header.h b/make/stub_includes/os/elf_header.h index 7d608f0..b303029 100644 --- a/make/stub_includes/os/elf_header.h +++ b/make/stub_includes/os/elf_header.h @@ -15,6 +15,9 @@ typedef struct { uint16_t e_type; uint16_t e_machine; uint32_t e_version; +} Ehdr_p1; + +typedef struct { ElfN_Addr e_entry; ElfN_Off e_phoff; ElfN_Off e_shoff; @@ -25,7 +28,7 @@ typedef struct { uint16_t e_shentsize; uint16_t e_shnum; uint16_t e_shstrndx; -} Ehdr; +} Ehdr_p2; typedef struct { uint32_t sh_name; |