private static boolean readArmAttributes(RandomAccessFile in, ElfData elf) throws IOException { byte[] bytes = new byte[elf.sh_size]; in.seek(elf.sh_offset); in.readFully(bytes); // wrap bytes in a ByteBuffer to force endianess ByteBuffer buffer = ByteBuffer.wrap(bytes); buffer.order(elf.order); // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0045d/IHI0045D_ABI_addenda.pdf if (buffer.get() != 'A') // format-version return false; // sub-sections loop while (buffer.remaining() > 0) { int start_section = buffer.position(); int length = buffer.getInt(); String vendor = getString(buffer); if (vendor.equals("aeabi")) { // tags loop while (buffer.position() < start_section + length) { int start = buffer.position(); int tag = buffer.get(); int size = buffer.getInt(); // skip if not Tag_File, we don't care about others if (tag != 1) { buffer.position(start + size); continue; } // attributes loop while (buffer.position() < start + size) { tag = getUleb128(buffer); if (tag == 6) { // CPU_arch int arch = getUleb128(buffer); elf.att_arch = CPU_archs[arch]; } else if (tag == 27) { // ABI_HardFP_use getUleb128(buffer); elf.att_fpu = true; } else { // string for 4=CPU_raw_name / 5=CPU_name / 32=compatibility // string for >32 && odd tags // uleb128 for other tag %= 128; if (tag == 4 || tag == 5 || tag == 32 || (tag > 32 && (tag & 1) != 0)) getString(buffer); else getUleb128(buffer); } } } break; } } return true; }