Skip to content

Instantly share code, notes, and snippets.

@a0u
a0u / riscv-chroot.md
Last active February 2, 2021 20:49
Transparent RISC-V user-mode emulation on Linux

This demonstrates how to run RISC-V Linux executables transparently on an x86 host using a combination of binfmt_misc and QEMU.

QEMU

Build statically-linked QEMU for user-mode emulation. Some distros (e.g., Debian) provide a precompiled qemu-user-static

From 08f58eb644409096697e476f7302a43c19e34eeb Mon Sep 17 00:00:00 2001
From: Albert Ou <aou@eecs.berkeley.edu>
Date: Sun, 13 Oct 2019 14:40:50 -0700
Subject: [PATCH 1/2] Fix prerequisites for shared library creation
---
Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
@a0u
a0u / vmhwm
Created February 28, 2019 20:15
Report peak RSS of command and descendant processes on Linux
#!/bin/bash
# \brief Report peak RSS of command and descendant processes on Linux
# \author Albert Ou <aou@eecs.berkeley.edu>
# \note Monitoring of children is limited to the same session group
# as the command. proc(5) must be mounted.
#
# SPDX-License-Identifier: BSD-3-Clause
#
set -e
@a0u
a0u / ptywrap.c
Created September 6, 2015 01:05
Wrapper for redirecting stdin/stdout of a shell command to a pseudo-terminal
/*
* \brief Wrapper for redirecting stdin/stdout to a pseudo-terminal
* \author Albert Ou <aou@eecs.berkeley.edu>
* \copyright BSD 2-Clause License
*/
#define _XOPEN_SOURCE (600)
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>