jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Shdr.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 org.jau.io.Buffers;
29import org.jau.io.StructAccessor;
30import org.jau.sys.MachineDataInfo;
31
32public class Shdr {
33
34 StructAccessor accessor;
35
36 private final int mdIdx;
37 private final MachineDataInfo md;
38
39 private static final int[] Shdr_size = new int[] { 40 /* ARM_MIPS_32 */, 40 /* X86_32_UNIX */, 40 /* X86_32_MACOS */, 40 /* PPC_32_UNIX */, 40 /* SPARC_32_SUNOS */, 40 /* X86_32_WINDOWS */, 64 /* LP64_UNIX */, 64 /* X86_64_WINDOWS */ };
40 private static final int[] sh_name_offset = new int[] { 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 */ };
41//private static final int[] sh_name_size = new int[] { 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 */ };
42 private static final int[] sh_type_offset = new int[] { 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 */ };
43//private static final int[] sh_type_size = new int[] { 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 */ };
44 private static final int[] sh_flags_offset = new int[] { 8 /* ARM_MIPS_32 */, 8 /* X86_32_UNIX */, 8 /* X86_32_MACOS */, 8 /* PPC_32_UNIX */, 8 /* SPARC_32_SUNOS */, 8 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
45//private static final int[] sh_flags_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
46 private static final int[] sh_addr_offset = new int[] { 12 /* ARM_MIPS_32 */, 12 /* X86_32_UNIX */, 12 /* X86_32_MACOS */, 12 /* PPC_32_UNIX */, 12 /* SPARC_32_SUNOS */, 12 /* X86_32_WINDOWS */, 16 /* LP64_UNIX */, 16 /* X86_64_WINDOWS */ };
47//private static final int[] sh_addr_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
48 private static final int[] sh_offset_offset = new int[] { 16 /* ARM_MIPS_32 */, 16 /* X86_32_UNIX */, 16 /* X86_32_MACOS */, 16 /* PPC_32_UNIX */, 16 /* SPARC_32_SUNOS */, 16 /* X86_32_WINDOWS */, 24 /* LP64_UNIX */, 24 /* X86_64_WINDOWS */ };
49//private static final int[] sh_offset_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
50 private static final int[] sh_size_offset = new int[] { 20 /* ARM_MIPS_32 */, 20 /* X86_32_UNIX */, 20 /* X86_32_MACOS */, 20 /* PPC_32_UNIX */, 20 /* SPARC_32_SUNOS */, 20 /* X86_32_WINDOWS */, 32 /* LP64_UNIX */, 32 /* X86_64_WINDOWS */ };
51//private static final int[] sh_size_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
52 private static final int[] sh_link_offset = new int[] { 24 /* ARM_MIPS_32 */, 24 /* X86_32_UNIX */, 24 /* X86_32_MACOS */, 24 /* PPC_32_UNIX */, 24 /* SPARC_32_SUNOS */, 24 /* X86_32_WINDOWS */, 40 /* LP64_UNIX */, 40 /* X86_64_WINDOWS */ };
53//private static final int[] sh_link_size = new int[] { 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 */ };
54 private static final int[] sh_info_offset = new int[] { 28 /* ARM_MIPS_32 */, 28 /* X86_32_UNIX */, 28 /* X86_32_MACOS */, 28 /* PPC_32_UNIX */, 28 /* SPARC_32_SUNOS */, 28 /* X86_32_WINDOWS */, 44 /* LP64_UNIX */, 44 /* X86_64_WINDOWS */ };
55//private static final int[] sh_info_size = new int[] { 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 */ };
56 private static final int[] sh_addralign_offset = new int[] { 32 /* ARM_MIPS_32 */, 32 /* X86_32_UNIX */, 32 /* X86_32_MACOS */, 32 /* PPC_32_UNIX */, 32 /* SPARC_32_SUNOS */, 32 /* X86_32_WINDOWS */, 48 /* LP64_UNIX */, 48 /* X86_64_WINDOWS */ };
57//private static final int[] sh_addralign_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
58 private static final int[] sh_entsize_offset = new int[] { 36 /* ARM_MIPS_32 */, 36 /* X86_32_UNIX */, 36 /* X86_32_MACOS */, 36 /* PPC_32_UNIX */, 36 /* SPARC_32_SUNOS */, 36 /* X86_32_WINDOWS */, 56 /* LP64_UNIX */, 56 /* X86_64_WINDOWS */ };
59//private static final int[] sh_entsize_size = new int[] { 4 /* ARM_MIPS_32 */, 4 /* X86_32_UNIX */, 4 /* X86_32_MACOS */, 4 /* PPC_32_UNIX */, 4 /* SPARC_32_SUNOS */, 4 /* X86_32_WINDOWS */, 8 /* LP64_UNIX */, 8 /* X86_64_WINDOWS */ };
60
61 public java.nio.ByteBuffer getBuffer() {
62 return accessor.getBuffer();
63 }
64
65 /** Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
66 public Shdr setSh_name(final int val) {
67 accessor.setIntAt(sh_name_offset[mdIdx], val);
68 return this;
69 }
70
71 /** Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
72 public int getSh_name() {
73 return accessor.getIntAt(sh_name_offset[mdIdx]);
74 }
75
76 /** Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
77 public Shdr setSh_type(final int val) {
78 accessor.setIntAt(sh_type_offset[mdIdx], val);
79 return this;
80 }
81
82 /** Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
83 public int getSh_type() {
84 return accessor.getIntAt(sh_type_offset[mdIdx]);
85 }
86
87 /** Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
88 public Shdr setSh_flags(final long val) {
89 accessor.setLongAt(sh_flags_offset[mdIdx], val, md.longSizeInBytes());
90 return this;
91 }
92
93 /** Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
94 public long getSh_flags() {
95 return accessor.getLongAt(sh_flags_offset[mdIdx], md.longSizeInBytes());
96 }
97
98 /** Setter for native field: CType['ElfN_Addr' (typedef), size [fixed false, lnx64 8], [int]] */
99 public Shdr setSh_addr(final long val) {
100 accessor.setLongAt(sh_addr_offset[mdIdx], val, md.longSizeInBytes());
101 return this;
102 }
103
104 /** Getter for native field: CType['ElfN_Addr' (typedef), size [fixed false, lnx64 8], [int]] */
105 public long getSh_addr() {
106 return accessor.getLongAt(sh_addr_offset[mdIdx], md.longSizeInBytes());
107 }
108
109 /** Setter for native field: CType['ElfN_Off' (typedef), size [fixed false, lnx64 8], [int]] */
110 public Shdr setSh_offset(final long val) {
111 accessor.setLongAt(sh_offset_offset[mdIdx], val, md.longSizeInBytes());
112 return this;
113 }
114
115 /** Getter for native field: CType['ElfN_Off' (typedef), size [fixed false, lnx64 8], [int]] */
116 public long getSh_offset() {
117 return accessor.getLongAt(sh_offset_offset[mdIdx], md.longSizeInBytes());
118 }
119
120 /** Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
121 public Shdr setSh_size(final long val) {
122 accessor.setLongAt(sh_size_offset[mdIdx], val, md.longSizeInBytes());
123 return this;
124 }
125
126 /** Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
127 public long getSh_size() {
128 return accessor.getLongAt(sh_size_offset[mdIdx], md.longSizeInBytes());
129 }
130
131 /** Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
132 public Shdr setSh_link(final int val) {
133 accessor.setIntAt(sh_link_offset[mdIdx], val);
134 return this;
135 }
136
137 /** Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
138 public int getSh_link() {
139 return accessor.getIntAt(sh_link_offset[mdIdx]);
140 }
141
142 /** Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
143 public Shdr setSh_info(final int val) {
144 accessor.setIntAt(sh_info_offset[mdIdx], val);
145 return this;
146 }
147
148 /** Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]] */
149 public int getSh_info() {
150 return accessor.getIntAt(sh_info_offset[mdIdx]);
151 }
152
153 /** Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
154 public Shdr setSh_addralign(final long val) {
155 accessor.setLongAt(sh_addralign_offset[mdIdx], val, md.longSizeInBytes());
156 return this;
157 }
158
159 /** Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
160 public long getSh_addralign() {
161 return accessor.getLongAt(sh_addralign_offset[mdIdx], md.longSizeInBytes());
162 }
163
164 /** Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
165 public Shdr setSh_entsize(final long val) {
166 accessor.setLongAt(sh_entsize_offset[mdIdx], val, md.longSizeInBytes());
167 return this;
168 }
169
170 /** Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8], [int]] */
171 public long getSh_entsize() {
172 return accessor.getLongAt(sh_entsize_offset[mdIdx], md.longSizeInBytes());
173 }
174
175 // --- Begin CustomJavaCode .cfg declarations
176 public static int size(final int mdIdx) {
177 return Shdr_size[mdIdx];
178 }
179
180 public static Shdr create(final int mdIdx) {
181 return create(mdIdx, Buffers.newDirectByteBuffer( size(mdIdx) ) );
182 }
183
184 public static Shdr create(final int mdIdx, final java.nio.ByteBuffer buf) {
185 return new Shdr(mdIdx, buf);
186 }
187
188 Shdr(final int mdIdx, final java.nio.ByteBuffer buf) {
189 this.mdIdx = mdIdx;
190 this.md = MachineDataInfo.StaticConfig.values()[mdIdx].md;
191 this.accessor = new StructAccessor(buf);
192 }
193 // ---- End CustomJavaCode .cfg declarations
194}
Utility methods allowing easy java.nio.Buffer manipulations.
Definition: Buffers.java:43
static ByteBuffer newDirectByteBuffer(final int size)
Allocates a new direct ByteBuffer with the specified number of elements.
Definition: Buffers.java:61
final void setLongAt(final int byteOffset, final long v)
Puts a long at the specified byteOffset.
final void setIntAt(final int byteOffset, final int v)
Puts a int at the specified byteOffset.
final ByteBuffer getBuffer()
final int getIntAt(final int byteOffset)
Retrieves the int at the specified byteOffset.
final long getLongAt(final int byteOffset)
Retrieves the long at the specified byteOffset.
Machine data description for alignment and size onle, see com.jogamp.gluegen.
int getSh_name()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:72
static int size(final int mdIdx)
Definition: Shdr.java:176
long getSh_addr()
Getter for native field: CType['ElfN_Addr' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:105
Shdr setSh_info(final int val)
Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:143
Shdr setSh_name(final int val)
Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:66
long getSh_flags()
Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:94
Shdr setSh_addralign(final long val)
Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:154
Shdr setSh_entsize(final long val)
Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:165
long getSh_entsize()
Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:171
Shdr setSh_flags(final long val)
Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:88
Shdr setSh_addr(final long val)
Setter for native field: CType['ElfN_Addr' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:99
Shdr setSh_link(final int val)
Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:132
int getSh_info()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:149
Shdr setSh_size(final long val)
Setter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:121
int getSh_link()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:138
java.nio.ByteBuffer getBuffer()
Definition: Shdr.java:61
Shdr setSh_offset(final long val)
Setter for native field: CType['ElfN_Off' (typedef), size [fixed false, lnx64 8], [int]].
Definition: Shdr.java:110
static Shdr create(final int mdIdx)
Definition: Shdr.java:180
long getSh_size()
Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:127
long getSh_addralign()
Getter for native field: CType['ElfN_size' (typedef), size [fixed false, lnx64 8],...
Definition: Shdr.java:160
int getSh_type()
Getter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:83
static Shdr create(final int mdIdx, final java.nio.ByteBuffer buf)
Definition: Shdr.java:184
long getSh_offset()
Getter for native field: CType['ElfN_Off' (typedef), size [fixed false, lnx64 8], [int]].
Definition: Shdr.java:116
Shdr setSh_type(final int val)
Setter for native field: CType['uint32_t', size [fixed true, lnx64 4], [int]].
Definition: Shdr.java:77
Static enumeration of MachineDataInfo instances used for high performance data size and alignment loo...