jaulib v1.3.0
Jau Support Library (C++, Java, ..)
ElfHeaderPart1.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 static org.jau.sys.elf.IOUtils.readBytes;
29
30import java.io.IOException;
31import java.io.RandomAccessFile;
32import java.nio.ByteBuffer;
33
34import org.jau.sys.Debug;
35import org.jau.sys.MachineDataInfo;
36import org.jau.sys.PlatformTypes.ABIType;
37import org.jau.sys.PlatformTypes.CPUType;
38import org.jau.sys.PlatformTypes.OSType;
39
40/**
41 * ELF ABI Header Part-1
42 * <p>
43 * Part-1 can be read w/o knowledge of CPUType!
44 * </p>
45 * <p>
46 * References:
47 * <ul>
48 * <li>http://www.sco.com/developers/gabi/latest/contents.html</li>
49 * <li>https://en.wikipedia.org/wiki/Executable_and_Linkable_Format</li>
50 * <li>http://linux.die.net/man/5/elf</li>
51 * <li>http://infocenter.arm.com/
52 * <ul>
53 * <li>ARM IHI 0044E, current through ABI release 2.09</li>
54 * <li>ARM IHI 0056B: Elf for ARM 64-bit Architecture</li>
55 * </ul></li>
56 * </ul>
57 * </p>
58 */
59public class ElfHeaderPart1 {
60 static final boolean DEBUG = Debug.debug("Platform");
61
62 /** Size of e_ident array - {@value} */
63 public static int EI_NIDENT = 16;
64
65 /** ident byte #0 - {@value} */
66 public static final byte ELFMAG0 = 0x7f;
67 /** ident byte #1 - {@value} */
68 public static final byte ELFMAG1 = 'E';
69 /** ident byte #2 - {@value} */
70 public static final byte ELFMAG2 = 'L';
71 /** ident byte #3 - {@value} */
72 public static final byte ELFMAG3 = 'F';
73
74 /** ident byte #4 */
75 public static final int EI_CLASS = 4;
76 public static final byte ELFCLASSNONE = 0;
77 public static final byte ELFCLASS32 = 1;
78 public static final byte ELFCLASS64 = 2;
79
80 /** ident byte #5 */
81 public static final int EI_DATA = 5;
82 public static final byte ELFDATANONE = 0;
83 public static final byte ELFDATA2LSB = 1;
84 public static final byte ELFDATA2MSB = 2;
85
86 /** ident byte #6 */
87 public static final int EI_VERSION = 6;
88 public static final byte EV_NONE = 0;
89 public static final byte EV_CURRENT = 1;
90
91 /** ident byte #7 */
92 public static final int EI_OSABI = 7;
93 /** Unix System V ABI - {@value} */
94 public static final byte ELFOSABI_SYSV = 0;
95 public static final byte ELFOSABI_NONE = ELFOSABI_SYSV;
96 /** HP-UX ABI - {@value} */
97 public static final byte ELFOSABI_HPUX = 1;
98 /** NetBSD ABI - {@value} **/
99 public static final byte ELFOSABI_NETBSD = 2;
100 /** Linux ABI - {@value} **/
101 public static final byte ELFOSABI_LINUX = 3;
102 /** Solaris ABI - {@value} **/
103 public static final byte ELFOSABI_SOLARIS = 6;
104 /** IRIX ABI - {@value} **/
105 public static final byte ELFOSABI_IRIX = 7;
106 /** FreeBSD ABI - {@value} **/
107 public static final byte ELFOSABI_FREEBSD = 8;
108 /** ARM architecture ABI - {@value} **/
109 public static final byte ELFOSABI_ARM = 8; // FIXME
110 /** Stand-alone (embedded) ABI - {@value} **/
111 public static final byte ELFOSABI_STANDALONE = 9; // FIXME
112 /** TRU64 UNIX ABI - {@value} **/
113 public static final byte ELFOSABI_TRU64 = 10;
114 /** Novell Modesto ABI - {@value} **/
115 public static final byte ELFOSABI_MODESTO = 11;
116 /** Open BSD ABI - {@value} **/
117 public static final byte ELFOSABI_OPENBSD = 12;
118 /** Open VMS ABI - {@value} **/
119 public static final byte ELFOSABI_OPENVMS = 13;
120 /** Hewlett-Packard Non-Stop Kernel ABI - {@value} **/
121 public static final byte ELFOSABI_NSK = 14;
122 /** Amiga Research OS ABI - {@value} **/
123 public static final byte ELFOSABI_AROS = 15;
124 /** The FenixOS highly scalable multi-core OS 64-255 Architecture-specific value range - {@value} */
125 public static final byte ELFOSABI_FENIXOS = 16;
126
127 /** ident byte #8
128 * <p>
129 * This byte identifies the version of the ABI to which the object is targeted.
130 * This field is used to distinguish among incompatible versions of an ABI.
131 * The interpretation of this version number is dependent on the ABI identified by the EI_OSABI field.
132 * Applications conforming to this specification use the value 0.
133 * </p>
134 */
135 public static final int EI_ABIVERSION = 8;
136
137 /**
138 * ident byte #9 .. ?
139 * <p>
140 * Start of padding.
141 * These bytes are reserved and set to zero.
142 * Programs which read them should ignore them.
143 * The value for EI_PAD will change in the future if currently unused bytes are given meanings.
144 * </p>
145 */
146 public static final int EI_PAD = 9;
147
148 /** An unknown type - {@value} */
149 public static final short ET_NONE = 0;
150 /** A relocatable file - {@value} */
151 public static final short ET_REL = 1;
152 /** An executable file - {@value} */
153 public static final short ET_EXEC = 2;
154 /** A shared object - {@value} */
155 public static final short ET_DYN = 3;
156 /** A core file - {@value} */
157 public static final short ET_CORE = 4;
158
159 public static final short EM_NONE = 0;
160 public static final short EM_M32 = 1;
161 public static final short EM_SPARC = 2;
162 public static final short EM_386 = 3;
163 public static final short EM_68K = 4;
164 public static final short EM_88K = 5;
165 public static final short EM_486 = 6;
166 public static final short EM_860 = 7;
167 public static final short EM_MIPS = 8;
168 public static final short EM_S370 = 9;
169 public static final short EM_MIPS_RS3_LE = 10;
170 public static final short EM_PARISC = 15;
171 public static final short EM_res016 = 16;
172 public static final short EM_VPP550 = 17;
173 public static final short EM_SPARC32PLUS = 18;
174 public static final short EM_960 = 19;
175 public static final short EM_PPC = 20;
176 public static final short EM_PPC64 = 21;
177 public static final short EM_S390 = 22;
178 public static final short EM_SPU = 23;
179 public static final short EM_V800 = 36;
180 public static final short EM_FR20 = 37;
181 public static final short EM_RH32 = 38;
182 public static final short EM_MCORE = 39;
183 public static final short EM_RCE = 39;
184 public static final short EM_ARM = 40;
185 public static final short EM_OLD_ALPHA = 41;
186 public static final short EM_SH = 42;
187 public static final short EM_SPARCV9 = 43;
188 public static final short EM_TRICORE = 44;
189 public static final short EM_ARC = 45;
190 public static final short EM_H8_300 = 46;
191 public static final short EM_H8_300H = 47;
192 public static final short EM_H8S = 48;
193 public static final short EM_H8_500 = 49;
194 public static final short EM_IA_64 = 50;
195 public static final short EM_MIPS_X = 51;
196 public static final short EM_COLDFIRE = 52;
197 public static final short EM_68HC12 = 53;
198 public static final short EM_MMA = 54;
199 public static final short EM_PCP = 55;
200 public static final short EM_NCPU = 56;
201 public static final short EM_NDR1 = 57;
202 public static final short EM_STARCORE = 58;
203 public static final short EM_ME16 = 59;
204 public static final short EM_ST100 = 60;
205 public static final short EM_TINYJ = 61;
206 public static final short EM_X86_64 = 62;
207 public static final short EM_PDSP = 63;
208 public static final short EM_PDP10 = 64;
209 public static final short EM_PDP11 = 65;
210 public static final short EM_FX66 = 66;
211 public static final short EM_ST9PLUS = 67;
212 public static final short EM_ST7 = 68;
213 public static final short EM_68HC16 = 69;
214 public static final short EM_68HC11 = 70;
215 public static final short EM_68HC08 = 71;
216 public static final short EM_68HC05 = 72;
217 public static final short EM_SVX = 73;
218 public static final short EM_ST19 = 74;
219 public static final short EM_VAX = 75;
220 public static final short EM_CRIS = 76;
221 public static final short EM_JAVELIN = 77;
222 public static final short EM_FIREPATH = 78;
223 public static final short EM_ZSP = 79;
224 public static final short EM_MMIX = 80;
225 public static final short EM_HUANY = 81;
226 public static final short EM_PRISM = 82;
227 public static final short EM_AVR = 83;
228 public static final short EM_FR30 = 84;
229 public static final short EM_D10V = 85;
230 public static final short EM_D30V = 86;
231 public static final short EM_V850 = 87;
232 public static final short EM_M32R = 88;
233 public static final short EM_MN10300 = 89;
234 public static final short EM_MN10200 = 90;
235 public static final short EM_PJ = 91;
236 public static final short EM_OPENRISC = 92;
237 public static final short EM_ARC_A5 = 93;
238 public static final short EM_XTENSA = 94;
239 public static final short EM_VIDEOCORE = 95;
240 public static final short EM_TMM_GPP = 96;
241 public static final short EM_NS32K = 97;
242 public static final short EM_TPC = 98;
243 public static final short EM_SNP1K = 99;
244 public static final short EM_ST200 = 100;
245 public static final short EM_IP2K = 101;
246 public static final short EM_MAX = 102;
247 public static final short EM_CR = 103;
248 public static final short EM_F2MC16 = 104;
249 public static final short EM_MSP430 = 105;
250 public static final short EM_BLACKFIN = 106;
251 public static final short EM_SE_C33 = 107;
252 public static final short EM_SEP = 108;
253 public static final short EM_ARCA = 109;
254 public static final short EM_UNICORE = 110;
255 public static final short EM_EXCESS = 111;
256 public static final short EM_DXP = 112;
257 public static final short EM_ALTERA_NIOS2 = 113;
258 public static final short EM_CRX = 114;
259 public static final short EM_XGATE = 115;
260 public static final short EM_C166 = 116;
261 public static final short EM_M16C = 117;
262 public static final short EM_DSPIC30F = 118;
263 public static final short EM_CE = 119;
264 public static final short EM_M32C = 120;
265 public static final short EM_TSK3000 = 131;
266 public static final short EM_RS08 = 132;
267 public static final short EM_res133 = 133;
268 public static final short EM_ECOG2 = 134;
269 public static final short EM_SCORE = 135;
270 public static final short EM_SCORE7 = 135;
271 public static final short EM_DSP24 = 136;
272 public static final short EM_VIDEOCORE3 = 137;
273 public static final short EM_LATTICEMICO32 = 138;
274 public static final short EM_SE_C17 = 139;
275 public static final short EM_TI_C6000 = 140;
276 public static final short EM_TI_C2000 = 141;
277 public static final short EM_TI_C5500 = 142;
278 public static final short EM_MMDSP_PLUS = 160;
279 public static final short EM_CYPRESS_M8C = 161;
280 public static final short EM_R32C = 162;
281 public static final short EM_TRIMEDIA = 163;
282 public static final short EM_QDSP6 = 164;
283 public static final short EM_8051 = 165;
284 public static final short EM_STXP7X = 166;
285 public static final short EM_NDS32 = 167;
286 public static final short EM_ECOG1 = 168;
287 public static final short EM_ECOG1X = 168;
288 public static final short EM_MAXQ30 = 169;
289 public static final short EM_XIMO16 = 170;
290 public static final short EM_MANIK = 171;
291 public static final short EM_CRAYNV2 = 172;
292 public static final short EM_RX = 173;
293 public static final short EM_METAG = 174;
294 public static final short EM_MCST_ELBRUS = 175;
295 public static final short EM_ECOG16 = 176;
296 public static final short EM_CR16 = 177;
297 public static final short EM_ETPU = 178;
298 public static final short EM_SLE9X = 179;
299 public static final short EM_L1OM = 180;
300 public static final short EM_INTEL181 = 181;
301 public static final short EM_INTEL182 = 182;
302 public static final short EM_AARCH64 = 183;
303 public static final short EM_ARM184 = 184;
304 public static final short EM_AVR32 = 185;
305 public static final short EM_STM8 = 186;
306 public static final short EM_TILE64 = 187;
307 public static final short EM_TILEPRO = 188;
308 public static final short EM_MICROBLAZE = 189;
309 public static final short EM_CUDA = 190;
310
311 public static final boolean isIdentityValid(final byte[] ident) {
312 return ELFMAG0 == ident[0] &&
313 ELFMAG1 == ident[1] &&
314 ELFMAG2 == ident[2] &&
315 ELFMAG3 == ident[3] ;
316 }
317
318 /** Public access to the raw elf header part-1 (CPU/ABI independent read) */
319 public final Ehdr_p1 raw;
320 private final byte[] E_ident;
321
322 /** Lower case CPUType name */
323 public final String cpuName;
324 public final CPUType cpuType;
325 public final ABIType abiType;
326
327 public final MachineDataInfo.StaticConfig machDesc;
328
329 /**
330 * Note: The input stream shall stay untouch to be able to read sections!
331 * @param osType TODO
332 * @param in input stream of a binary file at position zero
333 *
334 * @return
335 * @throws IOException if reading from the given input stream fails or less then ELF Header size bytes
336 * @throws IllegalArgumentException if the given input stream does not represent an ELF Header
337 */
338 public static ElfHeaderPart1 read(final OSType osType, final RandomAccessFile in) throws IOException, IllegalArgumentException {
339 return new ElfHeaderPart1(osType, in);
340 }
341
342 /**
343 * @param osType TODO
344 * @param buf ELF Header bytes
345 * @throws IllegalArgumentException if the given buffer does not represent an ELF Header
346 * @throws IOException
347 */
348 ElfHeaderPart1(final OSType osType, final RandomAccessFile in) throws IllegalArgumentException, IOException {
349 {
350 final byte[] buf = new byte[Ehdr_p1.size()];
351 readBytes (in, buf, 0, buf.length);
352 final ByteBuffer eh1Bytes = ByteBuffer.wrap(buf, 0, buf.length);
353 raw = Ehdr_p1.create(eh1Bytes);
354 }
355 E_ident = raw.getE_ident(0, new byte[Ehdr_p1.getE_identArrayLength()]);
356 if( !isIdentityValid(E_ident) ) {
357 throw new IllegalArgumentException("Buffer is not an ELF Header");
358 }
359
360 final short machine = getMachine();
361 switch ( machine ) {
362 case EM_ARM:
363 // ARM 32bit will be refine in ElfHeaderPart2
364 cpuName = "arm"; // lowest 32bit denominator, ok for now
365 cpuType = CPUType.ARM;
366 abiType = ABIType.GENERIC_ABI;
367 break;
368 case EM_AARCH64:
369 cpuName = "aarch64";
370 cpuType = CPUType.ARM64;
371 abiType = ABIType.EABI_AARCH64;
372 break;
373 case EM_X86_64:
374 cpuName = "x86_64";
375 cpuType = CPUType.X86_64;
376 abiType = ABIType.GENERIC_ABI;
377 break;
378 case EM_386:
379 cpuName = "i386";
380 cpuType = CPUType.X86_32;
381 abiType = ABIType.GENERIC_ABI;
382 break;
383 case EM_486:
384 cpuName = "i486";
385 cpuType = CPUType.X86_32;
386 abiType = ABIType.GENERIC_ABI;
387 break;
388 case EM_IA_64:
389 cpuName = "ia64";
390 cpuType = CPUType.IA64;
391 abiType = ABIType.GENERIC_ABI;
392 break;
393 case EM_MIPS:
394 // Can be little-endian or big-endian and 32 or 64 bits
395 if( 64 == getArchClassBits() ) {
396 cpuName = isLittleEndian() ? "mips64le" : "mips64";
397 cpuType = CPUType.MIPS_64;
398 } else {
399 cpuName = isLittleEndian() ? "mipsle" : "mips";
400 cpuType = CPUType.MIPS_32;
401 }
402 abiType = ABIType.GENERIC_ABI;
403 break;
404 case EM_MIPS_RS3_LE:
405 cpuName = "mipsle-rs3"; // FIXME: Only little-endian?
406 cpuType = CPUType.MIPS_32;
407 abiType = ABIType.GENERIC_ABI;
408 break;
409 case EM_MIPS_X:
410 cpuName = isLittleEndian() ? "mipsle-x" : "mips-x"; // Can be little-endian
411 cpuType = CPUType.MIPS_32;
412 abiType = ABIType.GENERIC_ABI;
413 break;
414 case EM_PPC:
415 cpuName = "ppc";
416 cpuType = CPUType.PPC;
417 abiType = ABIType.GENERIC_ABI;
418 break;
419 case EM_PPC64:
420 cpuName = "ppc64";
421 cpuType = CPUType.PPC64;
422 abiType = ABIType.GENERIC_ABI;
423 break;
424 case EM_SH:
425 cpuName = "superh";
426 cpuType = CPUType.SuperH;
427 abiType = ABIType.GENERIC_ABI;
428 break;
429 default:
430 throw new IllegalArgumentException("CPUType and ABIType could not be determined");
431 }
432 machDesc = MachineDataInfo.guessStaticMachineDataInfo(osType, cpuType);
433 if(DEBUG) {
434 System.err.println("ELF-1: cpuName "+cpuName+" -> "+cpuType+", "+abiType +", machDesc "+machDesc.toShortString() );
435 }
436 }
437
438 /**
439 * Returns the architecture class in bits,
440 * 32 for {@link #ELFCLASS32}, 64 for {@link #ELFCLASS64}
441 * and 0 for {@link #ELFCLASSNONE}.
442 */
443 public final int getArchClassBits() {
444 switch( E_ident[EI_CLASS] ) {
445 case ELFCLASS32: return 32;
446 case ELFCLASS64: return 64;
447 default: return 0;
448 }
449 }
450
451 /**
452 * Returns the processor's data encoding, i.e.
453 * {@link #ELFDATA2LSB}, {@link #ELFDATA2MSB} or {@link #ELFDATANONE};
454 */
455 public final byte getDataEncodingMode() {
456 return E_ident[EI_DATA];
457 }
458
459 /**
460 * Returns whether the processor's {@link #getDataEncodingMode() data encoding} is {@link #ELFDATA2LSB}.
461 */
462 public final boolean isLittleEndian() { return ELFDATA2LSB == E_ident[EI_DATA]; }
463 /**
464 * Returns whether the processor's {@link #getDataEncodingMode() data encoding} is {@link #ELFDATA2MSB}.
465 */
466 public final boolean isBigEndian() { return ELFDATA2MSB == E_ident[EI_DATA]; }
467 /**
468 * Returns whether the processor's {@link #getDataEncodingMode() data encoding} is {@link #ELFDATANONE}.
469 */
470 public final boolean isNoneEndian() { return ELFDATANONE == E_ident[EI_DATA]; }
471
472 /** Returns the ELF file version, should be {@link #EV_CURRENT}. */
473 public final byte getVersion() {
474 return E_ident[EI_VERSION];
475 }
476
477 /** Returns the operating system and ABI for this file, 3 == Linux. Note: Often not used. */
478 public final byte getOSABI() {
479 return E_ident[EI_OSABI];
480 }
481
482 /** Returns the version of the {@link #getOSABI() OSABI} for this file. */
483 public final byte getOSABIVersion() {
484 return E_ident[EI_ABIVERSION];
485 }
486
487 /** Returns the object file type, e.g. {@link #ET_EXEC}, .. */
488 public final short getType() {
489 return raw.getE_type();
490 }
491
492 /** Returns the required architecture for the file, e.g. {@link #EM_386}, .. */
493 public final short getMachine() {
494 return raw.getE_machine();
495 }
496
497 @Override
498 public final String toString() {
499 final int enc = getDataEncodingMode();
500 final String encS;
501 switch(enc) {
502 case ELFDATA2LSB: encS = "LSB"; break;
503 case ELFDATA2MSB: encS = "MSB"; break;
504 default: encS = "NON"; break; /* ELFDATANONE */
505 }
506 final int type = getType();
507 final String typeS;
508 switch(type) {
509 case ET_REL: typeS = "reloc"; break;
510 case ET_EXEC: typeS = "exec"; break;
511 case ET_DYN: typeS = "shared"; break;
512 case ET_CORE: typeS = "core"; break;
513 default: typeS = "none"; break; /* ET_NONE */
514 }
515 return "ELF-1[vers "+getVersion()+", machine["+getMachine()+", "+cpuType+", "+abiType+", machDesc "+machDesc.toShortString()+"], bits "+getArchClassBits()+", enc "+encS+
516 ", abi[os "+getOSABI()+", vers "+getOSABIVersion()+"], type "+typeS+"]";
517 }
518}
Helper routines for logging and debugging.
Definition: Debug.java:35
static final boolean debug(final String subcomponent)
Definition: Debug.java:63
static StaticConfig guessStaticMachineDataInfo(final PlatformTypes.OSType osType, final PlatformTypes.CPUType cpuType)
ByteBuffer getE_ident()
Getter for native field: CType['char *', size [fixed false, lnx64 16], [array*1]],...
Definition: Ehdr_p1.java:93
static Ehdr_p1 create()
Definition: Ehdr_p1.java:54
short getE_type()
Getter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]].
Definition: Ehdr_p1.java:112
static int size()
Definition: Ehdr_p1.java:50
short getE_machine()
Getter for native field: CType['uint16_t', size [fixed true, lnx64 2], [int]].
Definition: Ehdr_p1.java:123
static final int EI_DATA
ident byte #5
static final byte ELFOSABI_TRU64
TRU64 UNIX ABI - {@value}.
static final byte ELFOSABI_HPUX
HP-UX ABI - {@value}.
static final byte ELFOSABI_AROS
Amiga Research OS ABI - {@value}.
final boolean isLittleEndian()
Returns whether the processor's data encoding is ELFDATA2LSB.
static final byte ELFOSABI_NETBSD
NetBSD ABI - {@value}.
final int getArchClassBits()
Returns the architecture class in bits, 32 for ELFCLASS32, 64 for ELFCLASS64 and 0 for ELFCLASSNONE.
final byte getOSABIVersion()
Returns the version of the OSABI for this file.
static final short EM_LATTICEMICO32
static final byte ELFMAG0
ident byte #0 - {@value}
static ElfHeaderPart1 read(final OSType osType, final RandomAccessFile in)
Note: The input stream shall stay untouch to be able to read sections!
static int EI_NIDENT
Size of e_ident array - {@value}.
static final byte ELFMAG3
ident byte #3 - {@value}
final boolean isNoneEndian()
Returns whether the processor's data encoding is ELFDATANONE.
static final short ET_EXEC
An executable file - {@value}.
static final byte ELFMAG2
ident byte #2 - {@value}
static final int EI_ABIVERSION
ident byte #8
static final int EI_CLASS
ident byte #4
final MachineDataInfo.StaticConfig machDesc
static final short ET_DYN
A shared object - {@value}.
final byte getOSABI()
Returns the operating system and ABI for this file, 3 == Linux.
static final byte ELFOSABI_FREEBSD
FreeBSD ABI - {@value}.
static final byte ELFOSABI_STANDALONE
Stand-alone (embedded) ABI - {@value}.
static final byte ELFOSABI_ARM
ARM architecture ABI - {@value}.
static final int EI_PAD
ident byte #9 .
static final short ET_CORE
A core file - {@value}.
static final short ET_NONE
An unknown type - {@value}.
static final byte ELFOSABI_MODESTO
Novell Modesto ABI - {@value}.
static final short ET_REL
A relocatable file - {@value}.
final short getType()
Returns the object file type, e.g.
static final byte ELFOSABI_OPENVMS
Open VMS ABI - {@value}.
final String cpuName
Lower case CPUType name.
static final byte ELFOSABI_LINUX
Linux ABI - {@value}.
static final byte ELFOSABI_IRIX
IRIX ABI - {@value}.
static final boolean isIdentityValid(final byte[] ident)
static final int EI_OSABI
ident byte #7
static final byte ELFOSABI_FENIXOS
The FenixOS highly scalable multi-core OS 64-255 Architecture-specific value range - {@value}.
static final short EM_ALTERA_NIOS2
static final byte ELFOSABI_SYSV
Unix System V ABI - {@value}.
static final byte ELFMAG1
ident byte #1 - {@value}
static final byte ELFOSABI_OPENBSD
Open BSD ABI - {@value}.
final byte getVersion()
Returns the ELF file version, should be EV_CURRENT.
final byte getDataEncodingMode()
Returns the processor's data encoding, i.e.
static final byte ELFOSABI_NSK
Hewlett-Packard Non-Stop Kernel ABI - {@value}.
static final byte ELFOSABI_SOLARIS
Solaris ABI - {@value}.
final Ehdr_p1 raw
Public access to the raw elf header part-1 (CPU/ABI independent read)
static final int EI_VERSION
ident byte #6
final short getMachine()
Returns the required architecture for the file, e.g.
final boolean isBigEndian()
Returns whether the processor's data encoding is ELFDATA2MSB.
EABI_AARCH64
ARM EABI AARCH64 (64bit)
X86_32
X86 32bit, little endian.
SuperH
Hitachi SuperH 32bit default, ??? endian.
IA64
Itanium 64bit default, little endian.
MIPS_64
MIPS 64bit, big endian (mips64) or little endian (mipsel64) ?
PPC64
PPC 64bit default, usually big endian.
X86_64
X86 64bit, little endian.
ARM64
ARM64 default (64bit), usually little endian.
ARM
ARM 32bit default, usually little endian.
MIPS_32
MIPS 32bit, big endian (mips) or little endian (mipsel)
PPC
PPC 32bit default, usually big endian.