tls.c revision 5aefb6555731130ca4fd295960123d71f2d21fe8
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#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>
static void (* fptr_tls_modadd)(TLS_modinfo *) = 0;
static void (* fptr_tls_modrem)(TLS_modinfo *) = 0;
static void (* fptr_tls_statmods)(TLS_modinfo **, unsigned long) = 0;
static int tlsinitialized = 0;
static unsigned long tls_static_size = 0; /* static TLS buffer size */
/* at a time. */
typedef struct {
} Tlsmodid;
unsigned long
{
ulong_t i;
return ((unsigned long)-1);
return (0);
}
uint_t j;
/*
* If all bits are assigned - move on.
*/
continue;
return (ndx);
}
}
}
/*
* All bits taken - must allocate a new block
*/
(TLSBLOCKCNT * sizeof (uint_t))))) == 0)
return ((unsigned long)-1);
/*
* clear out the tail of the new allocation
*/
return (ndx);
}
void
tls_freemodid(unsigned long modid)
{
ulong_t i;
uint_t j;
/* LINTED */
j = ~(1 << j);
}
void
{
/*
* of the TLS interfaces - it's confused and we discard
* the whole lot.
*/
return;
/*
* The 'statmods' interface is only relevent for the
* primary link-map - ignore all other instances.
*/
(void(*)(TLS_modinfo **, unsigned long)) statmod;
}
void
{
void (* fptr)(TLS_modinfo *);
if (flag & TM_FLG_MODADD)
else
/*
* We only report TLS modactivity for the primary link-map
* after all the objects have been loaded and we've reported
* the STATIC tls modlist (see tls_report_modules()).
*/
if (((tlsinitialized == 0) &&
return;
tmi.tm_stattlsoffset = 0;
/*
* Free up the moduleid
*/
if (flag & TM_FLG_MODREM)
}
void
{
return;
/*
* Only objects on the primary link-map list are associated
* with the STATIC tls block.
*/
}
/*
* Everyone get's a dynamic TLS modid
*/
}
int
{
/*
* Scan through all objects to determine how many have TLS storage.
*/
tlsmodcnt = 0;
continue;
tlsmodcnt++;
if (fptr_tls_statmods)
continue;
/*
* If a module has TLS - but the TLS interfaces are not present
* (no libthread?). Then this is a fatal condition.
*/
return (0);
}
/*
* If we don't have any TLS modules - report that and return.
*/
if (tlsmodcnt == 0) {
if (fptr_tls_statmods != 0)
fptr_tls_statmods(0, 0);
return (1);
}
/*
* 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.
*/
return (0);
/*
* Account for the initial dtv ptr in the TLSSIZE calculation.
*/
tlsmodndx = 0;
continue;
(void *)((uintptr_t)tlsmodlist[
tlsmodndx++;
}
/*
* We're done with the list - clean it up.
*/
return (1);
}