+ if (aux[AT_UID]==aux[AT_EUID] && aux[AT_GID]==aux[AT_EGID]
+ && !aux[AT_SECURE]) return;
+
+ struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
+ int r =
+#ifdef SYS_poll
+ __syscall(SYS_poll, pfd, 3, 0);
+#else
+ __syscall(SYS_ppoll, pfd, 3, &(struct timespec){0}, 0, _NSIG/8);
+#endif
+ if (r<0) a_crash();
+ for (i=0; i<3; i++) if (pfd[i].revents&POLLNVAL)
+ if (__sys_open("/dev/null", O_RDWR)<0)
+ a_crash();
+ libc.secure = 1;
+}
+
+static void libc_start_init(void)
+{
+ _init();
+ uintptr_t a = (uintptr_t)&__init_array_start;
+ for (; a<(uintptr_t)&__init_array_end; a+=sizeof(void(*)()))
+ (*(void (**)(void))a)();
+}
+
+weak_alias(libc_start_init, __libc_start_init);
+
+typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);
+static lsm2_fn libc_start_main_stage2;
+
+int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
+{
+ char **envp = argv+argc+1;
+
+ /* External linkage, and explicit noinline attribute if available,
+ * are used to prevent the stack frame used during init from
+ * persisting for the entire process lifetime. */
+ __init_libc(envp, argv[0]);
+
+ /* Barrier against hoisting application code or anything using ssp
+ * or thread pointer prior to its initialization above. */
+ lsm2_fn *stage2 = libc_start_main_stage2;
+ __asm__ ( "" : "+r"(stage2) : : "memory" );
+ return stage2(main, argc, argv);
+}
+
+static int libc_start_main_stage2(int (*main)(int,char **,char **), int argc, char **argv)
+{
+ char **envp = argv+argc+1;
+ __libc_start_init();