OSDN Git Service

Merge "Document DT_RUNPATH support."
[android-x86/bionic.git] / libc / bionic / libc_init_dynamic.cpp
index 97d9e39..43bca30 100644 (file)
 #include "libc_init_common.h"
 
 #include "private/bionic_globals.h"
+#include "private/bionic_ssp.h"
 #include "private/bionic_tls.h"
 #include "private/KernelArgumentBlock.h"
 
 extern "C" {
-  extern void malloc_debug_fini(void);
   extern void netdClientInit(void);
   extern int __cxa_atexit(void (*)(void *), void *, void *);
 };
@@ -75,6 +75,10 @@ __attribute__((constructor)) static void __libc_preinit() {
   // __libc_init_common() will change the TLS area so the old one won't be accessible anyway.
   *args_slot = NULL;
 
+  // The linker has initialized its copy of the global stack_chk_guard, and filled in the main
+  // thread's TLS slot with that value. Initialize the local global stack guard with its value.
+  __stack_chk_guard = reinterpret_cast<uintptr_t>(tls[TLS_SLOT_STACK_GUARD]);
+
   __libc_init_globals(*args);
   __libc_init_common(*args);
 
@@ -83,11 +87,6 @@ __attribute__((constructor)) static void __libc_preinit() {
   netdClientInit();
 }
 
-__LIBC_HIDDEN__ void __libc_postfini() {
-  // A hook for the debug malloc library to let it know that we're shutting down.
-  malloc_debug_fini();
-}
-
 // This function is called from the executable's _start entry point
 // (see arch-$ARCH/bionic/crtbegin_dynamic.S), which is itself
 // called by the dynamic linker after it has loaded all shared
@@ -114,3 +113,9 @@ __noreturn void __libc_init(void* raw_args,
 
   exit(slingshot(args.argc, args.argv, args.envp));
 }
+
+extern "C" uint32_t android_get_application_target_sdk_version();
+
+uint32_t bionic_get_application_target_sdk_version() {
+  return android_get_application_target_sdk_version();
+}