mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-05-28 15:34:26 +00:00
Updated init app
This commit is contained in:
parent
d82d725f11
commit
0ce6433311
@ -33,7 +33,7 @@ INCLUDE_DIR = ../../../out/system/include
|
||||
|
||||
LDFLAGS := -Wl,-Map file.map
|
||||
|
||||
WARNCFLAG = -Wall -Wextra -Wmain
|
||||
WARNCFLAG = -Wall -Wextra -Wno-main
|
||||
|
||||
CFLAGS := \
|
||||
-I$(INCLUDE_DIR) \
|
||||
@ -61,7 +61,7 @@ $(FILENAME): $(OBJ)
|
||||
|
||||
%.o: %.cpp $(HEADERS)
|
||||
$(info Compiling $<)
|
||||
$(CPP) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti
|
||||
$(CPP) $(CFLAGS) $(WARNCFLAG) -std=c++20 -c $< -o $@
|
||||
|
||||
%.o: %.S
|
||||
$(info Compiling $<)
|
||||
|
@ -1,34 +1,34 @@
|
||||
#include <stdlib.h>
|
||||
#include <init.h>
|
||||
#include <aux.h>
|
||||
|
||||
#include <syslib.h>
|
||||
|
||||
#define print(m, ...) init_log(m, ##__VA_ARGS__)
|
||||
|
||||
int main(int argc, char *argv[], int envc, char *envp[])
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
print("Hello World!\n");
|
||||
print("%p %p %p %p\n", argc, argv, envc, envp);
|
||||
print("%p %p %p\n", (void *)(uint64_t)&argc, (void *)&argv, (void *)&envp);
|
||||
print("I have %d arguments\n", argc);
|
||||
for (int i = 0; i < argc; i++)
|
||||
print("argv[%d] = (%p) %s\n", i, argv[i], argv[i]);
|
||||
|
||||
int envc = 0;
|
||||
while (envp[envc] != NULL)
|
||||
envc++;
|
||||
|
||||
print("I have %d environment variables\n", envc);
|
||||
for (int i = 0; i < envc; i++)
|
||||
print("envp[%d] = (%p) %s\n", i, envp[i], envp[i]);
|
||||
|
||||
Elf64_auxv_t *auxv;
|
||||
while (*envp++ != NULL)
|
||||
char **e = envp;
|
||||
|
||||
while (*e++ != NULL)
|
||||
;
|
||||
|
||||
int i = 0;
|
||||
for (auxv = (Elf64_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++)
|
||||
{
|
||||
print("%lu :%d\n", (auxv->a_type), i++);
|
||||
}
|
||||
for (auxv = (Elf64_auxv_t *)e; auxv->a_type != AT_NULL; auxv++)
|
||||
print("auxv: %ld %#lx\n", auxv->a_type, auxv->a_un.a_val);
|
||||
|
||||
// This code somehow breaks the process. How? I can't figure it out if it's a bug in the kernel or in the libc.
|
||||
void *yes = malloc(0x100);
|
||||
print("malloc(0x100) = %p\n", yes);
|
||||
free(yes);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user