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