jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Ehdr_p1.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 * Copyright (c) 2013 Gothel Software e.K.
5 * Copyright (c) 2013 JogAmp Community.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26package org.jau.sys.elf;
27
28import java.nio.ByteBuffer;
29
30import org.jau.io.Buffers;
31import org.jau.io.StructAccessor;
32
33public class Ehdr_p1 {
34
35 StructAccessor accessor;
36
37 // private static final int mdIdx = 0;
38 // private final MachineDataInfo md;
39
40 private static final int Ehdr_p1_size = 24 /* ARM_MIPS_32 */; // 24 /* X86_32_UNIX */, 24 /* X86_32_MACOS */, 24 /* PPC_32_UNIX */, 24 /* SPARC_32_SUNOS */, 24 /* X86_32_WINDOWS */, 24 /* LP64_UNIX */, 24 /* X86_64_WINDOWS */
41 private static final int e_ident_offset = 0 /* ARM_MIPS_32 */; // 0 /* X86_32_UNIX */, 0 /* X86_32_MACOS */, 0 /* PPC_32_UNIX */, 0 /* SPARC_32_SUNOS */, 0 /* X86_32_WINDOWS */, 0 /* LP64_UNIX */, 0 /* X86_64_WINDOWS */
42// private static final int e_ident_size = 16 /* ARM_MIPS_32 */; // 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */
43 private static final int e_type_offset = 16 /* ARM_MIPS_32 */; // 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */
44//private static final int e_type_size = 2 /* ARM_MIPS_32 */; // 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */
45 private static final int e_machine_offset = 18 /* ARM_MIPS_32 */; // 18 /* X86_32_UNIX */, 18 /* X86_32_MACOS */, 18 /* PPC_32_UNIX */, 18 /* SPARC_32_SUNOS */, 18 /* X86_32_WINDOWS */, 18 /* LP64_UNIX */, 18 /* X86_64_WINDOWS */
46//private static final int e_machine_size = 2 /* ARM_MIPS_32 */; // 2 /* X86_32_UNIX */, 2 /* X86_32_MACOS */, 2 /* PPC_32_UNIX */, 2 /* SPARC_32_SUNOS */, 2 /* X86_32_WINDOWS */, 2 /* LP64_UNIX */, 2 /* X86_64_WINDOWS */
47 private static final int e_version_offset = 20 /* ARM_MIPS_32 */; // 20 /* X86_32_UNIX */, 20 /* X86_32_MACOS */, 20 /* PPC_32_UNIX */, 20 /* SPARC_32_SUNOS */, 20 /* X86_32_WINDOWS */, 20 /* LP64_UNIX */, 20 /* X86_64_WINDOWS */
48//private static final int e_version_size = 4 /* ARM_MIPS_32 */; // 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 4 /* LP64_UNIX */, 4 /* X86_64_WINDOWS */
49
50 public static int size() {
51 return Ehdr_p1_size;
52 }
53
54 public static Ehdr_p1 create() {
56 }
57
58 public static Ehdr_p1 create(final java.nio.ByteBuffer buf) {
59 return new Ehdr_p1(buf);
60 }
61
62 Ehdr_p1(final java.nio.ByteBuffer buf) {
63 // md = MachineDataInfo.StaticConfig.values()[mdIdx].md;
64 accessor = new StructAccessor(buf);
65 }
66
67 public java.nio.ByteBuffer getBuffer() {
68 return accessor.getBuffer();
69 }
70
71 /** Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]], with array length of <code>16</code> */
72 public static final int getE_identArrayLength() {
73 return 16;
74 }
75
76 /** Setter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]], with array length of <code>16</code> */
77 public Ehdr_p1 setE_ident(final int offset, final byte[] val) {
78 final int arrayLength = 16;
79 if( offset + val.length > arrayLength ) { throw new IndexOutOfBoundsException("offset "+offset+" + val.length "+val.length+" > array-length "+arrayLength); };
80 final int elemSize = Buffers.SIZEOF_BYTE;
81 final ByteBuffer destB = getBuffer();
82 final int bTotal = arrayLength * elemSize;
83 // if( bTotal > e_ident_size ) { throw new IndexOutOfBoundsException("bTotal "+bTotal+" > size "+e_ident_size+", elemSize "+elemSize+" * "+arrayLength); };
84 int bOffset = e_ident_offset;
85 final int bLimes = bOffset + bTotal;
86 if( bLimes > destB.limit() ) { throw new IndexOutOfBoundsException("bLimes "+bLimes+" > buffer.limit "+destB.limit()+", elemOff "+bOffset+", elemSize "+elemSize+" * "+arrayLength); };
87 bOffset += elemSize * offset;
88 accessor.setBytesAt(bOffset, val);
89 return this;
90 }
91
92 /** Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]], with array length of <code>16</code> */
93 public ByteBuffer getE_ident() {
94 return accessor.slice(e_ident_offset, Buffers.SIZEOF_BYTE * 16);
95 }
96
97 /** Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]], with array length of <code>16</code> */
98 public byte[] getE_ident(final int offset, final byte result[]) {
99 final int arrayLength = 16;
100 if( offset + result.length > arrayLength ) { throw new IndexOutOfBoundsException("offset "+offset+" + result.length "+result.length+" > array-length "+arrayLength); };
101 return accessor.getBytesAt(e_ident_offset + (Buffers.SIZEOF_BYTE * offset), result);
102 }
103
104
105 /** Setter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]] */
106 public Ehdr_p1 setE_type(final short val) {
107 accessor.setShortAt(e_type_offset, val);
108 return this;
109 }
110
111 /** Getter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]] */
112 public short getE_type() {
113 return accessor.getShortAt(e_type_offset);
114 }
115
116 /** Setter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]] */
117 public Ehdr_p1 setE_machine(final short val) {
118 accessor.setShortAt(e_machine_offset, val);
119 return this;
120 }
121
122 /** Getter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]] */
123 public short getE_machine() {
124 return accessor.getShortAt(e_machine_offset);
125 }
126
127 /** Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
128 public Ehdr_p1 setE_version(final int val) {
129 accessor.setIntAt(e_version_offset, val);
130 return this;
131 }
132
133 /** Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
134 public int getE_version() {
135 return accessor.getIntAt(e_version_offset);
136 }
137}
Utility methods allowing easy java.nio.Buffer manipulations.
Definition: Buffers.java:43
static final int SIZEOF_BYTE
Definition: Buffers.java:46
static ByteBuffer newDirectByteBuffer(final int size)
Allocates a new direct ByteBuffer with the specified number of elements.
Definition: Buffers.java:61
final byte[] getBytesAt(int byteOffset, final byte[] v)
final ByteBuffer slice(final int byteOffset, final int byteLength)
Returns a slice of the current ByteBuffer starting at the specified byte offset and extending the spe...
final void setIntAt(final int byteOffset, final int v)
Puts a int at the specified byteOffset.
final void setBytesAt(int byteOffset, final byte[] v)
final ByteBuffer getBuffer()
final short getShortAt(final int byteOffset)
Retrieves the short at the specified byteOffset.
final void setShortAt(final int byteOffset, final short v)
Puts a short at the specified byteOffset.
final int getIntAt(final int byteOffset)
Retrieves the int at the specified byteOffset.
Ehdr_p1 setE_version(final int val)
Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Ehdr_p1.java:128
java.nio.ByteBuffer getBuffer()
Definition: Ehdr_p1.java:67
ByteBuffer getE_ident()
Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]],...
Definition: Ehdr_p1.java:93
static final int getE_identArrayLength()
Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]],...
Definition: Ehdr_p1.java:72
static Ehdr_p1 create()
Definition: Ehdr_p1.java:54
byte[] getE_ident(final int offset, final byte result[])
Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]],...
Definition: Ehdr_p1.java:98
short getE_type()
Getter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]].
Definition: Ehdr_p1.java:112
Ehdr_p1 setE_type(final short val)
Setter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]].
Definition: Ehdr_p1.java:106
static Ehdr_p1 create(final java.nio.ByteBuffer buf)
Definition: Ehdr_p1.java:58
int getE_version()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Ehdr_p1.java:134
Ehdr_p1 setE_ident(final int offset, final byte[] val)
Setter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]],...
Definition: Ehdr_p1.java:77
static int size()
Definition: Ehdr_p1.java:50
Ehdr_p1 setE_machine(final short val)
Setter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]].
Definition: Ehdr_p1.java:117
short getE_machine()
Getter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]].
Definition: Ehdr_p1.java:123