@Override public RTLNumber readMemoryLocation(RTLMemoryLocation m) throws IOException { if (!(m.getAddress() instanceof RTLNumber)) return null; AbsoluteAddress va = new AbsoluteAddress((RTLNumber) m.getAddress()); long fp = getFilePointer(va); if (getSectionNumber(fp) >= 0) { assert m.getBitWidth() % 8 == 0 : "Non-byte-aligned memory reference!"; long val = 0; int bytes = m.getBitWidth() / 8; // OR together the least significant bytes inBuf.seek(fp); for (int i = 0; i < bytes - 1; i++) { val = val | ((long) inBuf.readBYTE()) << (i * 8); } // do not mask the MSB with 0xFF, so we get sign extension for free val = val | (((long) inBuf.readINT8()) << (bytes - 1) * 8); // logger.debug("Read constant value " + val + " from address " + m + " (file offset: " + // Long.toHexString(fp) + ") in image."); return ExpressionFactory.createNumber(val, m.getBitWidth()); } logger.debug("No value can be read from image for address " + m); return null; }
@Override public AbsoluteAddress getMaxAddress() { return new AbsoluteAddress(baseAddress.getValue() + inBuf.getSize()); }
@Override public byte[] getByteArray() { return inBuf.getByteArray(); }