/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <strings.h>
#include <dlfcn.h>
#include <libc_int.h>
#include <_rtld.h>
#include <_elf.h>
#include <msg.h>
#include <debug.h>
/* at a time. */
typedef struct {
} Tlsmodid;
static ulong_t
{
return ((ulong_t)-1);
return (0);
}
/*
* If all bits are assigned - move on.
*/
continue;
return (ndx);
}
}
}
/*
* All bits taken - must allocate a new block
*/
return ((ulong_t)-1);
/*
* Clear out the tail of the new allocation.
*/
return (ndx);
}
void
{
ulong_t i;
uint_t j;
/* LINTED */
j = ~(1 << j);
}
void
{
void (*fptr)(TLS_modinfo *);
if (flag & TM_FLG_MODADD) {
} else {
return;
}
tmi.tm_stattlsoffset = 0;
/*
* Tag that this link-map has registered its TLS, and, if this object
* is being removed, free up the module id.
*/
if (flag & TM_FLG_MODREM)
}
/*
* Track any static TLS use, retain the TLS header, and assign a TLS module
* identifier.
*/
int
{
/*
* If this object explicitly references static TLS, then there are some
* limitations.
*/
/*
* Static TLS is only available to objects on the primary
* link-map list.
*/
((rtld_flags2 & RT_FL2_NOPLM) != 0)) {
return (0);
}
/*
* All TLS blocks that are processed before thread
* initialization, are registered with libc. This
* initialization is carried out through a handshake with libc
* prior to executing any user code (ie. before the first .init
* sections are called). As part of this initialization, a
* small backup TLS reservation is added (tls_static_resv).
* Only explicit static TLS references that can be satisfied by
* this TLS backup reservation can be satisfied.
*/
if (rtld_flags2 & RT_FL2_PLMSETUP) {
/*
* Initialized static TLS can not be satisfied from the
* TLS backup reservation.
*/
if (filesz) {
return (0);
}
/*
* Make sure the backup reservation is sufficient.
*/
if (memsz > tls_static_resv) {
return (0);
}
tls_static_resv -= memsz;
}
}
/*
* If we haven't yet initialized threads, or this static reservation can
* be satisfied from the TLS backup reservation, determine the total
* static TLS size, and assign this object a static TLS offset.
*/
if (((rtld_flags2 & RT_FL2_PLMSETUP) == 0) ||
tls_static_size += memsz;
}
/*
* Retain the PT_TLS header, obtain a new module identifier, and
* indicate that this link-map list contains a new TLS object.
*/
/*
* Now that we have a TLS module id, generate any static TLS reservation
* diagnostic.
*/
if (resv != tls_static_resv)
}
int
{
/*
* Allocate a buffer to report the TLS modules, the buffer consists of:
*
* TLS_modinfo * ptrs[tlsmodcnt + 1]
* TLS_modinfo bufs[tlsmodcnt]
*
* The ptrs are initialized to the bufs - except the last one which
* null terminates the array.
*
* Note, even if no TLS has yet been observed, we still supply a
* TLS buffer with a single null entry. This allows us to initialize
* the backup TLS reservation.
*/
return (0);
/*
* If we don't have any TLS modules - report that and return.
*/
if (tlsmodcnt == 0) {
if (fptr)
return (1);
}
/*
* Initialize the TLS buffer.
*/
/*
* Account for the initial dtv ptr in the TLSSIZE calculation.
*/
tlsmodndx = 0;
if (THIS_IS_NOT_ELF(lmp) ||
continue;
}
tlsmodndx++;
}
/*
* We're done with the list - clean it up.
*/
return (1);
}