cosmopolitan/tool/build
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
..
dso Support 40 cosmo_dlopen() function parameters 2024-01-04 13:41:26 -08:00
lib Bring back gc() function 2024-01-08 10:26:28 -08:00
apelink.c Fix invalid XNU binaries generated by apelink in some edge cases (#1106) 2024-02-23 08:11:27 -08:00
ar.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
assimilate.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
bigmul.c Bring back gc() function 2024-01-08 10:26:28 -08:00
BUILD.mk Support 40 cosmo_dlopen() function parameters 2024-01-04 13:41:26 -08:00
chmod.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
cocmd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
compile.c Make improvements 2024-02-12 10:23:00 -08:00
cp.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
dd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
dlopen_test.c Support 40 cosmo_dlopen() function parameters 2024-01-04 13:41:26 -08:00
dropcache.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
echo.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
elf2pe.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
elf2pe.h Introduce new linker for fat ape binaries 2023-08-11 04:39:19 -07:00
false.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
fastdiff.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
findape.c Make improvements 2024-02-12 10:23:00 -08:00
findelf.c Make improvements 2024-02-12 10:23:00 -08:00
findpe.c Make improvements 2024-02-12 10:23:00 -08:00
fixupobj.c Fix fixupobj regression on MacOS ARM64 2024-02-21 12:13:54 -08:00
freebsd2sysv.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
gzip.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
helpop.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
killall.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
lz4toasm.c Bring back gc() function 2024-01-08 10:26:28 -08:00
march-native.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
mkdeps.c Make improvements 2024-02-12 10:23:00 -08:00
mkdir.c Remove some dead code 2023-07-03 02:48:29 -07:00
mktemper.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
mv.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
nproc.c Cull the examples folder 2023-10-11 21:45:32 -07:00
objbincopy.c Make improvements 2024-02-12 10:23:00 -08:00
package.c Make improvements 2024-02-12 10:23:00 -08:00
pecheck.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
pledge.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
printf.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
pwd.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
reboot.c Cull the examples folder 2023-10-11 21:45:32 -07:00
rm.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
rollup.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
runit.c Make improvements 2024-02-12 10:23:00 -08:00
runit.h Fix bugs and add security features to redbean 2022-04-18 00:01:26 -07:00
runitd.c Bring back gc() function 2024-01-08 10:26:28 -08:00
sha256sum.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
shutdown.c Cull the examples folder 2023-10-11 21:45:32 -07:00
summy.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
symtab.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
touch.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
unbuffer.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
unveil.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
verynice.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
zipcopy.c flip et / noet in modelines 2023-12-07 22:17:11 -05:00
zipobj.c Bring back gc() function 2024-01-08 10:26:28 -08:00