1 /* Thread-local storage handling in the ELF dynamic linker. Generic version.
2 Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 #include <sys/param.h>
32 /* Amount of excess space to allocate in the static TLS area
33 to allow dynamic loading of modules defining IE-model TLS data. */
34 #define TLS_STATIC_SURPLUS 64 + DL_NNS * 100
36 /* Value used for dtv entries for which the allocation is delayed. */
37 #define TLS_DTV_UNALLOCATED ((void *) -1l)
40 /* Out-of-memory handler. */
43 __attribute__ ((__noreturn__
))
46 _dl_fatal_printf ("cannot allocate memory for thread-local data: ABORT\n");
53 _dl_next_tls_modid (void)
57 if (__builtin_expect (GL(dl_tls_dtv_gaps
), false))
60 struct dtv_slotinfo_list
*runp
= GL(dl_tls_dtv_slotinfo_list
);
62 /* Note that this branch will never be executed during program
63 start since there are no gaps at that time. Therefore it
64 does not matter that the dl_tls_dtv_slotinfo is not allocated
65 yet when the function is called for the first times.
67 NB: the offset +1 is due to the fact that DTV[0] is used
68 for something else. */
69 result
= GL(dl_tls_static_nelem
) + 1;
70 if (result
<= GL(dl_tls_max_dtv_idx
))
73 while (result
- disp
< runp
->len
)
75 if (runp
->slotinfo
[result
- disp
].map
== NULL
)
79 assert (result
<= GL(dl_tls_max_dtv_idx
) + 1);
82 if (result
- disp
< runp
->len
)
87 while ((runp
= runp
->next
) != NULL
);
89 if (result
> GL(dl_tls_max_dtv_idx
))
91 /* The new index must indeed be exactly one higher than the
93 assert (result
== GL(dl_tls_max_dtv_idx
) + 1);
94 /* There is no gap anymore. */
95 GL(dl_tls_dtv_gaps
) = false;
102 /* No gaps, allocate a new entry. */
105 result
= ++GL(dl_tls_max_dtv_idx
);
115 _dl_determine_tlsoffset (void)
117 size_t max_align
= TLS_TCB_ALIGN
;
119 size_t freebottom
= 0;
121 /* The first element of the dtv slot info list is allocated. */
122 assert (GL(dl_tls_dtv_slotinfo_list
) != NULL
);
123 /* There is at this point only one element in the
124 dl_tls_dtv_slotinfo_list list. */
125 assert (GL(dl_tls_dtv_slotinfo_list
)->next
== NULL
);
127 struct dtv_slotinfo
*slotinfo
= GL(dl_tls_dtv_slotinfo_list
)->slotinfo
;
129 /* Determining the offset of the various parts of the static TLS
130 block has several dependencies. In addition we have to work
131 around bugs in some toolchains.
133 Each TLS block from the objects available at link time has a size
134 and an alignment requirement. The GNU ld computes the alignment
135 requirements for the data at the positions *in the file*, though.
136 I.e, it is not simply possible to allocate a block with the size
137 of the TLS program header entry. The data is layed out assuming
138 that the first byte of the TLS block fulfills
140 p_vaddr mod p_align == &TLS_BLOCK mod p_align
142 This means we have to add artificial padding at the beginning of
143 the TLS block. These bytes are never used for the TLS data in
144 this module but the first byte allocated must be aligned
145 according to mod p_align == 0 so that the first byte of the TLS
146 block is aligned according to p_vaddr mod p_align. This is ugly
147 and the linker can help by computing the offsets in the TLS block
148 assuming the first byte of the TLS block is aligned according to
151 The extra space which might be allocated before the first byte of
152 the TLS block need not go unused. The code below tries to use
153 that memory for the next TLS block. This can work if the total
154 memory requirement for the next TLS block is smaller than the
158 /* We simply start with zero. */
161 for (size_t cnt
= 0; slotinfo
[cnt
].map
!= NULL
; ++cnt
)
163 assert (cnt
< GL(dl_tls_dtv_slotinfo_list
)->len
);
165 size_t firstbyte
= (-slotinfo
[cnt
].map
->l_tls_firstbyte_offset
166 & (slotinfo
[cnt
].map
->l_tls_align
- 1));
168 max_align
= MAX (max_align
, slotinfo
[cnt
].map
->l_tls_align
);
170 if (freebottom
- freetop
>= slotinfo
[cnt
].map
->l_tls_blocksize
)
172 off
= roundup (freetop
+ slotinfo
[cnt
].map
->l_tls_blocksize
173 - firstbyte
, slotinfo
[cnt
].map
->l_tls_align
)
175 if (off
<= freebottom
)
179 /* XXX For some architectures we perhaps should store the
181 slotinfo
[cnt
].map
->l_tls_offset
= off
;
186 off
= roundup (offset
+ slotinfo
[cnt
].map
->l_tls_blocksize
- firstbyte
,
187 slotinfo
[cnt
].map
->l_tls_align
) + firstbyte
;
188 if (off
> offset
+ slotinfo
[cnt
].map
->l_tls_blocksize
189 + (freebottom
- freetop
))
192 freebottom
= off
- slotinfo
[cnt
].map
->l_tls_blocksize
;
196 /* XXX For some architectures we perhaps should store the
198 slotinfo
[cnt
].map
->l_tls_offset
= off
;
201 GL(dl_tls_static_used
) = offset
;
202 GL(dl_tls_static_size
) = (roundup (offset
+ TLS_STATIC_SURPLUS
, max_align
)
205 /* The TLS blocks start right after the TCB. */
206 size_t offset
= TLS_TCB_SIZE
;
208 for (size_t cnt
= 0; slotinfo
[cnt
].map
!= NULL
; ++cnt
)
210 assert (cnt
< GL(dl_tls_dtv_slotinfo_list
)->len
);
212 size_t firstbyte
= (-slotinfo
[cnt
].map
->l_tls_firstbyte_offset
213 & (slotinfo
[cnt
].map
->l_tls_align
- 1));
215 max_align
= MAX (max_align
, slotinfo
[cnt
].map
->l_tls_align
);
217 if (slotinfo
[cnt
].map
->l_tls_blocksize
<= freetop
- freebottom
)
219 off
= roundup (freebottom
, slotinfo
[cnt
].map
->l_tls_align
);
220 if (off
- freebottom
< firstbyte
)
221 off
+= slotinfo
[cnt
].map
->l_tls_align
;
222 if (off
+ slotinfo
[cnt
].map
->l_tls_blocksize
- firstbyte
<= freetop
)
224 slotinfo
[cnt
].map
->l_tls_offset
= off
- firstbyte
;
225 freebottom
= (off
+ slotinfo
[cnt
].map
->l_tls_blocksize
231 off
= roundup (offset
, slotinfo
[cnt
].map
->l_tls_align
);
232 if (off
- offset
< firstbyte
)
233 off
+= slotinfo
[cnt
].map
->l_tls_align
;
235 slotinfo
[cnt
].map
->l_tls_offset
= off
- firstbyte
;
236 if (off
- firstbyte
- offset
> freetop
- freebottom
)
239 freetop
= off
- firstbyte
;
242 offset
= off
+ slotinfo
[cnt
].map
->l_tls_blocksize
- firstbyte
;
245 GL(dl_tls_static_used
) = offset
;
246 GL(dl_tls_static_size
) = roundup (offset
+ TLS_STATIC_SURPLUS
,
249 # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
252 /* The alignment requirement for the static TLS block. */
253 GL(dl_tls_static_align
) = max_align
;
257 /* This is called only when the data structure setup was skipped at startup,
258 when there was no need for it then. Now we have dynamically loaded
259 something needing TLS, or libpthread needs it. */
264 assert (GL(dl_tls_dtv_slotinfo_list
) == NULL
);
265 assert (GL(dl_tls_max_dtv_idx
) == 0);
267 const size_t nelem
= 2 + TLS_SLOTINFO_SURPLUS
;
269 GL(dl_tls_dtv_slotinfo_list
)
270 = calloc (1, (sizeof (struct dtv_slotinfo_list
)
271 + nelem
* sizeof (struct dtv_slotinfo
)));
272 if (GL(dl_tls_dtv_slotinfo_list
) == NULL
)
275 GL(dl_tls_dtv_slotinfo_list
)->len
= nelem
;
277 /* Number of elements in the static TLS block. It can't be zero
278 because of various assumptions. The one element is null. */
279 GL(dl_tls_static_nelem
) = GL(dl_tls_max_dtv_idx
) = 1;
281 /* This initializes more variables for us. */
282 _dl_determine_tlsoffset ();
286 rtld_hidden_def (_dl_tls_setup
)
291 allocate_dtv (void *result
)
296 /* We allocate a few more elements in the dtv than are needed for the
297 initial set of modules. This should avoid in most cases expansions
299 dtv_length
= GL(dl_tls_max_dtv_idx
) + DTV_SURPLUS
;
300 dtv
= calloc (dtv_length
+ 2, sizeof (dtv_t
));
303 /* This is the initial length of the dtv. */
304 dtv
[0].counter
= dtv_length
;
306 /* The rest of the dtv (including the generation counter) is
307 Initialize with zero to indicate nothing there. */
309 /* Add the dtv to the thread data structures. */
310 INSTALL_DTV (result
, dtv
);
319 /* Get size and alignment requirements of the static TLS block. */
322 _dl_get_tls_static_info (size_t *sizep
, size_t *alignp
)
324 *sizep
= GL(dl_tls_static_size
);
325 *alignp
= GL(dl_tls_static_align
);
331 _dl_allocate_tls_storage (void)
334 size_t size
= GL(dl_tls_static_size
);
338 [ TLS_PRE_TCB_SIZE ] [ TLS_TCB_SIZE ] [ TLS blocks ]
339 ^ This should be returned. */
340 size
+= (TLS_PRE_TCB_SIZE
+ GL(dl_tls_static_align
) - 1)
341 & ~(GL(dl_tls_static_align
) - 1);
344 /* Allocate a correctly aligned chunk of memory. */
345 result
= __libc_memalign (GL(dl_tls_static_align
), size
);
346 if (__builtin_expect (result
!= NULL
, 1))
348 /* Allocate the DTV. */
349 void *allocated
= result
;
352 /* The TCB follows the TLS blocks. */
353 result
= (char *) result
+ size
- TLS_TCB_SIZE
;
355 /* Clear the TCB data structure. We can't ask the caller (i.e.
356 libpthread) to do it, because we will initialize the DTV et al. */
357 memset (result
, '\0', TLS_TCB_SIZE
);
359 result
= (char *) result
+ size
- GL(dl_tls_static_size
);
361 /* Clear the TCB data structure and TLS_PRE_TCB_SIZE bytes before it.
362 We can't ask the caller (i.e. libpthread) to do it, because we will
363 initialize the DTV et al. */
364 memset ((char *) result
- TLS_PRE_TCB_SIZE
, '\0',
365 TLS_PRE_TCB_SIZE
+ TLS_TCB_SIZE
);
368 result
= allocate_dtv (result
);
379 _dl_allocate_tls_init (void *result
)
382 /* The memory allocation failed. */
385 dtv_t
*dtv
= GET_DTV (result
);
386 struct dtv_slotinfo_list
*listp
;
390 /* We have to prepare the dtv for all currently loaded modules using
391 TLS. For those which are dynamically loaded we add the values
392 indicating deferred allocation. */
393 listp
= GL(dl_tls_dtv_slotinfo_list
);
398 for (cnt
= total
== 0 ? 1 : 0; cnt
< listp
->len
; ++cnt
)
400 struct link_map
*map
;
403 /* Check for the total number of used slots. */
404 if (total
+ cnt
> GL(dl_tls_max_dtv_idx
))
407 map
= listp
->slotinfo
[cnt
].map
;
412 /* Keep track of the maximum generation number. This might
413 not be the generation counter. */
414 maxgen
= MAX (maxgen
, listp
->slotinfo
[cnt
].gen
);
416 if (map
->l_tls_offset
== NO_TLS_OFFSET
)
418 /* For dynamically loaded modules we simply store
419 the value indicating deferred allocation. */
420 dtv
[map
->l_tls_modid
].pointer
.val
= TLS_DTV_UNALLOCATED
;
421 dtv
[map
->l_tls_modid
].pointer
.is_static
= false;
425 assert (map
->l_tls_modid
== cnt
);
426 assert (map
->l_tls_blocksize
>= map
->l_tls_initimage_size
);
428 assert ((size_t) map
->l_tls_offset
>= map
->l_tls_blocksize
);
429 dest
= (char *) result
- map
->l_tls_offset
;
431 dest
= (char *) result
+ map
->l_tls_offset
;
433 # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
436 /* Copy the initialization image and clear the BSS part. */
437 dtv
[map
->l_tls_modid
].pointer
.val
= dest
;
438 dtv
[map
->l_tls_modid
].pointer
.is_static
= true;
439 memset (__mempcpy (dest
, map
->l_tls_initimage
,
440 map
->l_tls_initimage_size
), '\0',
441 map
->l_tls_blocksize
- map
->l_tls_initimage_size
);
445 if (total
>= GL(dl_tls_max_dtv_idx
))
449 assert (listp
!= NULL
);
452 /* The DTV version is up-to-date now. */
453 dtv
[0].counter
= maxgen
;
457 rtld_hidden_def (_dl_allocate_tls_init
)
461 _dl_allocate_tls (void *mem
)
463 return _dl_allocate_tls_init (mem
== NULL
464 ? _dl_allocate_tls_storage ()
465 : allocate_dtv (mem
));
467 rtld_hidden_def (_dl_allocate_tls
)
472 _dl_deallocate_tls (void *tcb
, bool dealloc_tcb
)
474 dtv_t
*dtv
= GET_DTV (tcb
);
476 /* We need to free the memory allocated for non-static TLS. */
477 for (size_t cnt
= 0; cnt
< dtv
[-1].counter
; ++cnt
)
478 if (! dtv
[1 + cnt
].pointer
.is_static
479 && dtv
[1 + cnt
].pointer
.val
!= TLS_DTV_UNALLOCATED
)
480 free (dtv
[1 + cnt
].pointer
.val
);
482 /* The array starts with dtv[-1]. */
484 if (dtv
!= GL(dl_initial_dtv
))
491 /* The TCB follows the TLS blocks. Back up to free the whole block. */
492 tcb
-= GL(dl_tls_static_size
) - TLS_TCB_SIZE
;
494 /* Back up the TLS_PRE_TCB_SIZE bytes. */
495 tcb
-= (TLS_PRE_TCB_SIZE
+ GL(dl_tls_static_align
) - 1)
496 & ~(GL(dl_tls_static_align
) - 1);
501 rtld_hidden_def (_dl_deallocate_tls
)
505 /* The __tls_get_addr function has two basic forms which differ in the
506 arguments. The IA-64 form takes two parameters, the module ID and
507 offset. The form used, among others, on IA-32 takes a reference to
508 a special structure which contain the same information. The second
509 form seems to be more often used (in the moment) so we default to
510 it. Users of the IA-64 form have to provide adequate definitions
511 of the following macros. */
512 # ifndef GET_ADDR_ARGS
513 # define GET_ADDR_ARGS tls_index *ti
515 # ifndef GET_ADDR_MODULE
516 # define GET_ADDR_MODULE ti->ti_module
518 # ifndef GET_ADDR_OFFSET
519 # define GET_ADDR_OFFSET ti->ti_offset
524 allocate_and_init (struct link_map
*map
)
528 newp
= __libc_memalign (map
->l_tls_align
, map
->l_tls_blocksize
);
532 /* Initialize the memory. */
533 memset (__mempcpy (newp
, map
->l_tls_initimage
, map
->l_tls_initimage_size
),
534 '\0', map
->l_tls_blocksize
- map
->l_tls_initimage_size
);
541 _dl_update_slotinfo (unsigned long int req_modid
)
543 struct link_map
*the_map
= NULL
;
544 dtv_t
*dtv
= THREAD_DTV ();
546 /* The global dl_tls_dtv_slotinfo array contains for each module
547 index the generation counter current when the entry was created.
548 This array never shrinks so that all module indices which were
549 valid at some time can be used to access it. Before the first
550 use of a new module index in this function the array was extended
551 appropriately. Access also does not have to be guarded against
552 modifications of the array. It is assumed that pointer-size
553 values can be read atomically even in SMP environments. It is
554 possible that other threads at the same time dynamically load
555 code and therefore add to the slotinfo list. This is a problem
556 since we must not pick up any information about incomplete work.
557 The solution to this is to ignore all dtv slots which were
558 created after the one we are currently interested. We know that
559 dynamic loading for this module is completed and this is the last
560 load operation we know finished. */
561 unsigned long int idx
= req_modid
;
562 struct dtv_slotinfo_list
*listp
= GL(dl_tls_dtv_slotinfo_list
);
564 while (idx
>= listp
->len
)
570 if (dtv
[0].counter
< listp
->slotinfo
[idx
].gen
)
572 /* The generation counter for the slot is higher than what the
573 current dtv implements. We have to update the whole dtv but
574 only those entries with a generation counter <= the one for
575 the entry we need. */
576 size_t new_gen
= listp
->slotinfo
[idx
].gen
;
579 /* We have to look through the entire dtv slotinfo list. */
580 listp
= GL(dl_tls_dtv_slotinfo_list
);
583 for (size_t cnt
= total
== 0 ? 1 : 0; cnt
< listp
->len
; ++cnt
)
585 size_t gen
= listp
->slotinfo
[cnt
].gen
;
588 /* This is a slot for a generation younger than the
589 one we are handling now. It might be incompletely
590 set up so ignore it. */
593 /* If the entry is older than the current dtv layout we
594 know we don't have to handle it. */
595 if (gen
<= dtv
[0].counter
)
598 /* If there is no map this means the entry is empty. */
599 struct link_map
*map
= listp
->slotinfo
[cnt
].map
;
602 /* If this modid was used at some point the memory
603 might still be allocated. */
604 if (! dtv
[total
+ cnt
].pointer
.is_static
605 && dtv
[total
+ cnt
].pointer
.val
!= TLS_DTV_UNALLOCATED
)
607 free (dtv
[total
+ cnt
].pointer
.val
);
608 dtv
[total
+ cnt
].pointer
.val
= TLS_DTV_UNALLOCATED
;
614 /* Check whether the current dtv array is large enough. */
615 size_t modid
= map
->l_tls_modid
;
616 assert (total
+ cnt
== modid
);
617 if (dtv
[-1].counter
< modid
)
619 /* Reallocate the dtv. */
621 size_t newsize
= GL(dl_tls_max_dtv_idx
) + DTV_SURPLUS
;
622 size_t oldsize
= dtv
[-1].counter
;
624 assert (map
->l_tls_modid
<= newsize
);
626 if (dtv
== GL(dl_initial_dtv
))
628 /* This is the initial dtv that was allocated
629 during rtld startup using the dl-minimal.c
630 malloc instead of the real malloc. We can't
631 free it, we have to abandon the old storage. */
633 newp
= malloc ((2 + newsize
) * sizeof (dtv_t
));
636 memcpy (newp
, &dtv
[-1], oldsize
* sizeof (dtv_t
));
640 newp
= realloc (&dtv
[-1],
641 (2 + newsize
) * sizeof (dtv_t
));
646 newp
[0].counter
= newsize
;
648 /* Clear the newly allocated part. */
649 memset (newp
+ 2 + oldsize
, '\0',
650 (newsize
- oldsize
) * sizeof (dtv_t
));
652 /* Point dtv to the generation counter. */
655 /* Install this new dtv in the thread data
657 INSTALL_NEW_DTV (dtv
);
660 /* If there is currently memory allocate for this
661 dtv entry free it. */
662 /* XXX Ideally we will at some point create a memory
664 if (! dtv
[modid
].pointer
.is_static
665 && dtv
[modid
].pointer
.val
!= TLS_DTV_UNALLOCATED
)
666 /* Note that free is called for NULL is well. We
667 deallocate even if it is this dtv entry we are
668 supposed to load. The reason is that we call
669 memalign and not malloc. */
670 free (dtv
[modid
].pointer
.val
);
672 /* This module is loaded dynamically- We defer memory
674 dtv
[modid
].pointer
.is_static
= false;
675 dtv
[modid
].pointer
.val
= TLS_DTV_UNALLOCATED
;
677 if (modid
== req_modid
)
683 while ((listp
= listp
->next
) != NULL
);
685 /* This will be the new maximum generation counter. */
686 dtv
[0].counter
= new_gen
;
693 /* The generic dynamic and local dynamic model cannot be used in
694 statically linked applications. */
696 __tls_get_addr (GET_ADDR_ARGS
)
698 dtv_t
*dtv
= THREAD_DTV ();
699 struct link_map
*the_map
= NULL
;
702 if (__builtin_expect (dtv
[0].counter
!= GL(dl_tls_generation
), 0))
703 the_map
= _dl_update_slotinfo (GET_ADDR_MODULE
);
705 p
= dtv
[GET_ADDR_MODULE
].pointer
.val
;
707 if (__builtin_expect (p
== TLS_DTV_UNALLOCATED
, 0))
709 /* The allocation was deferred. Do it now. */
712 /* Find the link map for this module. */
713 size_t idx
= GET_ADDR_MODULE
;
714 struct dtv_slotinfo_list
*listp
= GL(dl_tls_dtv_slotinfo_list
);
716 while (idx
>= listp
->len
)
722 the_map
= listp
->slotinfo
[idx
].map
;
725 p
= dtv
[GET_ADDR_MODULE
].pointer
.val
= allocate_and_init (the_map
);
726 dtv
[GET_ADDR_MODULE
].pointer
.is_static
= false;
729 return (char *) p
+ GET_ADDR_OFFSET
;
734 /* Look up the module's TLS block as for __tls_get_addr,
735 but never touch anything. Return null if it's not allocated yet. */
738 _dl_tls_get_addr_soft (struct link_map
*l
)
740 if (__builtin_expect (l
->l_tls_modid
== 0, 0))
741 /* This module has no TLS segment. */
744 dtv_t
*dtv
= THREAD_DTV ();
745 if (__builtin_expect (dtv
[0].counter
!= GL(dl_tls_generation
), 0))
747 /* This thread's DTV is not completely current,
748 but it might already cover this module. */
750 if (l
->l_tls_modid
>= dtv
[-1].counter
)
754 size_t idx
= l
->l_tls_modid
;
755 struct dtv_slotinfo_list
*listp
= GL(dl_tls_dtv_slotinfo_list
);
756 while (idx
>= listp
->len
)
762 /* We've reached the slot for this module.
763 If its generation counter is higher than the DTV's,
764 this thread does not know about this module yet. */
765 if (dtv
[0].counter
< listp
->slotinfo
[idx
].gen
)
769 void *data
= dtv
[l
->l_tls_modid
].pointer
.val
;
770 if (__builtin_expect (data
== TLS_DTV_UNALLOCATED
, 0))
771 /* The DTV is current, but this thread has not yet needed
772 to allocate this module's segment. */
780 _dl_add_to_slotinfo (struct link_map
*l
)
782 /* Now that we know the object is loaded successfully add
783 modules containing TLS data to the dtv info table. We
784 might have to increase its size. */
785 struct dtv_slotinfo_list
*listp
;
786 struct dtv_slotinfo_list
*prevp
;
787 size_t idx
= l
->l_tls_modid
;
789 /* Find the place in the dtv slotinfo list. */
790 listp
= GL(dl_tls_dtv_slotinfo_list
);
791 prevp
= NULL
; /* Needed to shut up gcc. */
794 /* Does it fit in the array of this list element? */
795 if (idx
< listp
->len
)
801 while (listp
!= NULL
);
805 /* When we come here it means we have to add a new element
806 to the slotinfo list. And the new module must be in
810 listp
= prevp
->next
= (struct dtv_slotinfo_list
*)
811 malloc (sizeof (struct dtv_slotinfo_list
)
812 + TLS_SLOTINFO_SURPLUS
* sizeof (struct dtv_slotinfo
));
815 /* We ran out of memory. We will simply fail this
816 call but don't undo anything we did so far. The
817 application will crash or be terminated anyway very
820 /* We have to do this since some entries in the dtv
821 slotinfo array might already point to this
823 ++GL(dl_tls_generation
);
825 _dl_signal_error (ENOMEM
, "dlopen", NULL
, N_("\
826 cannot create TLS data structures"));
829 listp
->len
= TLS_SLOTINFO_SURPLUS
;
831 memset (listp
->slotinfo
, '\0',
832 TLS_SLOTINFO_SURPLUS
* sizeof (struct dtv_slotinfo
));
835 /* Add the information into the slotinfo data structure. */
836 listp
->slotinfo
[idx
].map
= l
;
837 listp
->slotinfo
[idx
].gen
= GL(dl_tls_generation
) + 1;