dtrace_data.c revision 14ea49401f3c8c61422aefbda43809e275f60c6c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License (the "License").
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You may not use this file except in compliance with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma ident "%Z%%M% %I% %E% SMI"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <sys/types.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * In order to let the DTrace fasttrap provider trace processes before libc
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * is initialized, we place this structure in the thread pointer register.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This is communicated to the kernel (in the elfexec() function) by
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * placing the address of this structure in the PT_SUNWDTRACE program
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * header with the -zdtrace_data=<object> option to ld(1).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Besides DTrace use, the initialization sequence carried out for the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * PT_SUNWDTRACE data is an essential step required for the correct
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * initialization of any process. Therefore, PT_SUNWDTRACE data must
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * exist in any interpretor available on Solaris.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * ld.so.1 is the standard interpretor on all Solaris platforms. However,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * for ABI compliance, 32-bit executables are able to identify libc.so.1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * as their interpretor. Therefore, this data file is used to build all
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * instances of ld.so.1, and the 32-bit versions of libc.so.1. Note,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * although libc.so.1 can act as an interpretor for 32-bit applications,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * libc.so.1 only provides a bootstrap mechanism to load and jump to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * ld.so.1.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The fields of the program header are set as follows:
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_type: PT_SUNWDTRACE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_vaddr: address of dtrace_data
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_memsz: size of dtrace_data
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_flags: flags of segment dtrace_data is assigned to
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_paddr: <reserved>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_filesz: <reserved>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_offset: <reserved>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * p_align: <reserved>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the comment in fasttrap.h for information on how to safely change
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * this data structure and the other places that need to be kept in sync.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#if defined(__sparc)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma align 64(dtrace_data)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncuint32_t dtrace_data[32] = {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0x9de04000, /* save %g1, %g0, %sp */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0x81e80000, /* restore %g0, %g0, %g0 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0x91d0203a, /* ta 0x3a */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0x81ca0000, /* return %o0 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, /* self pointer (must be zero) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#elif defined(__amd64)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma align 64(dtrace_data)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncuint8_t dtrace_data[64] = {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0, /* self pointer (must be zero) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#elif defined(__i386)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma align 64(dtrace_data)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncuint8_t dtrace_data[64] = {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, /* self pointer (must be zero) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync 0, 0, 0, 0, 0, 0, 0, 0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#else
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#error "unknown ISA"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif