private static void read()

in java/com/facebook/soloader/MinElf.java [300:318]


  private static void read(ElfByteChannel bc, ByteBuffer bb, int sz, long offset)
      throws IOException {
    bb.position(0);
    bb.limit(sz);

    while (bb.remaining() > 0) {
      int numBytesRead = bc.read(bb, offset);
      if (numBytesRead == -1) {
        break; // Reached end of channel
      }
      offset += numBytesRead;
    }

    if (bb.remaining() > 0) {
      throw new ElfError("ELF file truncated");
    }

    bb.position(0);
  }