xref: /illumos-gate/usr/src/common/dtrace/dtrace_data.c (revision c40a6cd785e883b3f052b122c332e21174fc1871)
1*e127a3e7Sraf /*
2*e127a3e7Sraf  * CDDL HEADER START
3*e127a3e7Sraf  *
4*e127a3e7Sraf  * The contents of this file are subject to the terms of the
5*e127a3e7Sraf  * Common Development and Distribution License (the "License").
6*e127a3e7Sraf  * You may not use this file except in compliance with the License.
7*e127a3e7Sraf  *
8*e127a3e7Sraf  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*e127a3e7Sraf  * or http://www.opensolaris.org/os/licensing.
10*e127a3e7Sraf  * See the License for the specific language governing permissions
11*e127a3e7Sraf  * and limitations under the License.
12*e127a3e7Sraf  *
13*e127a3e7Sraf  * When distributing Covered Code, include this CDDL HEADER in each
14*e127a3e7Sraf  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*e127a3e7Sraf  * If applicable, add the following below this CDDL HEADER, with the
16*e127a3e7Sraf  * fields enclosed by brackets "[]" replaced with your own identifying
17*e127a3e7Sraf  * information: Portions Copyright [yyyy] [name of copyright owner]
18*e127a3e7Sraf  *
19*e127a3e7Sraf  * CDDL HEADER END
20*e127a3e7Sraf  */
21*e127a3e7Sraf 
22*e127a3e7Sraf /*
23*e127a3e7Sraf  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24*e127a3e7Sraf  * Use is subject to license terms.
25*e127a3e7Sraf  */
26*e127a3e7Sraf 
27*e127a3e7Sraf #include <sys/types.h>
28*e127a3e7Sraf 
29*e127a3e7Sraf /*
30*e127a3e7Sraf  * In order to let the DTrace fasttrap provider trace processes before libc
31*e127a3e7Sraf  * is initialized, we place this structure in the thread pointer register.
32*e127a3e7Sraf  * This is communicated to the kernel (in the elfexec() function) by
33*e127a3e7Sraf  * placing the address of this structure in the PT_SUNWDTRACE program
34*e127a3e7Sraf  * header with the -zdtrace_data=<object> option to ld(1).
35*e127a3e7Sraf  *
36*e127a3e7Sraf  * Besides DTrace use, the initialization sequence carried out for the
37*e127a3e7Sraf  * PT_SUNWDTRACE data is an essential step required for the correct
38*e127a3e7Sraf  * initialization of any process.  Therefore, PT_SUNWDTRACE data must
39*e127a3e7Sraf  * exist in any interpretor available on Solaris.
40*e127a3e7Sraf  *
41*e127a3e7Sraf  * ld.so.1 is the standard interpretor on all Solaris platforms.  However,
42*e127a3e7Sraf  * for ABI compliance, 32-bit executables are able to identify libc.so.1
43*e127a3e7Sraf  * as their interpretor.  Therefore, this data file is used to build all
44*e127a3e7Sraf  * instances of ld.so.1, and the 32-bit versions of libc.so.1.  Note,
45*e127a3e7Sraf  * although libc.so.1 can act as an interpretor for 32-bit applications,
46*e127a3e7Sraf  * libc.so.1 only provides a bootstrap mechanism to load and jump to
47*e127a3e7Sraf  * ld.so.1.
48*e127a3e7Sraf  *
49*e127a3e7Sraf  * The fields of the program header are set as follows:
50*e127a3e7Sraf  *	p_type:         PT_SUNWDTRACE
51*e127a3e7Sraf  *	p_vaddr:        address of dtrace_data
52*e127a3e7Sraf  *	p_memsz:        size of dtrace_data
53*e127a3e7Sraf  *	p_flags:        flags of segment dtrace_data is assigned to
54*e127a3e7Sraf  *	p_paddr:        <reserved>
55*e127a3e7Sraf  *	p_filesz:       <reserved>
56*e127a3e7Sraf  *	p_offset:       <reserved>
57*e127a3e7Sraf  *	p_align:        <reserved>
58*e127a3e7Sraf  *
59*e127a3e7Sraf  * See the comment in fasttrap.h for information on how to safely change
60*e127a3e7Sraf  * this data structure and the other places that need to be kept in sync.
61*e127a3e7Sraf  */
62*e127a3e7Sraf 
63*e127a3e7Sraf #if defined(__sparc)
64*e127a3e7Sraf 
65*e127a3e7Sraf #pragma align 64(dtrace_data)
66*e127a3e7Sraf uint32_t	dtrace_data[32] = {
67*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
68*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
69*e127a3e7Sraf 	0x9de04000,			/* save %g1, %g0, %sp */
70*e127a3e7Sraf 	0x81e80000,			/* restore %g0, %g0, %g0 */
71*e127a3e7Sraf 	0x91d0203a,			/* ta 0x3a */
72*e127a3e7Sraf 	0x81ca0000,			/* return %o0 */
73*e127a3e7Sraf 	0, 0,				/* self pointer (must be zero) */
74*e127a3e7Sraf 	0, 0,
75*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0
76*e127a3e7Sraf };
77*e127a3e7Sraf 
78*e127a3e7Sraf #elif defined(__amd64)
79*e127a3e7Sraf 
80*e127a3e7Sraf #pragma align 64(dtrace_data)
81*e127a3e7Sraf uint8_t	dtrace_data[64] = {
82*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,		/* self pointer (must be zero) */
83*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
84*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
85*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
86*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
87*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
88*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
89*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0
90*e127a3e7Sraf };
91*e127a3e7Sraf 
92*e127a3e7Sraf #elif defined(__i386)
93*e127a3e7Sraf 
94*e127a3e7Sraf #pragma align 64(dtrace_data)
95*e127a3e7Sraf uint8_t	dtrace_data[64] = {
96*e127a3e7Sraf 	0, 0, 0, 0,			/* self pointer (must be zero)  */
97*e127a3e7Sraf 	0, 0, 0, 0,
98*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
99*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
100*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
101*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
102*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
103*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0,
104*e127a3e7Sraf 	0, 0, 0, 0, 0, 0, 0, 0
105*e127a3e7Sraf };
106*e127a3e7Sraf 
107*e127a3e7Sraf #else
108*e127a3e7Sraf 
109*e127a3e7Sraf #error "unknown ISA"
110*e127a3e7Sraf 
111*e127a3e7Sraf #endif
112