mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
1422e96b4e
There's a new program named ape/ape-m1.c which will be used to build an embeddable binary that can load ape and elf executables. The support is mostly working so far, but still chasing down ABI issues.
37 lines
1.5 KiB
C
37 lines
1.5 KiB
C
#if 0
|
|
/*─────────────────────────────────────────────────────────────────╗
|
|
│ To the extent possible under law, Justine Tunney has waived │
|
|
│ all copyright and related or neighboring rights to this file, │
|
|
│ as it is written in the following disclaimers: │
|
|
│ • http://unlicense.org/ │
|
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
╚─────────────────────────────────────────────────────────────────*/
|
|
#endif
|
|
#include "ape/sections.internal.h"
|
|
#include "libc/dce.h"
|
|
#include "libc/runtime/runtime.h"
|
|
#include "libc/stdio/stdio.h"
|
|
|
|
/**
|
|
* @fileoverview Non-Self-Modifying APE Binary Demo
|
|
*
|
|
* See examples/examples.mk for the build config, which uses the
|
|
* alternative APE runtime.
|
|
*/
|
|
|
|
int main(int argc, char *argv[]) {
|
|
if (__executable_start[0] == 'M' && __executable_start[1] == 'Z') {
|
|
printf("success: %s spawned without needing to modify its "
|
|
"executable header",
|
|
argv[0]);
|
|
if (!IsWindows()) {
|
|
printf(", thanks to APE loader!\n");
|
|
} else {
|
|
printf(", because you ran it on Windows :P\n");
|
|
}
|
|
return 0;
|
|
} else {
|
|
printf("error: %s doesn't have an MZ file header!\n", argv[0]);
|
|
return 1;
|
|
}
|
|
}
|