From d2bada0e42e668ec65e1a853d32ac021feed4952 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 10 Nov 2023 11:18:07 -0600 Subject: [PATCH] Move linux32 command to its own file, because BSD can't build it. (It's also kind of silly: it makes uname -m produce different output. That's it. It doesn't stop you from running x86-64 binaries, it's just another way of lying to autoconf when it asks The Wrong Question yet again.) --- toys/other/linux32.c | 24 ++++++++++++++++++++++++ toys/posix/uname.c | 15 --------------- 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 toys/other/linux32.c diff --git a/toys/other/linux32.c b/toys/other/linux32.c new file mode 100644 index 00000000..3131c6d6 --- /dev/null +++ b/toys/other/linux32.c @@ -0,0 +1,24 @@ +/* linux32.c - Change uname -m output, and on some architectures /proc/cpuinfo + * + * Copyright 2023 Rob Landley + * + * No standard: it's a syscall wrapper provided by util-linux. + +USE_LINUX32(NEWTOY(linux32, 0, TOYFLAG_USR|TOYFLAG_BIN)) + +config LINUX32 + bool "linux32" + default y + help + usage: linux32 [COMMAND...] + + Tell uname -m to lie to autoconf (to build 32 bit binaries on 64 bit kernel). +*/ + +#include "toys.h" + +void linux32_main(void) +{ + personality(PER_LINUX32); + xexec(toys.optc ? toys.optargs : (char *[]){"/bin/sh", 0}); +} diff --git a/toys/posix/uname.c b/toys/posix/uname.c index d11e1e5c..ae94577b 100644 --- a/toys/posix/uname.c +++ b/toys/posix/uname.c @@ -6,7 +6,6 @@ USE_UNAME(NEWTOY(uname, "paomvrns", TOYFLAG_BIN)) USE_ARCH(NEWTOY(arch, 0, TOYFLAG_USR|TOYFLAG_BIN)) -USE_LINUX32(NEWTOY(linux32, 0, TOYFLAG_USR|TOYFLAG_BIN)) config ARCH bool "arch" @@ -16,14 +15,6 @@ config ARCH Print machine (hardware) name, same as uname -m. -config LINUX32 - bool "linux32" - default y - help - usage: linux32 [COMMAND...] - - Tell uname -m to line to autoconf (to build 32 bit binaries on 64 bit kernel). - config UNAME bool "uname" default y @@ -69,9 +60,3 @@ void arch_main(void) toys.optflags = FLAG_m; uname_main(); } - -void linux32_main(void) -{ - personality(PER_LINUX32); - xexec(toys.optc ? toys.optargs : (char *[]){"/bin/sh", 0}); -} -- 2.39.2