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