cosmopolitan/tool
Ivan Komarov 99f0491f04
Fix invalid XNU binaries generated by apelink in some edge cases (#1106)
* Fix `if...fi` generation in the generated APE shell script

A shell will fail with a syntax error on an empty `if` or `else` body.
That is, neither of these is allowed:

    # Empty `if`
    if [ ... ]; then
    fi

    # Empty `else`
    if [ ... ]; then
    ...
    else
    fi

There were two places where `apelink` could generate problematic `if`'s:

1. The XNU shell generation for aarch64 binaries when no loaders (either
   binary or source) are provided. They can't assimilate, so the resulting
   `else` body becomes empty.
   There is actually a code path guarded by the `gotsome` variable that
   inserts an extra `true` in this case, but the variable was never
   initialized, so in practice this code path didn't activate in my
   tests. This is fixed by initializing the variable.
2. The loader extraction code when no loaders are provided and XNU
   support is requested. This is fixed by adding a simliar code path
   that prevents an empty body from being generated.

* Update the apelink manual after commit d53c335

The `-s` option changed its meaning, but the docs weren't updated.
2024-02-23 08:11:27 -08:00
..
args Make ... optional in .args (#1086) 2024-01-15 16:20:50 -08:00
build Fix invalid XNU binaries generated by apelink in some edge cases (#1106) 2024-02-23 08:11:27 -08:00
cosmocc Make fixups for libcrypt 2024-02-23 07:39:44 -08:00
curl Support any HTTP method 2024-02-22 14:12:18 -08:00
decode Make improvements 2024-02-12 10:23:00 -08:00
emacs Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
hello Release Cosmopolitan v3.3 2024-02-20 13:27:59 -08:00
lambda more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
net Support any HTTP method 2024-02-22 14:12:18 -08:00
plinko more modeline errata (#1019) 2023-12-16 23:07:10 -05:00
scripts Fix more vi modelines (#1006) 2023-12-13 02:28:11 -05:00
viz Make improvements 2024-02-12 10:23:00 -08:00
zsh mkofs improvements 2024-01-08 17:23:09 +00:00
BUILD.mk more modeline errata (#1019) 2023-12-16 23:07:10 -05:00