mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 18:30:28 +00:00
Merge branch 'master' into exename-tests
This commit is contained in:
commit
4ef17712fe
8 changed files with 15 additions and 29 deletions
|
@ -1012,8 +1012,8 @@ int main(int argc, char **argv, char **envp) {
|
||||||
Emit("usage: ape PROG [ARGV1,ARGV2,...]\n"
|
Emit("usage: ape PROG [ARGV1,ARGV2,...]\n"
|
||||||
" ape - PROG [ARGV0,ARGV1,...]\n"
|
" ape - PROG [ARGV0,ARGV1,...]\n"
|
||||||
" ($0 = PROG.ape) [ARGV1,ARGV2,...]\n"
|
" ($0 = PROG.ape) [ARGV1,ARGV2,...]\n"
|
||||||
"actually portable executable loader silicon 1.9\n"
|
"actually portable executable loader silicon 1.10\n"
|
||||||
"copyright 2023 justine alexandra roberts tunney\n"
|
"copyrights 2023 justine alexandra roberts tunney\n"
|
||||||
"https://justine.lol/ape.html\n");
|
"https://justine.lol/ape.html\n");
|
||||||
_exit(1);
|
_exit(1);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define COSMOPOLITAN_APE_APE_H_
|
#define COSMOPOLITAN_APE_APE_H_
|
||||||
|
|
||||||
#define APE_VERSION_MAJOR 1
|
#define APE_VERSION_MAJOR 1
|
||||||
#define APE_VERSION_MINOR 9
|
#define APE_VERSION_MINOR 10
|
||||||
#define APE_VERSION_STR APE_VERSION_STR_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
|
#define APE_VERSION_STR APE_VERSION_STR_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
|
||||||
#define APE_VERSION_NOTE APE_VERSION_NOTE_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
|
#define APE_VERSION_NOTE APE_VERSION_NOTE_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ for x in .ape \
|
||||||
.ape-1.7 \
|
.ape-1.7 \
|
||||||
.ape-1.8 \
|
.ape-1.8 \
|
||||||
.ape-1.9 \
|
.ape-1.9 \
|
||||||
|
.ape-1.10 \
|
||||||
.ape-blink-0.9.2 \
|
.ape-blink-0.9.2 \
|
||||||
.ape-blink-1.0.0; do
|
.ape-blink-1.0.0; do
|
||||||
rm -f \
|
rm -f \
|
||||||
|
|
31
ape/loader.c
31
ape/loader.c
|
@ -901,13 +901,8 @@ __attribute__((__noreturn__)) static void ShowUsage(int os, int fd, int rc) {
|
||||||
"\n"
|
"\n"
|
||||||
"USAGE\n"
|
"USAGE\n"
|
||||||
"\n"
|
"\n"
|
||||||
" ape [FLAGS] PROG [ARGV1,ARGV2,...]\n"
|
" ape PROG [ARGV1,ARGV2,...]\n"
|
||||||
" ape [FLAGS] - PROG [ARGV0,ARGV1,...]\n"
|
" ape - PROG [ARGV0,ARGV1,...]\n"
|
||||||
"\n"
|
|
||||||
"FLAGS\n"
|
|
||||||
"\n"
|
|
||||||
" -h show this help\n"
|
|
||||||
" -f force loading of program (do not use execve)\n"
|
|
||||||
"\n",
|
"\n",
|
||||||
0l);
|
0l);
|
||||||
Exit(rc, os);
|
Exit(rc, os);
|
||||||
|
@ -982,20 +977,6 @@ EXTERN_C __attribute__((__noreturn__)) void ApeLoader(long di, long *sp,
|
||||||
os = LINUX;
|
os = LINUX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse flags */
|
|
||||||
while (argc > 1) {
|
|
||||||
if (argv[1][0] != '-') break; /* normal argument */
|
|
||||||
if (!argv[1][1]) break; /* hyphen argument */
|
|
||||||
if (!StrCmp(argv[1], "-h") || !StrCmp(argv[1], "--help")) {
|
|
||||||
ShowUsage(os, 1, 0);
|
|
||||||
} else {
|
|
||||||
Print(os, 2, ape, ": invalid flag (pass -h for help)\n", 0l);
|
|
||||||
Exit(1, os);
|
|
||||||
}
|
|
||||||
*++sp = --argc;
|
|
||||||
++argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we can load via shell, shebang, or binfmt_misc */
|
/* we can load via shell, shebang, or binfmt_misc */
|
||||||
if ((literally = argc >= 3 && !StrCmp(argv[1], "-"))) {
|
if ((literally = argc >= 3 && !StrCmp(argv[1], "-"))) {
|
||||||
/* if the first argument is a hyphen then we give the user the
|
/* if the first argument is a hyphen then we give the user the
|
||||||
|
@ -1006,9 +987,13 @@ EXTERN_C __attribute__((__noreturn__)) void ApeLoader(long di, long *sp,
|
||||||
argc = sp[3] = sp[0] - 3;
|
argc = sp[3] = sp[0] - 3;
|
||||||
argv = (char **)((sp += 3) + 1);
|
argv = (char **)((sp += 3) + 1);
|
||||||
} else if (argc < 2) {
|
} else if (argc < 2) {
|
||||||
Print(os, 2, ape, ": missing command name (pass -h for help)\n", 0l);
|
ShowUsage(os, 2, 1);
|
||||||
Exit(1, os);
|
|
||||||
} else {
|
} else {
|
||||||
|
if (argv[1][0] == '-') {
|
||||||
|
rc = !(argv[1][1] == 'h' && !argv[1][2]) || !StrCmp(argv[1] + 1,
|
||||||
|
"-help");
|
||||||
|
ShowUsage(os, 1 + rc, rc);
|
||||||
|
}
|
||||||
prog = (char *)sp[2];
|
prog = (char *)sp[2];
|
||||||
argc = sp[1] = sp[0] - 1;
|
argc = sp[1] = sp[0] - 1;
|
||||||
argv = (char **)((sp += 1) + 1);
|
argv = (char **)((sp += 1) + 1);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -108,7 +108,7 @@ On Apple Silicon, `aarch64-unknown-cosmo-cc` produces ELF binaries. If
|
||||||
you build a hello world program, then you need to say `ape ./hello`. If
|
you build a hello world program, then you need to say `ape ./hello`. If
|
||||||
you don't have an `ape` command then run `cc -o ape bin/ape-m1.c` which
|
you don't have an `ape` command then run `cc -o ape bin/ape-m1.c` which
|
||||||
should be moved to `/usr/local/bin/ape`. Your APE interpreter might
|
should be moved to `/usr/local/bin/ape`. Your APE interpreter might
|
||||||
already exist under a path like `$TMPDIR/.ape-1.9`. It's important to
|
already exist under a path like `$TMPDIR/.ape-1.10`. It's important to
|
||||||
note this is only a gotcha for the cross compiler. Your `cosmocc`
|
note this is only a gotcha for the cross compiler. Your `cosmocc`
|
||||||
compiler wraps the actual ELF binaries with a shell script that'll
|
compiler wraps the actual ELF binaries with a shell script that'll
|
||||||
extract and compile an APE loader automatically, as needed. This also
|
extract and compile an APE loader automatically, as needed. This also
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue