Fix global variable initialization for linker
Linker now calls init functions for itself.
(cherry picked from commit 4151ea73b75e274d1ff80b42d9d457a783208516)
Change-Id: I3300fe22de8ad8466a5b1c2d551429769a42852d
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 04ffe59..4c76594 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2077,12 +2077,6 @@
ldpreload_env = linker_env_get("LD_PRELOAD");
}
- // Linker does not call constructors for its own
- // global variables so we need to initialize
- // the allocators explicitly.
- g_soinfo_allocator.init();
- g_soinfo_links_allocator.init();
-
INFO("[ android linker & debugger ]");
soinfo* si = soinfo_alloc(args.argv[0], NULL);
@@ -2271,6 +2265,9 @@
_exit(EXIT_FAILURE);
}
+ // lets properly initialize global variables
+ linker_so.CallConstructors();
+
// We have successfully fixed our own relocations. It's safe to run
// the main part of the linker now.
args.abort_message_ptr = &g_abort_message;