import mmap


def rm(addr, nbytes):
  """Read memory at the given addr as a string.

  Args:
    addr: The address to read at.
    nbytes: The number of bytes to read.

  Returns:
    The string that was read.
  """
  with open('/dev/mem', 'r+b') as mem:
    offset = addr & 0xfff
    mem_map = mmap.mmap(mem.fileno(), nbytes + offset, offset=addr & ~0xfff)
    return mem_map[offset:offset + nbytes]