1.1 --- a/crt0.c Fri Dec 13 00:48:06 2019 +0100
1.2 +++ b/crt0.c Sat Jun 27 01:49:04 2020 +0200
1.3 @@ -1,5 +1,6 @@
1.4 #include <l4/re/env.h>
1.5 -#include <l4/util/elf.h>
1.6 +#include <l4/sys/vcon.h>
1.7 +#include <string.h>
1.8
1.9 #include <stdlib.h> /* exit */
1.10
1.11 @@ -18,7 +19,6 @@
1.12 void *stack_end)
1.13 {
1.14 unsigned long *entry;
1.15 - ElfW(Auxv) *auxv;
1.16
1.17 /* The environment is found after argv. */
1.18
1.19 @@ -36,15 +36,19 @@
1.20
1.21 entry++;
1.22
1.23 - /* Search the auxiliary vector for the L4 environment entry. */
1.24 -
1.25 - auxv = (ElfW(Auxv) *) entry;
1.26 + /* Search the auxiliary vector for the L4 environment entry.
1.27 + For some reason, incrementing an ElfW(Auxv) pointer seems to increment
1.28 + by only 8 bytes instead of the 16 bytes of the structure size (for 64-bit
1.29 + architectures). In fact, the Elf structures are just unusable. So, a
1.30 + plain word pointer is used instead. */
1.31
1.32 - while (auxv->atype != AT_NULL)
1.33 + while (*entry)
1.34 {
1.35 - if (auxv->atype == AT_L4_ENV)
1.36 - l4re_global_env = (void *) auxv->avalue;
1.37 - auxv++;
1.38 + /* Search for AT_L4_ENV as the type. */
1.39 +
1.40 + if (*entry == 0xf1)
1.41 + l4re_global_env = (l4re_env_t *) *(entry + 1);
1.42 + entry += 2;
1.43 }
1.44
1.45 /* Record finalisation routines. */