mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 02:38:31 +00:00
Use unsigned leb128 for magnums
This commit is contained in:
parent
edd9297eba
commit
cdc54ea1fd
931 changed files with 1989 additions and 1983 deletions
|
@ -141,7 +141,7 @@ textwindows int sys_fork_nt(void) {
|
|||
startinfo.hStdOutput = g_fds.p[1].handle;
|
||||
startinfo.hStdError = g_fds.p[2].handle;
|
||||
GetModuleFileNameA(0, exe, ARRAYLEN(exe));
|
||||
if (ntspawn(exe, g_argv, environ, forkvar, &kNtIsInheritable, NULL, true,
|
||||
if (ntspawn(exe, __argv, environ, forkvar, &kNtIsInheritable, NULL, true,
|
||||
0, NULL, &startinfo, &procinfo) != -1) {
|
||||
CloseHandle(reader);
|
||||
CloseHandle(procinfo.hThread);
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
#include "libc/notice.inc"
|
||||
|
||||
.initbss 300,_init_g_argc
|
||||
g_argc: .quad 0
|
||||
.endobj g_argc,globl,hidden
|
||||
.initbss 300,_init___argc
|
||||
/ Global variable holding _start(argc) parameter.
|
||||
__argc: .quad 0
|
||||
.endobj __argc,globl
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_g_argc
|
||||
.init.start 300,_init___argc
|
||||
mov %r12,%rax
|
||||
stosq
|
||||
.init.end 300,_init_g_argc
|
||||
.init.end 300,_init___argc
|
||||
|
|
|
@ -8,10 +8,10 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
typedef long jmp_buf[8] forcealign(CACHELINE);
|
||||
|
||||
extern int g_argc; /* CRT */
|
||||
extern char **g_argv; /* CRT */
|
||||
extern int __argc; /* CRT */
|
||||
extern char **__argv; /* CRT */
|
||||
extern char **environ; /* CRT */
|
||||
extern unsigned long *g_auxv; /* CRT */
|
||||
extern unsigned long *__auxv; /* CRT */
|
||||
extern char *program_invocation_name; /* RII */
|
||||
extern char *program_invocation_short_name; /* RII */
|
||||
extern uint64_t g_syscount; /* RII */
|
||||
|
|
|
@ -41,8 +41,12 @@
|
|||
#include "libc/runtime/memtrack.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
#define MAP_ANONYMOUS 32
|
||||
#define MAP_PRIVATE 2
|
||||
#define PROT_EXEC 4
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
|
||||
/*
|
||||
* TODO: Why can't we allocate addresses above 4GB on Windows 7 x64?
|
||||
|
@ -51,7 +55,8 @@
|
|||
|
||||
struct WinArgs {
|
||||
char *argv[4096];
|
||||
char *envp[4096];
|
||||
char *envp[4092];
|
||||
intptr_t auxv[2][2];
|
||||
char argblock[ARG_MAX];
|
||||
char envblock[ARG_MAX];
|
||||
};
|
||||
|
@ -100,7 +105,6 @@ static noasan textwindows wontreturn void WinMainNew(void) {
|
|||
size_t size;
|
||||
int i, count;
|
||||
uint64_t addr;
|
||||
long auxv[1][2];
|
||||
struct WinArgs *wa;
|
||||
const char16_t *env16;
|
||||
extern char os asm("__hostos");
|
||||
|
@ -120,18 +124,23 @@ static noasan textwindows wontreturn void WinMainNew(void) {
|
|||
_mmi.p[0].flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||
_mmi.i = pushpop(1L);
|
||||
wa = (struct WinArgs *)(addr + size - sizeof(struct WinArgs));
|
||||
count = GetDosArgv(GetCommandLine(), wa->argblock, ARG_MAX, wa->argv, 4096);
|
||||
count = GetDosArgv(GetCommandLine(), wa->argblock, ARRAYLEN(wa->argblock),
|
||||
wa->argv, ARRAYLEN(wa->argv));
|
||||
for (i = 0; wa->argv[0][i]; ++i) {
|
||||
if (wa->argv[0][i] == '\\') {
|
||||
wa->argv[0][i] = '/';
|
||||
}
|
||||
}
|
||||
env16 = GetEnvironmentStrings();
|
||||
GetDosEnviron(env16, wa->envblock, ARG_MAX, wa->envp, 4096);
|
||||
GetDosEnviron(env16, wa->envblock, ARRAYLEN(wa->envblock), wa->envp,
|
||||
ARRAYLEN(wa->envp));
|
||||
FreeEnvironmentStrings(env16);
|
||||
auxv[0][0] = pushpop(0L);
|
||||
auxv[0][1] = pushpop(0L);
|
||||
_jmpstack((char *)addr + STACKSIZE, cosmo, count, wa->argv, wa->envp, auxv);
|
||||
wa->auxv[1][0] = pushpop(0L);
|
||||
wa->auxv[1][1] = pushpop(0L);
|
||||
wa->auxv[0][0] = (intptr_t)wa->argv[0];
|
||||
wa->auxv[0][1] = pushpop(31L);
|
||||
_jmpstack((char *)addr + STACKSIZE, cosmo, count, wa->argv, wa->envp,
|
||||
wa->auxv);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue