result<uint64_t> Binary::offset_to_virtual_address(uint64_t offset, uint64_t slide) const {
  const SegmentCommand* segment = segment_from_offset(offset);
  if (segment == nullptr) {
    return offset + slide;
  }
  const uint64_t base_address = segment->virtual_address() - segment->file_offset();
  if (slide > 0) {
    const uint64_t base = imagebase();
    if (base == 0) {
      return slide + offset;
    }
    return (base_address - base) + offset + slide;
  }
  return base_address + offset;
}
result<uint64_t> Binary::offset_to_virtual_address(uint64_t offset, uint64_t slide) const {
  const SegmentCommand* segment = segment_from_offset(offset);
  if (segment == nullptr) {
    return offset + slide;
  }
  const uint64_t base_address = segment->virtual_address() - segment->file_offset();
  if (slide > 0) {
    const uint64_t base = imagebase();
    if (base == 0) {
      return slide + offset;
    }
    return (base_address - base) + offset + slide;
  }
  return base_address + offset;
}