Disable stack protector for __libc_preinit
__libc_preinit sets up the stack protector global cookie value, and thus
cannot intialize a stack protector cookie for itself in the function
prologue. LTO compilation can inline functions requiring a stack
protector into __libc_preinit. This patch disables stack protection for
__libc_preinit and forces all potentially inlined functions into a
helper that can have a stack protector.
Test: run bionic-unit-tests
Change-Id: I45911611190f216c91eb6feff722967214c5f99f
diff --git a/libc/Android.bp b/libc/Android.bp
index 5a1c287..4f6ff1a 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -123,6 +123,12 @@
cflags: ["-fno-stack-protector"],
}
+cc_library_static {
+ name: "libc_init_dynamic",
+ defaults: ["libc_defaults"],
+ srcs: ["bionic/libc_init_dynamic.cpp"],
+ cflags: ["-fno-stack-protector"],
+}
// ========================================================
// libc_tzcode.a - upstream 'tzcode' code
@@ -1757,10 +1763,10 @@
"arch-common/bionic/crtbrand.S",
"bionic/icu.cpp",
"bionic/malloc_common.cpp",
- "bionic/libc_init_dynamic.cpp",
"bionic/NetdClient.cpp",
"arch-common/bionic/crtend_so.S",
],
+ whole_static_libs: ["libc_init_dynamic"],
},
required: ["tzdata"],