• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂1ac7bf149be1e35343b7f5d830d930bd8bd41fcf (tree)
時間2022-09-07 15:32:48
作者Max Filippov <jcmvbkbc@gmai...>
CommiterWaldemar Brodkorb

Log Message

nptl: use mmap to allocate initial TLS data for static PIE on noMMU

Static PIE ELFs may be loaded on noMMU linux platforms with FDPIC
support, but they don't have adjustable brk, and thus cannot allocate
memory for the TLS. Use mmap instead of sbrk to allocate initial TLS
memory when building with static PIE support for noMMU.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

Change Summary

差異

--- a/libpthread/nptl/sysdeps/generic/libc-tls.c
+++ b/libpthread/nptl/sysdeps/generic/libc-tls.c
@@ -166,10 +166,13 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
166166 for FDPIC MMU-less platforms:
167167 fs/binfmt_elf_fdpic.c: fix brk area overlap with stack on NOMMU
168168 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/binfmt_elf_fdpic.c?id=4ac313111018cb44ecc250445de5ccb93026a980
169+ Loading static PIE ELFs on noMMU is possible since the linux kernel commit
170+ 1bde925d2354 ("fs/binfmt_elf_fdpic.c: provide NOMMU loader for regular ELF binaries")
171+ and it is subject to the same brk restriction.
169172 */
170173 # if defined(TLS_TCB_AT_TP)
171174 tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign);
172-# if defined(__FDPIC__)
175+# if defined(__FDPIC__) || (!defined(__ARCH_USE_MMU__) && defined(STATIC_PIE))
173176 tlsblock = mmap (NULL, tcb_offset + tcbsize + max_align,
174177 PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
175178 # else
@@ -177,7 +180,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
177180 # endif
178181 # elif defined(TLS_DTV_AT_TP)
179182 tcb_offset = roundup (tcbsize, align ?: 1);
180-# if defined(__FDPIC__)
183+# if defined(__FDPIC__) || (!defined(__ARCH_USE_MMU__) && defined(STATIC_PIE))
181184 tlsblock = mmap (NULL, tcb_offset + memsz + max_align + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size),
182185 PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
183186 # else