Defend against -fstack-protector in libc startup.
Exactly which functions get a stack protector is up to the compiler, so
let's separate the code that sets up the environment stack protection
requires and explicitly build it with -fno-stack-protector.
Bug: http://b/26276517
Change-Id: I8719e23ead1f1e81715c32c1335da868f68369b5
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 130e341..70c2ca5 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -4154,6 +4154,7 @@
return 0;
}
+extern "C" int __set_tls(void*);
extern "C" void _start();
/*
@@ -4168,6 +4169,9 @@
extern "C" ElfW(Addr) __linker_init(void* raw_args) {
KernelArgumentBlock args(raw_args);
+ void* tls[BIONIC_TLS_SLOTS];
+ __set_tls(tls);
+
ElfW(Addr) linker_addr = args.getauxval(AT_BASE);
ElfW(Addr) entry_point = args.getauxval(AT_ENTRY);
ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_addr);