Skip to content

Instantly share code, notes, and snippets.

@enh
enh / readelf.c-patch.txt
Created November 2, 2024 16:36
file(1) support for Android ELF notes
diff --git a/src/readelf.c b/src/readelf.c
index a79906f5..6fd877ec 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -686,6 +686,27 @@ do_os_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
return -1;
return 1;
}
+
+ if (NAMEEQUALS(name, "Android") && type == 1 && descsz >= 4) {
@enh
enh / one.s
Created December 13, 2023 04:13
2023 adventofcode.com (arm64 assembler)
// https://adventofcode.com/2023/day/1
// as -o one.o one.s && ld -o one one.o
// echo -e "1abc2\npqr3stu8vwx\na1b2c3d4e5f\ntreb7uchet\n" | ./one
.equ __NR_read, 63
.equ __NR_write, 64
.equ __NR_exit_group, 94
diff --git a/toys/other/i2ctools.c b/toys/other/i2ctools.c
index ad296adf..95280988 100644
--- a/toys/other/i2ctools.c
+++ b/toys/other/i2ctools.c
@@ -17,6 +17,7 @@ USE_I2CDETECT(NEWTOY(i2cdetect, ">3aFlqry[!qr]", TOYFLAG_USR|TOYFLAG_SBIN))
USE_I2CDUMP(NEWTOY(i2cdump, "<2>2fy", TOYFLAG_USR|TOYFLAG_SBIN))
USE_I2CGET(NEWTOY(i2cget, "<2>3fy", TOYFLAG_USR|TOYFLAG_SBIN))
USE_I2CSET(NEWTOY(i2cset, "<4fy", TOYFLAG_USR|TOYFLAG_SBIN))
+USE_I2CTRANSFER(NEWTOY(i2ctransfer, "<2vfy", TOYFLAG_USR|TOYFLAG_SBIN))
@enh
enh / gpiod.c
Created February 22, 2022 01:08
Initial toybox gpiod implementation.
/* gpiod.c - gpio tools
*
* Copyright 2021 The Android Open Source Project
*
* TODO: gpiomon
USE_GPIODETECT(NEWTOY(gpiodetect, ">0", TOYFLAG_USR|TOYFLAG_BIN))
USE_GPIOFIND(NEWTOY(gpioinfo, "", TOYFLAG_USR|TOYFLAG_BIN))
USE_GPIOGET(NEWTOY(gpioget, "<2l", TOYFLAG_USR|TOYFLAG_BIN))
USE_GPIOINFO(NEWTOY(gpiofind, "<1>1", TOYFLAG_USR|TOYFLAG_BIN))
@enh
enh / rdrand.c
Created November 2, 2019 05:02
Show RDRAND results.
// cc -mrdrnd rdrand.c -o rdrand && ./rdrand | head
#include <stdio.h>
void main() {
while (1) {
unsigned long long v;
int i = __builtin_ia32_rdrand64_step(&v);
printf("%d %#8llx\n", i, v);
}
@enh
enh / .bashrc
Created October 26, 2019 17:08
Sensible default prompt (but nothing else).
PS1="\[\e[1;33m\]\w\$\[\e[0m\] "
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
@enh
enh / .inputrc
Created October 26, 2019 16:39
A sensible default .inputrc.
$if Bash
set show-all-if-ambiguous on
# History search.
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
@enh
enh / build-package.sh
Created June 14, 2017 00:37
ndkports
#!/bin/bash
set -eu
package_name=$1
if [ "$package_name" == "all" ]; then
for p in `ls ports`; do
echo "-----------------------------------"
echo "$p"
echo "-----------------------------------"
@enh
enh / build-boost-for-android.sh
Last active July 19, 2023 00:19
Shell script to build boost for Android
#!/bin/bash
version=1.68.0
echo "Building boost $version..."
set -eu
toolchain=$PWD/toolchain
if [ ! -d "$toolchain" ]; then
echo "Building toolchain..."