fix: inherit process environment and untrack libc objects

This commit is contained in:
2026-08-11 13:08:40 +02:00
parent 0a91131cb0
commit 3ef98a9fd5
26 changed files with 254 additions and 36 deletions
+8
View File
@@ -39,6 +39,9 @@ static inline long _sys2(long nr, long a1, long a2) {
#define SYS_GETSIZE 8
#define SYS_GETARGS 25
#define SYS_GETENVIRON 171
void __libc_init_environ(const char *blob, unsigned long len);
/* fdopen, strtoll and strtoull used to be defined here; they moved
into the Montauk libc with the native binutils port. */
@@ -50,6 +53,11 @@ static inline long _sys2(long nr, long a1, long a2) {
int main(int argc, char **argv);
void _start(void) {
static char envbuf[4096];
int envlen = (int)_sys2(SYS_GETENVIRON, (long)envbuf, sizeof(envbuf));
if (envlen > 0)
__libc_init_environ(envbuf, (unsigned long)envlen);
/* Get command-line arguments from kernel */
char argbuf[256];
int len = (int)_sys2(SYS_GETARGS, (long)argbuf, sizeof(argbuf));