Improve and fix the stack-protector tests.
Bug: http://b/26888853
(cherry picked from commit fc69a8ad5f0d9b63de48e3858fb4811ede7ac64e)
Change-Id: Ibc431076000b9a8db46f68f858480045b03b6e79
diff --git a/libc/bionic/__libc_init_main_thread.cpp b/libc/bionic/__libc_init_main_thread.cpp
index e1445cb..a29d8a7 100644
--- a/libc/bionic/__libc_init_main_thread.cpp
+++ b/libc/bionic/__libc_init_main_thread.cpp
@@ -74,6 +74,10 @@
main_thread.attr.stack_size = 0; // User code should never see this; we'll compute it when asked.
// TODO: the main thread's sched_policy and sched_priority need to be queried.
+ // The TLS stack guard is set from the global, so ensure that we've initialized the global
+ // before we initialize the TLS.
+ __libc_init_global_stack_chk_guard(args);
+
__init_thread(&main_thread);
__init_tls(&main_thread);