Force stack order for system-V info
The order, spacing and alignment of the argv, envp, and auxv regions are
part of the system-V specification and the init in muslc uses this to
derive the location of auxv from envp.
This uses an anonymous struct to enforce the ordering and spacing of
these items in release builds such that muslc can still initialise libc.
diff --git a/src/start_root.c b/src/start_root.c
index 677d5f7..fe6aa39 100644
--- a/src/start_root.c
+++ b/src/start_root.c
@@ -55,41 +55,45 @@
.p_align = sizeof(seL4_Word),
};
- auxv_t auxv[] = {
- {
- .a_type = AT_PHENT,
- .a_un.a_val = sizeof(Elf32_Phdr),
- }, {
- .a_type = AT_PHNUM,
- .a_un.a_val = 1,
- }, {
- .a_type = AT_PHDR,
- .a_un.a_ptr = &tls_header,
- }, {
- .a_type = AT_SYSINFO,
- .a_un.a_ptr = &sel4_vsyscall,
- }, {
- .a_type = AT_SEL4_BOOT_INFO,
- .a_un.a_ptr = boot_info,
- }, {
- .a_type = AT_SEL4_TCB,
- .a_un.a_val = seL4_CapInitThreadTCB,
- }, {
- // Null terminating entry
- .a_type = AT_NULL,
- .a_un.a_val = 0
+ struct {
+ char const *const argv[2];
+ char const *const envp[2];
+ auxv_t auxv[7];
+ } info = {
+ .argv = {
+ "rootserver",
+ SEL4RUNTIME_NULL,
+ },
+ .envp = {
+ "seL4=1",
+ SEL4RUNTIME_NULL,
+ },
+ .auxv = {
+ {
+ .a_type = AT_PHENT,
+ .a_un.a_val = sizeof(Elf32_Phdr),
+ }, {
+ .a_type = AT_PHNUM,
+ .a_un.a_val = 1,
+ }, {
+ .a_type = AT_PHDR,
+ .a_un.a_ptr = &tls_header,
+ }, {
+ .a_type = AT_SYSINFO,
+ .a_un.a_ptr = &sel4_vsyscall,
+ }, {
+ .a_type = AT_SEL4_BOOT_INFO,
+ .a_un.a_ptr = boot_info,
+ }, {
+ .a_type = AT_SEL4_TCB,
+ .a_un.a_val = seL4_CapInitThreadTCB,
+ }, {
+ // Null terminating entry
+ .a_type = AT_NULL,
+ .a_un.a_val = 0
+ },
},
};
- char const *const envp[] = {
- "seL4=1",
- SEL4RUNTIME_NULL,
- };
-
- char const *const argv[] = {
- "rootserver",
- SEL4RUNTIME_NULL,
- };
-
- __sel4runtime_start_main(main, ARRAY_LENGTH(argv), argv, envp, auxv);
+ __sel4runtime_start_main(main, ARRAY_LENGTH(info.argv), info.argv, info.envp, info.auxv);
}