1f34a2328890aa192141f96449d25b77f666bf47.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. From 1f34a2328890aa192141f96449d25b77f666bf47 Mon Sep 17 00:00:00 2001
  2. From: Florian Weimer <fweimer@redhat.com>
  3. Date: Thu, 3 Nov 2022 17:28:03 +0100
  4. Subject: [PATCH] elf: Introduce <dl-call_tls_init_tp.h> and call_tls_init_tp
  5. (bug 29249)
  6. This makes it more likely that the compiler can compute the strlen
  7. argument in _startup_fatal at compile time, which is required to
  8. avoid a dependency on strlen this early during process startup.
  9. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
  10. ---
  11. csu/libc-tls.c | 14 ++++-------
  12. elf/rtld.c | 14 +++--------
  13. sysdeps/aarch64/nptl/tls.h | 2 +-
  14. sysdeps/alpha/nptl/tls.h | 2 +-
  15. sysdeps/arc/nptl/tls.h | 3 +--
  16. sysdeps/csky/nptl/tls.h | 3 +--
  17. sysdeps/generic/dl-call_tls_init_tp.h | 34 +++++++++++++++++++++++++++
  18. sysdeps/generic/startup.h | 2 +-
  19. sysdeps/hppa/nptl/tls.h | 2 +-
  20. sysdeps/i386/nptl/tls.h | 3 +--
  21. sysdeps/ia64/nptl/tls.h | 2 +-
  22. sysdeps/loongarch/nptl/tls.h | 2 +-
  23. sysdeps/m68k/nptl/tls.h | 2 +-
  24. sysdeps/mach/hurd/i386/tls.h | 10 ++++----
  25. sysdeps/microblaze/nptl/tls.h | 2 +-
  26. sysdeps/mips/nptl/tls.h | 3 +--
  27. sysdeps/nios2/nptl/tls.h | 2 +-
  28. sysdeps/or1k/nptl/tls.h | 2 +-
  29. sysdeps/powerpc/nptl/tls.h | 2 +-
  30. sysdeps/riscv/nptl/tls.h | 2 +-
  31. sysdeps/s390/nptl/tls.h | 2 +-
  32. sysdeps/sh/nptl/tls.h | 2 +-
  33. sysdeps/sparc/nptl/tls.h | 2 +-
  34. sysdeps/unix/sysv/linux/arm/tls.h | 3 +--
  35. sysdeps/x86_64/nptl/tls.h | 2 +-
  36. 25 files changed, 68 insertions(+), 51 deletions(-)
  37. create mode 100644 sysdeps/generic/dl-call_tls_init_tp.h
  38. diff --git a/csu/libc-tls.c b/csu/libc-tls.c
  39. index 0a216c55028..ca4def26133 100644
  40. --- a/csu/libc-tls.c
  41. +++ b/csu/libc-tls.c
  42. @@ -25,6 +25,7 @@
  43. #include <sys/param.h>
  44. #include <array_length.h>
  45. #include <pthreadP.h>
  46. +#include <dl-call_tls_init_tp.h>
  47. #ifdef SHARED
  48. #error makefile bug, this file is for static only
  49. @@ -147,14 +148,14 @@ __libc_setup_tls (void)
  50. tcb_offset = roundup (memsz + GLRO(dl_tls_static_surplus), max_align);
  51. tlsblock = _dl_early_allocate (tcb_offset + TLS_INIT_TCB_SIZE + max_align);
  52. if (tlsblock == NULL)
  53. - _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n");
  54. + _startup_fatal_tls_error ();
  55. #elif TLS_DTV_AT_TP
  56. tcb_offset = roundup (TLS_INIT_TCB_SIZE, align ?: 1);
  57. tlsblock = _dl_early_allocate (tcb_offset + memsz + max_align
  58. + TLS_PRE_TCB_SIZE
  59. + GLRO(dl_tls_static_surplus));
  60. if (tlsblock == NULL)
  61. - _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n");
  62. + _startup_fatal_tls_error ();
  63. tlsblock += TLS_PRE_TCB_SIZE;
  64. #else
  65. /* In case a model with a different layout for the TCB and DTV
  66. @@ -191,16 +192,11 @@ __libc_setup_tls (void)
  67. #if TLS_TCB_AT_TP
  68. INSTALL_DTV ((char *) tlsblock + tcb_offset, _dl_static_dtv);
  69. - const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset);
  70. + call_tls_init_tp ((char *) tlsblock + tcb_offset);
  71. #elif TLS_DTV_AT_TP
  72. INSTALL_DTV (tlsblock, _dl_static_dtv);
  73. - const char *lossage = TLS_INIT_TP (tlsblock);
  74. -#else
  75. -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
  76. + call_tls_init_tp (tlsblock);
  77. #endif
  78. - if (__builtin_expect (lossage != NULL, 0))
  79. - _startup_fatal (lossage);
  80. - __tls_init_tp ();
  81. /* Update the executable's link map with enough information to make
  82. the TLS routines happy. */
  83. diff --git a/elf/rtld.c b/elf/rtld.c
  84. index 8671594f1f5..70ad1acc43e 100644
  85. --- a/elf/rtld.c
  86. +++ b/elf/rtld.c
  87. @@ -52,6 +52,7 @@
  88. #include <dl-execve.h>
  89. #include <dl-find_object.h>
  90. #include <dl-audit-check.h>
  91. +#include <dl-call_tls_init_tp.h>
  92. #include <assert.h>
  93. @@ -796,10 +797,7 @@ cannot allocate TLS data structures for initial thread\n");
  94. GL(dl_initial_dtv) = GET_DTV (tcbp);
  95. /* And finally install it for the main thread. */
  96. - const char *lossage = TLS_INIT_TP (tcbp);
  97. - if (__glibc_unlikely (lossage != NULL))
  98. - _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
  99. - __tls_init_tp ();
  100. + call_tls_init_tp (tcbp);
  101. tls_init_tp_called = true;
  102. return tcbp;
  103. @@ -2348,13 +2346,7 @@ dl_main (const ElfW(Phdr) *phdr,
  104. /* And finally install it for the main thread. */
  105. if (! tls_init_tp_called)
  106. - {
  107. - const char *lossage = TLS_INIT_TP (tcbp);
  108. - if (__glibc_unlikely (lossage != NULL))
  109. - _dl_fatal_printf ("cannot set up thread-local storage: %s\n",
  110. - lossage);
  111. - __tls_init_tp ();
  112. - }
  113. + call_tls_init_tp (tcbp);
  114. /* Make sure no new search directories have been added. */
  115. assert (GLRO(dl_init_all_dirs) == GL(dl_all_dirs));
  116. diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h
  117. index 08aa2eff891..6fe084c1ef9 100644
  118. --- a/sysdeps/aarch64/nptl/tls.h
  119. +++ b/sysdeps/aarch64/nptl/tls.h
  120. @@ -72,7 +72,7 @@ typedef struct
  121. special attention since 'errno' is not yet available and if the
  122. operation can cause a failure 'errno' must not be touched. */
  123. # define TLS_INIT_TP(tcbp) \
  124. - ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); NULL; })
  125. + ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); true; })
  126. /* Value passed to 'clone' for initialization of the thread register. */
  127. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
  128. diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h
  129. index 8f5b69ad3b1..48dc1369fc1 100644
  130. --- a/sysdeps/alpha/nptl/tls.h
  131. +++ b/sysdeps/alpha/nptl/tls.h
  132. @@ -69,7 +69,7 @@ typedef struct
  133. special attention since 'errno' is not yet available and if the
  134. operation can cause a failure 'errno' must not be touched. */
  135. # define TLS_INIT_TP(tcbp) \
  136. - (__builtin_set_thread_pointer ((void *)(tcbp)), NULL)
  137. + (__builtin_set_thread_pointer ((void *)(tcbp)), true)
  138. /* Value passed to 'clone' for initialization of the thread register. */
  139. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
  140. diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
  141. index 7fc6602b236..948e618a3aa 100644
  142. --- a/sysdeps/arc/nptl/tls.h
  143. +++ b/sysdeps/arc/nptl/tls.h
  144. @@ -75,8 +75,7 @@ typedef struct
  145. long result_var; \
  146. __builtin_set_thread_pointer (tcbp); \
  147. result_var = INTERNAL_SYSCALL_CALL (arc_settls, (tcbp));\
  148. - INTERNAL_SYSCALL_ERROR_P (result_var) \
  149. - ? "settls syscall error" : NULL; \
  150. + !INTERNAL_SYSCALL_ERROR_P (result_var); \
  151. })
  152. /* Value passed to 'clone' for initialization of the thread register. */
  153. diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
  154. index 58d6ab0fb2a..3f7afc93391 100644
  155. --- a/sysdeps/csky/nptl/tls.h
  156. +++ b/sysdeps/csky/nptl/tls.h
  157. @@ -92,8 +92,7 @@ typedef struct
  158. ({ long int result_var; \
  159. result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \
  160. (char *) (tcbp) + TLS_TCB_OFFSET); \
  161. - INTERNAL_SYSCALL_ERROR_P (result_var) \
  162. - ? "unknown error" : NULL; })
  163. + !INTERNAL_SYSCALL_ERROR_P (result_var); })
  164. /* Return the address of the dtv for the current thread. */
  165. # define THREAD_DTV() \
  166. diff --git a/sysdeps/generic/dl-call_tls_init_tp.h b/sysdeps/generic/dl-call_tls_init_tp.h
  167. new file mode 100644
  168. index 00000000000..411feda3fc0
  169. --- /dev/null
  170. +++ b/sysdeps/generic/dl-call_tls_init_tp.h
  171. @@ -0,0 +1,34 @@
  172. +/* Invoke TLS_INIT_TP and __tls_init_tp with error handling.
  173. + Copyright (C) 2022 Free Software Foundation, Inc.
  174. + This file is part of the GNU C Library.
  175. +
  176. + The GNU C Library is free software; you can redistribute it and/or
  177. + modify it under the terms of the GNU Lesser General Public
  178. + License as published by the Free Software Foundation; either
  179. + version 2.1 of the License, or (at your option) any later version.
  180. +
  181. + The GNU C Library is distributed in the hope that it will be useful,
  182. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  183. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  184. + Lesser General Public License for more details.
  185. +
  186. + You should have received a copy of the GNU Lesser General Public
  187. + License along with the GNU C Library; if not, see
  188. + <https://www.gnu.org/licenses/>. */
  189. +
  190. +#include <startup.h>
  191. +#include <tls.h>
  192. +
  193. +static inline void
  194. +_startup_fatal_tls_error (void)
  195. +{
  196. + _startup_fatal ("Fatal glibc error: Cannot allocate TLS block\n");
  197. +}
  198. +
  199. +static inline void
  200. +call_tls_init_tp (void *addr)
  201. +{
  202. + if (!TLS_INIT_TP (addr))
  203. + _startup_fatal_tls_error ();
  204. + __tls_init_tp ();
  205. +}
  206. diff --git a/sysdeps/generic/startup.h b/sysdeps/generic/startup.h
  207. index 45979ab2319..4b444511b4f 100644
  208. --- a/sysdeps/generic/startup.h
  209. +++ b/sysdeps/generic/startup.h
  210. @@ -19,7 +19,7 @@
  211. /* Targets should override this file if the default definitions below
  212. will not work correctly very early before TLS is initialized. */
  213. -#include <unistd.h>
  214. +#include <stdio.h>
  215. /* Use macro instead of inline function to avoid including <stdio.h>. */
  216. #define _startup_fatal(message) __libc_fatal ((message))
  217. diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h
  218. index e6b0bd5c718..6af22cdc004 100644
  219. --- a/sysdeps/hppa/nptl/tls.h
  220. +++ b/sysdeps/hppa/nptl/tls.h
  221. @@ -74,7 +74,7 @@ typedef struct
  222. special attention since 'errno' is not yet available and if the
  223. operation can cause a failure 'errno' must not be touched. */
  224. # define TLS_INIT_TP(tcbp) \
  225. - ({ __set_cr27(tcbp); NULL; })
  226. + ({ __set_cr27(tcbp); true; })
  227. /* Value passed to 'clone' for initialization of the thread register. */
  228. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
  229. diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
  230. index 91090bf2877..553b55b3f2d 100644
  231. --- a/sysdeps/i386/nptl/tls.h
  232. +++ b/sysdeps/i386/nptl/tls.h
  233. @@ -203,8 +203,7 @@ tls_fill_user_desc (union user_desc_init *desc,
  234. which is necessary since we have changed it. */ \
  235. TLS_SET_GS (_segdescr.desc.entry_number * 8 + 3); \
  236. \
  237. - _result == 0 ? NULL \
  238. - : "set_thread_area failed when setting up thread-local storage\n"; })
  239. + _result == 0; })
  240. # define TLS_DEFINE_INIT_TP(tp, pd) \
  241. union user_desc_init _segdescr; \
  242. diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h
  243. index d2411b3c1ac..4085c568326 100644
  244. --- a/sysdeps/ia64/nptl/tls.h
  245. +++ b/sysdeps/ia64/nptl/tls.h
  246. @@ -105,7 +105,7 @@ register struct pthread *__thread_self __asm__("r13");
  247. special attention since 'errno' is not yet available and if the
  248. operation can cause a failure 'errno' must not be touched. */
  249. # define TLS_INIT_TP(thrdescr) \
  250. - (__thread_self = (thrdescr), INIT_SYSINFO, NULL)
  251. + (__thread_self = (thrdescr), INIT_SYSINFO, true)
  252. /* Value passed to 'clone2' for initialization of the thread register. */
  253. # define TLS_DEFINE_INIT_TP(tp, pd) \
  254. diff --git a/sysdeps/loongarch/nptl/tls.h b/sysdeps/loongarch/nptl/tls.h
  255. index 24bffe3a0ad..e8b616854f7 100644
  256. --- a/sysdeps/loongarch/nptl/tls.h
  257. +++ b/sysdeps/loongarch/nptl/tls.h
  258. @@ -83,7 +83,7 @@ typedef struct
  259. #define TLS_INIT_TP(tcbp) \
  260. ({ \
  261. __thread_self = (char *) tcbp + TLS_TCB_OFFSET; \
  262. - NULL; \
  263. + true; \
  264. })
  265. /* Return the address of the dtv for the current thread. */
  266. diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
  267. index 742e1b6767d..ebcc118bbe2 100644
  268. --- a/sysdeps/m68k/nptl/tls.h
  269. +++ b/sysdeps/m68k/nptl/tls.h
  270. @@ -90,7 +90,7 @@ typedef struct
  271. \
  272. _sys_result = INTERNAL_SYSCALL_CALL (set_thread_area, \
  273. ((void *) (tcbp)) + TLS_TCB_OFFSET); \
  274. - INTERNAL_SYSCALL_ERROR_P (_sys_result) ? "unknown error" : NULL; })
  275. + !INTERNAL_SYSCALL_ERROR_P (_sys_result); })
  276. # define TLS_DEFINE_INIT_TP(tp, pd) \
  277. void *tp = (void *) (pd) + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE
  278. diff --git a/sysdeps/mach/hurd/i386/tls.h b/sysdeps/mach/hurd/i386/tls.h
  279. index 602bacc0de0..2847e3ee61c 100644
  280. --- a/sysdeps/mach/hurd/i386/tls.h
  281. +++ b/sysdeps/mach/hurd/i386/tls.h
  282. @@ -117,12 +117,12 @@ extern unsigned short __init1_desc;
  283. # define HURD_SEL_LDT(sel) (__builtin_expect ((sel) & 4, 0))
  284. -static inline const char * __attribute__ ((unused))
  285. +static inline bool __attribute__ ((unused))
  286. _hurd_tls_init (tcbhead_t *tcb)
  287. {
  288. HURD_TLS_DESC_DECL (desc, tcb);
  289. thread_t self = __mach_thread_self ();
  290. - const char *msg = NULL;
  291. + bool success = true;
  292. /* This field is used by TLS accesses to get our "thread pointer"
  293. from the TLS point of view. */
  294. @@ -141,14 +141,14 @@ _hurd_tls_init (tcbhead_t *tcb)
  295. assert_perror (err);
  296. if (err)
  297. {
  298. - msg = "i386_set_ldt failed";
  299. + success = false;
  300. goto out;
  301. }
  302. }
  303. else if (err)
  304. {
  305. assert_perror (err); /* Separate from above with different line #. */
  306. - msg = "i386_set_gdt failed";
  307. + success = false;
  308. goto out;
  309. }
  310. @@ -157,7 +157,7 @@ _hurd_tls_init (tcbhead_t *tcb)
  311. out:
  312. __mach_port_deallocate (__mach_task_self (), self);
  313. - return msg;
  314. + return success;
  315. }
  316. /* Code to initially initialize the thread pointer. This might need
  317. diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h
  318. index 588fd1c5d63..d8be1932b9b 100644
  319. --- a/sysdeps/microblaze/nptl/tls.h
  320. +++ b/sysdeps/microblaze/nptl/tls.h
  321. @@ -75,7 +75,7 @@ typedef struct
  322. /* Code to initially initialize the thread pointer.
  323. r21 is reserved for thread pointer. */
  324. # define TLS_INIT_TP(tcbp) \
  325. - ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); NULL; })
  326. + ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); true; })
  327. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
  328. diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
  329. index 2aa7cb4bb8d..bac6e8771cd 100644
  330. --- a/sysdeps/mips/nptl/tls.h
  331. +++ b/sysdeps/mips/nptl/tls.h
  332. @@ -116,8 +116,7 @@ typedef struct
  333. ({ long int result_var; \
  334. result_var = INTERNAL_SYSCALL_CALL (set_thread_area, \
  335. (char *) (tcbp) + TLS_TCB_OFFSET); \
  336. - INTERNAL_SYSCALL_ERROR_P (result_var) \
  337. - ? "unknown error" : NULL; })
  338. + !INTERNAL_SYSCALL_ERROR_P (result_var); })
  339. /* Value passed to 'clone' for initialization of the thread register. */
  340. # define TLS_DEFINE_INIT_TP(tp, pd) \
  341. diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h
  342. index cb231e2a4bb..f5a9713f93f 100644
  343. --- a/sysdeps/nios2/nptl/tls.h
  344. +++ b/sysdeps/nios2/nptl/tls.h
  345. @@ -88,7 +88,7 @@ register struct pthread *__thread_self __asm__("r23");
  346. /* Code to initially initialize the thread pointer. */
  347. # define TLS_INIT_TP(tcbp) \
  348. - (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), NULL)
  349. + (__thread_self = (struct pthread *) ((char *) tcbp + TLS_TCB_OFFSET), true)
  350. /* Value passed to 'clone' for initialization of the thread register. */
  351. # define TLS_DEFINE_INIT_TP(tp, pd) \
  352. diff --git a/sysdeps/or1k/nptl/tls.h b/sysdeps/or1k/nptl/tls.h
  353. index e82f444738d..eda0e893aea 100644
  354. --- a/sysdeps/or1k/nptl/tls.h
  355. +++ b/sysdeps/or1k/nptl/tls.h
  356. @@ -112,7 +112,7 @@ register tcbhead_t *__thread_self __asm__("r10");
  357. It's hard to fail this, so return NULL always. */
  358. # define TLS_INIT_TP(tcbp) \
  359. - ({__thread_self = ((tcbhead_t *)tcbp + 1); NULL;})
  360. + ({__thread_self = ((tcbhead_t *)tcbp + 1); true;})
  361. /* Value passed to 'clone' for initialization of the thread register. */
  362. # define TLS_DEFINE_INIT_TP(tp, pd) \
  363. diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
  364. index e62a96238aa..68a1d8b546b 100644
  365. --- a/sysdeps/powerpc/nptl/tls.h
  366. +++ b/sysdeps/powerpc/nptl/tls.h
  367. @@ -139,7 +139,7 @@ typedef struct
  368. __thread_register = (void *) (tcbp) + TLS_TCB_OFFSET; \
  369. THREAD_SET_HWCAP (__tcb.hwcap); \
  370. THREAD_SET_AT_PLATFORM (__tcb.at_platform); \
  371. - NULL; \
  372. + true; \
  373. })
  374. /* Value passed to 'clone' for initialization of the thread register. */
  375. diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h
  376. index 700c2f51899..b221980399b 100644
  377. --- a/sysdeps/riscv/nptl/tls.h
  378. +++ b/sysdeps/riscv/nptl/tls.h
  379. @@ -79,7 +79,7 @@ typedef struct
  380. /* Code to initially initialize the thread pointer. */
  381. # define TLS_INIT_TP(tcbp) \
  382. - ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; NULL; })
  383. + ({ __thread_self = (char*)tcbp + TLS_TCB_OFFSET; true; })
  384. /* Return the address of the dtv for the current thread. */
  385. # define THREAD_DTV() \
  386. diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h
  387. index 98d7870148c..937c49dda68 100644
  388. --- a/sysdeps/s390/nptl/tls.h
  389. +++ b/sysdeps/s390/nptl/tls.h
  390. @@ -112,7 +112,7 @@ typedef struct
  391. INIT_SYSINFO; \
  392. \
  393. __builtin_set_thread_pointer (_thrdescr); \
  394. - NULL; \
  395. + true; \
  396. })
  397. /* Value passed to 'clone' for initialization of the thread register. */
  398. diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h
  399. index 1530489a6ce..3882114f5c8 100644
  400. --- a/sysdeps/sh/nptl/tls.h
  401. +++ b/sysdeps/sh/nptl/tls.h
  402. @@ -83,7 +83,7 @@ typedef struct
  403. special attention since 'errno' is not yet available and if the
  404. operation can cause a failure 'errno' must not be touched. */
  405. # define TLS_INIT_TP(tcbp) \
  406. - ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); NULL; })
  407. + ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); true; })
  408. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1
  409. diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
  410. index 95a69cb8249..e8fbe40e7bb 100644
  411. --- a/sysdeps/sparc/nptl/tls.h
  412. +++ b/sysdeps/sparc/nptl/tls.h
  413. @@ -89,7 +89,7 @@ register struct pthread *__thread_self __asm__("%g7");
  414. /* Code to initially initialize the thread pointer. */
  415. # define TLS_INIT_TP(descr) \
  416. - (__thread_self = (__typeof (__thread_self)) (descr), NULL)
  417. + (__thread_self = (__typeof (__thread_self)) (descr), true)
  418. /* Value passed to 'clone' for initialization of the thread register. */
  419. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd)
  420. diff --git a/sysdeps/unix/sysv/linux/arm/tls.h b/sysdeps/unix/sysv/linux/arm/tls.h
  421. index 9d1601af44c..045fad22751 100644
  422. --- a/sysdeps/unix/sysv/linux/arm/tls.h
  423. +++ b/sysdeps/unix/sysv/linux/arm/tls.h
  424. @@ -33,8 +33,7 @@
  425. # define TLS_INIT_TP(tcbp) \
  426. ({ long int result_var; \
  427. result_var = INTERNAL_SYSCALL_CALL (set_tls, (tcbp)); \
  428. - INTERNAL_SYSCALL_ERROR_P (result_var) \
  429. - ? "unknown error" : NULL; })
  430. + !INTERNAL_SYSCALL_ERROR_P (result_var); })
  431. #endif /* __ASSEMBLER__ */
  432. diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
  433. index 75f80209758..63744f63845 100644
  434. --- a/sysdeps/x86_64/nptl/tls.h
  435. +++ b/sysdeps/x86_64/nptl/tls.h
  436. @@ -156,7 +156,7 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
  437. "S" (_thrdescr) \
  438. : "memory", "cc", "r11", "cx"); \
  439. \
  440. - _result ? "cannot set %fs base address for thread-local storage" : 0; \
  441. + _result == 0; \
  442. })
  443. # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd)