__program_executable_name is not always mapped when argc == 0
When running an APE with the APE loader without any arguments, for example: ./ape.elf - /path/to/ape-program, the program executable path is not always included in cosmopolitan's memory maps (kisdangerous(__program_executable_name) sometimes returns true). This causes the path returned by GetProgramExecutableName() to be un openable, breaking zipos.
The culprit is:
This function determines the top of stack for the mappings. When argc > 0; ./ape.elf - /path/to/ape-program argv0, as argv0 is placed at a higher address than /path/to/ape-program, /path/to/ape-program is included in the stack. When argc == 0, the fallback case uses the end of auxv as the top of the stack. When /path/to/ape-program occurs on a page at a higher address than auxv, it is excluded from the stack mapping.
Source: jart/cosmopolitan