Fix debug malloc.

This was broken by the change to use AT_RANDOM for the stack guards.

Bug: 7959813
Bug: 8330764
Change-Id: I791900092b72a9a900f16585237fa7ad82aaed9f
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index 6038056..33ec1db 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -26,21 +26,24 @@
  * SUCH DAMAGE.
  */
 
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <unistd.h>
-#include <elf.h>
-#include <asm/page.h>
-#include "pthread_internal.h"
-#include "atexit.h"
-#include "KernelArgumentBlock.h"
 #include "libc_init_common.h"
 
+#include <asm/page.h>
 #include <bionic_tls.h>
+#include <elf.h>
 #include <errno.h>
-#include <private/bionic_auxv.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <unistd.h>
+
+#include "atexit.h"
+#include "private/bionic_auxv.h"
+#include "private/bionic_ssp.h"
+#include "private/KernelArgumentBlock.h"
+#include "pthread_internal.h"
 
 extern "C" unsigned __get_sp(void);
 extern "C" int __system_properties_init(void);
@@ -51,6 +54,9 @@
 // Declared in <unistd.h>.
 char** environ;
 
+// Declared in <private/bionic_ssp.h>.
+uintptr_t __stack_chk_guard = 0;
+
 // Declared in <asm/page.h>.
 unsigned int __page_size = PAGE_SIZE;
 unsigned int __page_shift = PAGE_SHIFT;
@@ -91,6 +97,9 @@
   __libc_auxv = args.auxv;
   __progname = args.argv[0] ? args.argv[0] : "<unknown>";
 
+  // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
+  __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM));
+
   // Get the main thread from TLS and add it to the thread list.
   pthread_internal_t* main_thread = __get_thread();
   main_thread->allocated_on_heap = false;