Write tests for new APE loader and fix bugs

- Add FreeBSD-specific mmap() flags
- Reduce size of the APE loader from 8kb to 4kb
- Work towards fixing the Makefile build on WSL
- Automate testing of APE no-modify-self behaviors
- Make the ape.S shell script code cleaner and tinier
- Improve the APE sanity check to test behavior better
- Fixed issue with ShowCrashReports() sigaltstack() on BSDs
- Delete symbols for S_MODE magnums which wasted compile time

If you checked out yesterday's APE commit, please run:

    rm -f /usr/bin/ape o/tmp/ape /tmp/ape "${TMPDIR:-/tmp}/ape"

Because this change fixes certain aspects of the new ABI. We don't have
automated migrations for APE loader versions yet. Thanks! You can also
download prebuilt binaries here:

- https://justine.lol/ape.elf    (Linux/FreeBSD/NetBSD/OpenBSD)
- https://justine.lol/ape.macho  (Apple)

Install the appropriate one as `/usr/bin/ape`.
This commit is contained in:
Justine Tunney 2022-05-22 04:51:02 -07:00
parent 056dc5f554
commit 4e9662cbc7
75 changed files with 759 additions and 443 deletions

Binary file not shown.

BIN
build/bootstrap/ape.elf Executable file

Binary file not shown.

BIN
build/bootstrap/apetest.com Executable file

Binary file not shown.

View file

@ -27,28 +27,38 @@ EOF
exit 1
fi
build/sanitycheck2
if [ $? -ne 123 ]; then
if [ ! -f /proc/sys/fs/binfmt_misc/status ]; then
exit 0
fi
STATUS="$(build/bootstrap/apetest.com)"
if [ x"$STATUS" != xsuccess ]; then
cat <<'EOF' >&2
ERROR
Thompson Shell Backwards Compatibility Issue Detected
APE Execution error.
DETAILS
Your system has likely been configured to use binfmt_misc and wine.
You need to run the command below which will install a /usr/bin/ape
program and then register it with binfmt_misc. See ape/loader.c for
source code and technical details.
Your system has probably been configured to use binfmt_misc. You need
to run the command below to install /usr/bin/ape and register it with
binfmt_misc. See ape/loader.c for source code, and technical details.
WORKAROUND
ape/apeinstall.sh
NOTES
If it still doesn't work, possibly due to an overly aggressive WINE
or WSL registration, or possibly due to the ordering of definitions,
then one troubleshooting step is to just unregister everything using
sudo sh -c 'echo -1 >/proc/sys/fs/binfmt_misc/status' and try again.
SEE ALSO
https://justine.storage.googleapis.com/ape.html
https://justine.lol/ape.html
EOF
kill $1

View file

@ -1,16 +0,0 @@
MZboop=123
exit $MZboop