fix: inherit process environment and untrack libc objects
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user