}
protected ELFhdr(byte[] bytes) throws BinaryParseException {
if (bytes.length <= e_ident.length) {
throw new BinaryParseException("No ELF File"); //$NON-NLS-1$
}
System.arraycopy(bytes, 0, e_ident, 0, e_ident.length);
if (e_ident[ELFhdr.EI_MAG0] != 0x7f || e_ident[ELFhdr.EI_MAG1] != 'E' || e_ident[ELFhdr.EI_MAG2] != 'L'
|| e_ident[ELFhdr.EI_MAG3] != 'F')
throw new BinaryParseException("No ELF File"); //$NON-NLS-1$
boolean isle = (e_ident[ELFhdr.EI_DATA] == ELFhdr.ELFDATA2LSB);
int offset = e_ident.length;
e_type = makeShort(bytes, offset, isle);
offset += 2;
e_machine = makeShort(bytes, offset, isle);
offset += 2;
e_version = makeInt(bytes, offset, isle);
offset += 4;
switch (e_ident[ELFhdr.EI_CLASS]) {
case ELFhdr.ELFCLASS32 : {
byte[] addrArray = new byte[ELF32_ADDR_SIZE];
System.arraycopy(bytes, offset, addrArray, 0, ELF32_ADDR_SIZE);
offset += ELF32_ADDR_SIZE;
e_entry = new Addr32(addrArray);
e_phoff = makeInt(bytes, offset, isle);
offset += ELF32_OFF_SIZE;
e_shoff = makeInt(bytes, offset, isle);
offset += ELF32_OFF_SIZE;
}
break;
case ELFhdr.ELFCLASS64 : {
byte[] addrArray = new byte[ELF64_ADDR_SIZE];
System.arraycopy(bytes, offset, addrArray, 0, ELF64_ADDR_SIZE);
offset += ELF64_ADDR_SIZE;
e_entry = new Addr64(addrArray);
e_phoff = makeUnsignedLong(bytes, offset, isle);
offset += ELF64_OFF_SIZE;
e_shoff = makeUnsignedLong(bytes, offset, isle);
offset += ELF64_OFF_SIZE;
}
break;
case ELFhdr.ELFCLASSNONE :
default :
throw new BinaryParseException("Unknown ELF class " + e_ident[ELFhdr.EI_CLASS]); //$NON-NLS-1$
}
e_flags = makeInt(bytes, offset, isle);
offset += 4;
e_ehsize = makeShort(bytes, offset, isle);
offset += 2;