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

Siva Chandra via libc-commits libc-commits at lists.llvm.org
Thu Sep 21 11:33:17 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;
----------------
sivachandra wrote:

They are in different directions. You need `uintptr_t` worth of memory starting from offset 40, which the current allocation doesn't include.

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


More information about the libc-commits mailing list