258 uint_t tlsmodndx, tlsmodcnt = lml->lm_tls;
259 TLS_modinfo **tlsmodlist, *tlsbuflist;
260 Phdr *tlsphdr;
261 int (*fptr)(TLS_modinfo **, ulong_t);
262
263 fptr = lml->lm_lcs[CI_TLS_STATMOD].lc_un.lc_func;
264
265 /*
266 * Allocate a buffer to report the TLS modules, the buffer consists of:
267 *
268 * TLS_modinfo * ptrs[tlsmodcnt + 1]
269 * TLS_modinfo bufs[tlsmodcnt]
270 *
271 * The ptrs are initialized to the bufs - except the last one which
272 * null terminates the array.
273 *
274 * Note, even if no TLS has yet been observed, we still supply a
275 * TLS buffer with a single null entry. This allows us to initialize
276 * the backup TLS reservation.
277 */
278 if ((tlsmodlist = calloc((sizeof (TLS_modinfo *) * (tlsmodcnt + 1)) +
279 (sizeof (TLS_modinfo) * tlsmodcnt), 1)) == NULL)
280 return (0);
281
282 lml->lm_tls = 0;
283
284 /*
285 * If we don't have any TLS modules - report that and return.
286 */
287 if (tlsmodcnt == 0) {
288 if (fptr != NULL)
289 (void) (*fptr)(tlsmodlist, tls_static_resv);
290 DBG_CALL(Dbg_tls_static_block(&lml_main, 0, 0,
291 tls_static_resv));
292 return (1);
293 }
294
295 /*
296 * Initialize the TLS buffer.
297 */
298 tlsbuflist = (TLS_modinfo *)((uintptr_t)tlsmodlist +
299 ((tlsmodcnt + 1) * sizeof (TLS_modinfo *)));
|
258 uint_t tlsmodndx, tlsmodcnt = lml->lm_tls;
259 TLS_modinfo **tlsmodlist, *tlsbuflist;
260 Phdr *tlsphdr;
261 int (*fptr)(TLS_modinfo **, ulong_t);
262
263 fptr = lml->lm_lcs[CI_TLS_STATMOD].lc_un.lc_func;
264
265 /*
266 * Allocate a buffer to report the TLS modules, the buffer consists of:
267 *
268 * TLS_modinfo * ptrs[tlsmodcnt + 1]
269 * TLS_modinfo bufs[tlsmodcnt]
270 *
271 * The ptrs are initialized to the bufs - except the last one which
272 * null terminates the array.
273 *
274 * Note, even if no TLS has yet been observed, we still supply a
275 * TLS buffer with a single null entry. This allows us to initialize
276 * the backup TLS reservation.
277 */
278 if ((tlsmodlist = calloc(1, (sizeof (TLS_modinfo *) * (tlsmodcnt + 1)) +
279 (sizeof (TLS_modinfo) * tlsmodcnt))) == NULL)
280 return (0);
281
282 lml->lm_tls = 0;
283
284 /*
285 * If we don't have any TLS modules - report that and return.
286 */
287 if (tlsmodcnt == 0) {
288 if (fptr != NULL)
289 (void) (*fptr)(tlsmodlist, tls_static_resv);
290 DBG_CALL(Dbg_tls_static_block(&lml_main, 0, 0,
291 tls_static_resv));
292 return (1);
293 }
294
295 /*
296 * Initialize the TLS buffer.
297 */
298 tlsbuflist = (TLS_modinfo *)((uintptr_t)tlsmodlist +
299 ((tlsmodcnt + 1) * sizeof (TLS_modinfo *)));
|