[libc-commits] [libc] Supporting stack protectors in linux x86-64 (PR #66456)

via libc-commits libc-commits at lists.llvm.org
Wed Oct 4 05:51:05 PDT 2023


================
@@ -54,7 +57,9 @@ void init_tls(TLSDescriptor &tls_descriptor) {
   // Per the x86_64 TLS ABI, the entry pointed to by the thread pointer is the
   // address of the TLS block. So, we add more size to accomodate this address
   // entry.
-  uintptr_t tlsSizeWithAddr = tlsSize + sizeof(uintptr_t);
+  // We also need to include space for the stack canary. The canary is at
+  // offset 0x28 (40) and is of size uintptr_t.
+  uintptr_t tlsSizeWithAddr = tlsSize + sizeof(uintptr_t) + 40;
----------------
tnv01 wrote:

Based on discussion this should be fine.

https://github.com/llvm/llvm-project/pull/66456


More information about the libc-commits mailing list