aboutsummaryrefslogtreecommitdiff
path: root/libs/libc/crt
diff options
context:
space:
mode:
authorMarvin Borner2021-04-05 00:22:15 +0200
committerMarvin Borner2021-04-05 00:22:15 +0200
commitb476dc856431436ac0f3e0179f8a25302421a0cc (patch)
treeac89ab7533db5ebae796ec0f732271afff10c891 /libs/libc/crt
parent248c0d2fd007eeeb108ff1a88924e3ef8ff84ba4 (diff)
Added new randomization features
Diffstat (limited to 'libs/libc/crt')
-rw-r--r--libs/libc/crt/crt0.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/libs/libc/crt/crt0.c b/libs/libc/crt/crt0.c
index 6c38474..3bd413f 100644
--- a/libs/libc/crt/crt0.c
+++ b/libs/libc/crt/crt0.c
@@ -1,18 +1,28 @@
// MIT License, Copyright (c) 2021 Marvin Borner
+#include <assert.h>
#include <def.h>
+#include <random.h>
#include <sys.h>
#ifdef USER
-extern int main(int, char **);
+extern u32 __stack_chk_guard;
+u32 __stack_chk_guard;
-void _start(void);
-void _start(void)
+int main(int, char **);
+
+int _start(int argc, char **argv);
+int _start(int argc, char **argv)
{
- exit(main(0, NULL));
- while (1)
- ;
+ u32 stamp = 0;
+ assert(read("/dev/rtc", &stamp, 0, sizeof(stamp)) == sizeof(stamp) && stamp);
+ srand(stamp);
+ rand_fill(&__stack_chk_guard, sizeof(__stack_chk_guard));
+
+ exit(main(argc, argv));
+
+ return 1;
}
#endif