108 { RECURSIVEMUTEX, NULL }, /* quickexit_root */
109 { DEFAULTMUTEX, 0, 0, NULL }, /* tsd_metadata */
110 { DEFAULTMUTEX, {0, 0}, {0, 0} }, /* tls_metadata */
111 0, /* primary_map */
112 0, /* bucket_init */
113 0, /* pad[0] */
114 0, /* pad[1] */
115 { 0 }, /* uberflags */
116 NULL, /* queue_head */
117 init_hash_table, /* thr_hash_table */
118 1, /* hash_size: size of the hash table */
119 0, /* hash_mask: hash_size - 1 */
120 NULL, /* ulwp_one */
121 NULL, /* all_lwps */
122 NULL, /* all_zombies */
123 0, /* nthreads */
124 0, /* nzombies */
125 0, /* ndaemons */
126 0, /* pid */
127 sigacthandler, /* sigacthandler */
128 NULL, /* lwp_stacks */
129 NULL, /* lwp_laststack */
130 0, /* nfreestack */
131 10, /* thread_stack_cache */
132 NULL, /* ulwp_freelist */
133 NULL, /* ulwp_lastfree */
134 NULL, /* ulwp_replace_free */
135 NULL, /* ulwp_replace_last */
136 NULL, /* atforklist */
137 NULL, /* robustlocks */
138 NULL, /* robustlist */
139 NULL, /* progname */
140 NULL, /* __tdb_bootstrap */
141 { /* tdb */
142 NULL, /* tdb_sync_addr_hash */
143 0, /* tdb_register_count */
144 0, /* tdb_hash_alloc_failed */
145 NULL, /* tdb_sync_addr_free */
146 NULL, /* tdb_sync_addr_last */
147 0, /* tdb_sync_alloc */
148 { 0, 0 }, /* tdb_ev_global_mask */
149 tdb_events, /* tdb_events array */
150 },
151 };
152
153 /*
154 * The weak version is known to libc_db and mdb.
155 */
156 #pragma weak _tdb_bootstrap = __tdb_bootstrap
157 uberdata_t **__tdb_bootstrap = NULL;
158
159 int thread_queue_fifo = 4;
1203 }
1204 }
1205
1206 /* PROBE_SUPPORT begin */
1207 #pragma weak __tnf_probe_notify
1208 extern void __tnf_probe_notify(void);
1209 /* PROBE_SUPPORT end */
1210
1211 /* same as atexit() but private to the library */
1212 extern int _atexit(void (*)(void));
1213
1214 /* same as _cleanup() but private to the library */
1215 extern void __cleanup(void);
1216
1217 extern void atfork_init(void);
1218
1219 #ifdef __amd64
1220 extern void __proc64id(void);
1221 #endif
1222
1223 /*
1224 * libc_init() is called by ld.so.1 for library initialization.
1225 * We perform minimal initialization; enough to work with the main thread.
1226 */
1227 void
1228 libc_init(void)
1229 {
1230 uberdata_t *udp = &__uberdata;
1231 ulwp_t *oldself = __curthread();
1232 ucontext_t uc;
1233 ulwp_t *self;
1234 struct rlimit rl;
1235 caddr_t data;
1236 size_t tls_size;
1237 int setmask;
1238
1239 /*
1240 * For the initial stage of initialization, we must be careful
1241 * not to call any function that could possibly call _cerror().
1242 * For this purpose, we call only the raw system call wrappers.
1243 */
1244
1245 #ifdef __amd64
1246 /*
1247 * Gather information about cache layouts for optimized
1248 * AMD and Intel assembler strfoo() and memfoo() functions.
1249 */
1250 __proc64id();
1251 #endif
1252
1253 /*
1254 * Every libc, regardless of which link map, must register __cleanup().
1255 */
1256 (void) _atexit(__cleanup);
1257
1258 /*
1259 * We keep our uberdata on one of (a) the first alternate link map
1260 * or (b) the primary link map. We switch to the primary link map
1261 * and stay there once we see it. All intermediate link maps are
1262 * subject to being unloaded at any time.
1263 */
1264 if (oldself != NULL && (oldself->ul_primarymap || !primary_link_map)) {
1265 __tdb_bootstrap = oldself->ul_uberdata->tdb_bootstrap;
1266 mutex_setup();
1267 atfork_init(); /* every link map needs atfork() processing */
1268 init_progname();
1269 return;
1270 }
1271
1272 /*
1273 * To establish the main stack information, we have to get our context.
1274 * This is also convenient to use for getting our signal mask.
1275 */
1276 uc.uc_flags = UC_ALL;
1277 (void) __getcontext(&uc);
1278 ASSERT(uc.uc_link == NULL);
|
108 { RECURSIVEMUTEX, NULL }, /* quickexit_root */
109 { DEFAULTMUTEX, 0, 0, NULL }, /* tsd_metadata */
110 { DEFAULTMUTEX, {0, 0}, {0, 0} }, /* tls_metadata */
111 0, /* primary_map */
112 0, /* bucket_init */
113 0, /* pad[0] */
114 0, /* pad[1] */
115 { 0 }, /* uberflags */
116 NULL, /* queue_head */
117 init_hash_table, /* thr_hash_table */
118 1, /* hash_size: size of the hash table */
119 0, /* hash_mask: hash_size - 1 */
120 NULL, /* ulwp_one */
121 NULL, /* all_lwps */
122 NULL, /* all_zombies */
123 0, /* nthreads */
124 0, /* nzombies */
125 0, /* ndaemons */
126 0, /* pid */
127 sigacthandler, /* sigacthandler */
128 __setcontext, /* setctxt */
129 NULL, /* lwp_stacks */
130 NULL, /* lwp_laststack */
131 0, /* nfreestack */
132 10, /* thread_stack_cache */
133 NULL, /* ulwp_freelist */
134 NULL, /* ulwp_lastfree */
135 NULL, /* ulwp_replace_free */
136 NULL, /* ulwp_replace_last */
137 NULL, /* atforklist */
138 NULL, /* robustlocks */
139 NULL, /* robustlist */
140 NULL, /* progname */
141 NULL, /* ub_broot */
142 NULL, /* ub_comm_page */
143 NULL, /* __tdb_bootstrap */
144 { /* tdb */
145 NULL, /* tdb_sync_addr_hash */
146 0, /* tdb_register_count */
147 0, /* tdb_hash_alloc_failed */
148 NULL, /* tdb_sync_addr_free */
149 NULL, /* tdb_sync_addr_last */
150 0, /* tdb_sync_alloc */
151 { 0, 0 }, /* tdb_ev_global_mask */
152 tdb_events, /* tdb_events array */
153 },
154 };
155
156 /*
157 * The weak version is known to libc_db and mdb.
158 */
159 #pragma weak _tdb_bootstrap = __tdb_bootstrap
160 uberdata_t **__tdb_bootstrap = NULL;
161
162 int thread_queue_fifo = 4;
1206 }
1207 }
1208
1209 /* PROBE_SUPPORT begin */
1210 #pragma weak __tnf_probe_notify
1211 extern void __tnf_probe_notify(void);
1212 /* PROBE_SUPPORT end */
1213
1214 /* same as atexit() but private to the library */
1215 extern int _atexit(void (*)(void));
1216
1217 /* same as _cleanup() but private to the library */
1218 extern void __cleanup(void);
1219
1220 extern void atfork_init(void);
1221
1222 #ifdef __amd64
1223 extern void __proc64id(void);
1224 #endif
1225
1226 static void
1227 init_auxv_data(uberdata_t *udp)
1228 {
1229 Dl_argsinfo_t args;
1230
1231 udp->ub_broot = NULL;
1232 udp->ub_comm_page = NULL;
1233 if (dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &args) < 0)
1234 return;
1235
1236 while (args.dla_auxv->a_type != AT_NULL) {
1237 switch (args.dla_auxv->a_type) {
1238 case AT_SUN_BRAND_NROOT:
1239 udp->ub_broot = args.dla_auxv->a_un.a_ptr;
1240 break;
1241 case AT_SUN_COMMPAGE:
1242 udp->ub_comm_page = args.dla_auxv->a_un.a_ptr;
1243 break;
1244 }
1245 args.dla_auxv++;
1246 }
1247 }
1248
1249 /*
1250 * libc_init() is called by ld.so.1 for library initialization.
1251 * We perform minimal initialization; enough to work with the main thread.
1252 */
1253 void
1254 libc_init(void)
1255 {
1256 uberdata_t *udp = &__uberdata;
1257 ulwp_t *oldself = __curthread();
1258 ucontext_t uc;
1259 ulwp_t *self;
1260 struct rlimit rl;
1261 caddr_t data;
1262 size_t tls_size;
1263 int setmask;
1264
1265 /*
1266 * For the initial stage of initialization, we must be careful
1267 * not to call any function that could possibly call _cerror().
1268 * For this purpose, we call only the raw system call wrappers.
1269 */
1270
1271 #ifdef __amd64
1272 /*
1273 * Gather information about cache layouts for optimized
1274 * AMD and Intel assembler strfoo() and memfoo() functions.
1275 */
1276 __proc64id();
1277 #endif
1278
1279 /*
1280 * Every libc, regardless of which link map, must register __cleanup().
1281 */
1282 (void) _atexit(__cleanup);
1283
1284 /*
1285 * Every libc, regardless of link map, needs to go through and check
1286 * its aux vectors. Doing so will indicate whether or not this has
1287 * been given a brand root (used to qualify various other data) or a
1288 * comm page (to optimize certain system actions).
1289 */
1290 init_auxv_data(udp);
1291
1292 /*
1293 * We keep our uberdata on one of (a) the first alternate link map
1294 * or (b) the primary link map. We switch to the primary link map
1295 * and stay there once we see it. All intermediate link maps are
1296 * subject to being unloaded at any time.
1297 */
1298 if (oldself != NULL && (oldself->ul_primarymap || !primary_link_map)) {
1299 __tdb_bootstrap = oldself->ul_uberdata->tdb_bootstrap;
1300 mutex_setup();
1301 atfork_init(); /* every link map needs atfork() processing */
1302 init_progname();
1303 return;
1304 }
1305
1306 /*
1307 * To establish the main stack information, we have to get our context.
1308 * This is also convenient to use for getting our signal mask.
1309 */
1310 uc.uc_flags = UC_ALL;
1311 (void) __getcontext(&uc);
1312 ASSERT(uc.uc_link == NULL);
|